The complete ASL owner is shown directly below.
12implementation func ReadMonotonicTime() => Word3begin4 return _SystemRegisters.cycle;5end;6
7implementation func FloatingExponential(value: real) => real8begin9 10 11 var result: real = 1.0;12 var term: real = 1.0;13 for index = 1 to 18 do14 term = (term * value) / Real(index);15 result = result + term;16 end;17 return result;18end;19
20implementation func FloatingRoundNearest(value: real) => integer21begin22 let lower = RoundDown(value);23 let fraction = value - Real(lower);24 if fraction < 0.5 then return lower;25 elsif fraction > 0.5 then return lower + 1;26 elsif lower MOD 2 == 0 then return lower;27 else return lower + 1;28 end;29end;30
31implementation func ScalarFPBinaryProfile(operation: FloatingBinaryOperation,32 rounding_mode: NumericRoundingMode,33 source_type: bits(5),34 left: Word, right: Word)35 => (Word, bits(5))36begin37 assert ScalarFPTypeCodeSupported(source_type);38 case operation of39 when FloatingBinary_ADD => return (left + right, Zeros{5});40 when FloatingBinary_SUB => return (left - right, Zeros{5});41 when FloatingBinary_MUL => return (MultiplyWord(left, right), Zeros{5});42 when FloatingBinary_DIV =>43 if ScalarFPCarrierIsZero(right, source_type) then44 return (Ones{PTO_XLEN}, Zeros{5} + 2);45 else return (DivideWordUnsigned(left, right), Zeros{5});46 end;47 48 49 when FloatingBinary_MIN =>50 if SInt(left) <= SInt(right) then return (left, Zeros{5});51 else return (right, Zeros{5});52 end;53 when FloatingBinary_MAX =>54 if SInt(left) >= SInt(right) then return (left, Zeros{5});55 else return (right, Zeros{5});56 end;57 end;58end;59
60implementation func ScalarFPUnaryProfile(operation: FloatingUnaryOperation,61 rounding_mode: NumericRoundingMode,62 source_type: bits(5), value: Word)63 => (Word, bits(5))64begin65 assert ScalarFPTypeCodeSupported(source_type);66 case operation of67 when FloatingUnary_ABS =>68 if source_type == '00001' then69 return (ZeroExtend{PTO_XLEN}(value[30:0]), Zeros{5});70 else return (value AND (Zeros{PTO_XLEN} + 0x7fffffffffffffff), Zeros{5});71 end;72 when FloatingUnary_SQRT => return (value, Zeros{5});73 when FloatingUnary_EXP => return (value + 1, Zeros{5});74 when FloatingUnary_RECIP =>75 if ScalarFPCarrierIsZero(value, source_type) then76 return (Ones{PTO_XLEN}, Zeros{5} + 2);77 else return (DivideWordUnsigned(Ones{PTO_XLEN}, value), Zeros{5});78 end;79 end;80end;81
82implementation func ScalarFPFusedProfile(operation: FloatingFusedOperation,83 rounding_mode: NumericRoundingMode,84 source_type: bits(5), addend: Word,85 left: Word, right: Word)86 => (Word, bits(5))87begin88 assert ScalarFPTypeCodeSupported(source_type);89 let product = MultiplyWord(left, right);90 case operation of91 when FloatingFused_MADD => return (product + addend, Zeros{5});92 when FloatingFused_MSUB => return (product - addend, Zeros{5});93 when FloatingFused_NMADD =>94 return (Zeros{PTO_XLEN} - (product + addend), Zeros{5});95 when FloatingFused_NMSUB =>96 return (Zeros{PTO_XLEN} - (product - addend), Zeros{5});97 end;98end;99
100implementation func ScalarFPToIntegerProfile(101 rounding_mode: NumericRoundingMode, destination_type: bits(5),102 source_type: bits(5), value: Word) => (Word, bits(5))103begin104 assert ScalarIntegerTypeCodeSupported(destination_type);105 assert ScalarFPTypeCodeSupported(source_type);106 return (value, Zeros{5});107end;108
109implementation func ScalarFPConvertProfile(110 rounding_mode: NumericRoundingMode, destination_type: bits(5),111 source_type: bits(5), value: Word) => (Word, bits(5))112begin113 assert ScalarFPTypeCodeSupported(destination_type);114 assert ScalarFPTypeCodeSupported(source_type);115 return (value, Zeros{5});116end;117
118implementation func ScalarIntegerToFPProfile(119 rounding_mode: NumericRoundingMode, source_type: bits(5),120 destination_type: bits(5), value: Word) => (Word, bits(5))121begin122 assert ScalarIntegerTypeCodeSupported(source_type);123 assert ScalarFPTypeCodeSupported(destination_type);124 return (value, Zeros{5});125end;126
127implementation func TileSquareRoot(value: Word) => Word128begin129 return value;130end;131
132implementation func TileLogarithm(value: Word) => Word133begin134 return value;135end;136
137implementation func TileReciprocal(value: Word) => Word138begin139 return DivideWordUnsigned(Ones{PTO_XLEN}, value);140end;141
142implementation func TileReciprocalSquareRoot(value: Word) => Word143begin144 return value;145end;146
147implementation func TileExponential(value: Word) => Word148begin149 return value + 1;150end;151
152readonly implementation func AtomicAddress(address: Word,153 far: boolean) => Word154begin155 return address;156end;157
158readonly implementation func TranslateDataAddress(address: Word,159 size_bytes: integer {1..262144},160 write: boolean) => Word161begin162 return address;163end;164
165readonly implementation func DataAccessPermitted(address: Word,166 size_bytes: integer {1..262144},167 write: boolean) => boolean168begin169 let end_address = UInt(address) + size_bytes;170 if end_address > PTO_MODEL_MEMORY_BYTES then return FALSE; end;171 172 173 if CurrentACR() >= 2 then return end_address <= 3072;174 else return TRUE;175 end;176end;177
178implementation func SaveTrapContext(target: AccessControlRing,179 source: AccessControlRing)180begin181 _TrapContexts[[target]].valid = TRUE;182 _TrapContexts[[target]].source_acr = source;183 _TrapContexts[[target]].tpc = ReadTPC();184 _TrapContexts[[target]].bpc = ReadBPC();185 _TrapContexts[[target]].core_state = _SystemRegisters.core_state;186 _TrapContexts[[target]].bundle_argument = _BundleArgument;187 _TrapContexts[[target]].commit_argument = _CommitArgument;188 _TrapContexts[[target]].bundle_active = _BundleActive;189 _TrapContexts[[target]].bundle_body_active = _BundleBodyActive;190 _TrapContexts[[target]].bundle_commit_target_set = _BundleCommitTargetSet;191 _TrapContexts[[target]].bundle_condition_set = _BundleConditionSet;192 _TrapContexts[[target]].system_block_terminal_pending =193 _SystemBlockTerminalPending;194 _TrapContexts[[target]].barg = _BARG;195 _TrapContexts[[target]].bundle_sequential_pc = _BundleSequentialPC;196 _TrapContexts[[target]].frame_stack_return_target =197 _FrameStackReturnTarget;198 _TrapContexts[[target]].return_address = _ReturnAddress;199 _TrapContexts[[target]].bundle_argument_kind = _BundleArgumentKind;200 _TrapContexts[[target]].bundle_operation = _BundleOperation;201 _TrapContexts[[target]].bundle_dimensions = _BundleDimensions;202 _TrapContexts[[target]].bundle_dimension_present =203 _BundleDimensionPresent;204 _TrapContexts[[target]].bundle_scalar_bindings = _BundleScalarBindings;205 _TrapContexts[[target]].bundle_tile_bindings = _BundleTileBindings;206 _TrapContexts[[target]].bundle_shared_bindings = _BundleSharedBindings;207 _TrapContexts[[target]].bundle_range_group = _BundleRangeGroup;208 _TrapContexts[[target]].bundle_zero_participation_seen =209 _BundleZeroParticipationSeen;210 _TrapContexts[[target]].bundle_control_attributes =211 _BundleControlAttributes;212 _TrapContexts[[target]].bundle_data_attributes = _BundleDataAttributes;213 _TrapContexts[[target]].bundle_data_attributes_present =214 _BundleDataAttributesPresent;215 _TrapContexts[[target]].bundle_hint = _BundleHint;216 _TrapContexts[[target]].bundle_fixed_point_attributes =217 _BundleFixedPointAttributes;218 _TrapContexts[[target]].local_generations = _LocalGenerations;219 _TrapContexts[[target]].shared_generations = _SharedGenerations;220 _TrapContexts[[target]].bundle_execution_domain_token =221 _BundleExecutionDomainToken;222 _TrapContexts[[target]].memory_copy_template = _MemoryCopyTemplate;223 _TrapContexts[[target]].frame_template = _FrameTemplate;224 _TrapContexts[[target]].t_queue = _TQueue;225 _TrapContexts[[target]].t_queue_valid = _TQueueValid;226 _TrapContexts[[target]].u_queue = _UQueue;227 _TrapContexts[[target]].u_queue_valid = _UQueueValid;228 _TrapContexts[[target]].predicates = _PredicateRegisters;229
230 var ecstate = _SystemRegisters.core_state;231 ecstate[3:0] = AccessControlRingBits(source);232 ecstate[4] = if _BundleBodyActive then '1' else '0';233 PTOv0WriteContextRegister(target, 0x0f00, ecstate);234
235 var control: Word = Zeros{PTO_XLEN};236 control[3:0] = AccessControlRingBits(source);237 control[4] = '1';238 control[5] = if _BundleActive then '1' else '0';239 control[6] = if _BundleBodyActive then '1' else '0';240 control[10:7] = PTOv0BundleKindCode(_BARG.block_type);241 control[13:11] = PTOv0BundleTransferCode(_BARG.transfer_type);242 control[14] = if _BARG.taken then '1' else '0';243 PTOv0WriteContextRegister(target, 0x0f40, control);244 PTOv0WriteContextRegister(target, 0x0f41, ReadBPC());245 PTOv0WriteContextRegister(target, 0x0f42, _BARG.bpcn);246 PTOv0WriteContextRegister(target, 0x0f43, ReadTPC());247 PTOv0WriteContextRegister(target, 0x0f44, _ReturnAddress);248 for index = 0 to PTO_TEMPORARY_QUEUE_DEPTH - 1 do249 PTOv0WriteContextRegister(target, 0x0f45 + index,250 _TQueue[[index]]);251 PTOv0WriteContextRegister(target, 0x0f49 + index,252 _UQueue[[index]]);253 end;254 PTOv0WriteContextRegister(target, 0x0f4d, Zeros{PTO_XLEN});255 PTOv0WriteContextRegister(target, 0x0f4e, Zeros{PTO_XLEN});256end;257
258implementation func TileProfileFloatingModulo(data_type: TileDataType,259 left: Word, right: Word) => Word260begin261 let encoding = TileDataTypeToEncoding(data_type);262 if ScalarFPCarrierIsZero(right, encoding) then263 return Ones{PTO_XLEN};264 end;265 let quotient = DivideWordUnsigned(left, right);266 return left - MultiplyWord(quotient, right);267end;268
269implementation func TileProfileUnary(op: TileUnaryOperation,270 data_type: TileDataType,271 value: Word) => (Word, bits(5))272begin273 if TileUnaryUsesClosedElementwiseContract(op) then274 let (result, invalid) = TileFixedUnaryValue(275 op,276 data_type,277 value);278 return (279 result,280 if invalid then Zeros{5} + 1 else Zeros{5});281 end;282 return (283 TileUnaryValue(op, value),284 Zeros{5});285end;286
287implementation func TileProfileFloatingCompare(288 comparison: TileComparison,289 data_type: TileDataType,290 left: Word,291 right: Word) => (boolean, bits(5))292begin293 let left_class = TileNumericValueClass(data_type, left);294 let right_class = TileNumericValueClass(data_type, right);295 let signaling_nan =296 left_class == NumericValue_SignalingNaN ||297 right_class == NumericValue_SignalingNaN;298 if NumericValueClassIsNaN(left_class) ||299 NumericValueClassIsNaN(right_class) then300 return (301 comparison == TileComparison_NE,302 if signaling_nan then Zeros{5} + 1 else Zeros{5});303 end;304 let both_zero = NumericValueClassIsZero(left_class) &&305 NumericValueClassIsZero(right_class);306 let equal = both_zero || left == right;307 let left_less = if both_zero then FALSE else308 UInt(TileFloatingOrderKey(data_type, left)) <309 UInt(TileFloatingOrderKey(data_type, right));310 return (TileCompareBoolean(comparison, left_less, equal), Zeros{5});311end;312
313implementation func TileProfileReductionInitial(314 operation: TileReductionOperation,315 data_type: TileDataType,316 first: Word) => Word317begin318 return TileReductionInitialValue(319 operation,320 data_type,321 first);322end;323
324implementation func TileProfileReductionStep(325 operation: TileReductionOperation,326 data_type: TileDataType,327 accumulator: Word, value: Word) => (Word, boolean)328begin329 let (result, selected, -) = TileReductionStepWithFlags(330 operation,331 data_type,332 accumulator,333 value);334 return (result, selected);335end;336
337implementation func TileProfileMixedExpdifFP32(338 source_type: TileDataType,339 left: Word,340 broadcast: Word) => (Word, bits(5))341begin342 assert source_type == TileDataType_FP16 ||343 source_type == TileDataType_BF16;344 let (handled, discriminator_result) =345 HardwareNumericMixedExpdifDiscriminator(left, broadcast);346 if handled then return (discriminator_result, Zeros{5}); end;347
348 let (difference, subtract_flags) = TileProfileBinaryWithFlags(349 TileBinary_SUB,350 TileDataType_FP32,351 left,352 broadcast);353 let (special_handled, special_result, special_flags) =354 TileSFUUnarySpecialValue(355 TileUnary_EXP,356 TileDataType_FP32,357 difference);358 if special_handled then359 return (360 special_result,361 subtract_flags OR special_flags);362 end;363
364 let (profile_result, profile_flags) = TileProfileUnary(365 TileUnary_EXP,366 TileDataType_FP32,367 difference);368 return (369 profile_result,370 subtract_flags OR profile_flags);371end;372implementation func TileProfileExpand(op: TileExpandOperation,373 data_type: TileDataType,374 left: Word, broadcast: Word) => Word375begin376 return TileExpandValue(377 op,378 data_type,379 left,380 broadcast);381end;382implementation func TileProfileOrderLeft(left: Word, right: Word,383 descending: boolean,384 data_type: TileDataType) => boolean385begin386 if descending then return SInt(left) >= SInt(right);387 else return SInt(left) <= SInt(right);388 end;389end;390
391implementation func TileProfileValueIsNaN(value: Word,392 data_type: TileDataType) => boolean393begin394 395 return FALSE;396end;397
398implementation func TileProfileMatrixAccumulate(399 accumulator: Word, left: Word, right: Word,400 destination_type: TileDataType, left_type: TileDataType,401 right_type: TileDataType, control: NumericExecutionControl) => Word402begin403 return accumulator + MultiplyWord(left, right);404end;405
406implementation func TileProfileFusedMultiplyAdd(407 data_type: TileDataType,408 addend: Word,409 left: Word,410 right: Word) => (Word, bits(5))411begin412 return ScalarFPFusedProfile(413 FloatingFused_MADD,414 DefaultNumericExecutionControl().rounding_mode,415 TileDataTypeToEncoding(data_type),416 addend,417 left,418 right);419end;420
421implementation func TileProfileFusedInvalidResult(422 data_type: TileDataType,423 left: Word,424 right: Word,425 addend: Word) => (Word, bits(5))426begin427 let (available, quiet_nan) =428 HardwareNumericCanonicalNaNResult(data_type);429 assert available;430 return (quiet_nan, Zeros{5} + 1);431end;432
433implementation func TileProfileMatrixBias(value: Word, bias: Word,434 destination_type: TileDataType,435 bias_type: TileDataType) => Word436begin437 return value + bias;438end;439
440implementation func TileProfileMatrixScaledAccumulate(441 accumulator: Word, left: Word, right: Word,442 left_scale: Word, right_scale: Word,443 left_scale_present: boolean, right_scale_present: boolean,444 destination_type: TileDataType, left_type: TileDataType,445 right_type: TileDataType, left_scale_type: TileDataType,446 right_scale_type: TileDataType) => Word447begin448 let scaled_left = if left_scale_present then449 MultiplyWord(left, left_scale)450 else451 left;452 let scaled_right = if right_scale_present then453 MultiplyWord(right, right_scale)454 else455 right;456 return accumulator + MultiplyWord(scaled_left, scaled_right);457end;458