The complete ASL owner is shown directly below.
12
345678910111213
14151617181920
21func AbortBundleSharedGenerationsForBundle()22begin23 for binding = 0 to 3 do24 if _BundleSharedBindings[[binding]].valid &&25 _BundleSharedBindings[[binding]].destination_assemble.valid then26 AbortBundleSharedGeneration(27 _BundleSharedBindings[[binding]].shared_tile_id);28 end;29 end;30end;31
32readonly func BundleSharedGenerationCoverageWithCurrent(33 shared_tile_id: SharedTileID,34 offset_cells: integer {0..2047},35 writer_cells: integer {1..2048},36 init: boolean) => bits(2048)37begin38 let index = SharedTileArrayIndex(shared_tile_id);39 var covered = if init then Zeros{2048}40 else _SharedGenerations[[index]].covered_cells;41 for cell = 0 to 2047 do42 if cell < writer_cells then43 covered[offset_cells + cell] = '1';44 end;45 end;46 return covered;47end;48
49readonly func ValidateBundleSharedGeneration() => boolean50begin51 for binding = 0 to 3 do52 if _BundleSharedBindings[[binding]].valid &&53 _BundleSharedBindings[[binding]].destination_assemble.valid then54 let shared_tile_id =55 _BundleSharedBindings[[binding]].shared_tile_id;56 let index = SharedTileArrayIndex(shared_tile_id);57 let assemble =58 _BundleSharedBindings[[binding]].destination_assemble;59 let writer_size = _BundleSharedBindings[[binding]].size_code;60 let participant_mask = _BundleSharedBindings[[binding]].pe_mask;61 if writer_size < 1 || writer_size > 12 then return FALSE; end;62 if assemble.init && _SharedGenerations[[index]].open then63 return FALSE;64 end;65 if !assemble.init &&66 (!_SharedGenerations[[index]].open ||67 _SharedGenerations[[index]].closed) then68 return FALSE;69 end;70 if !assemble.init &&71 _SharedGenerations[[index]].participant_mask !=72 participant_mask then73 return FALSE;74 end;75 let raw_offset = UInt(assemble.offset);76 if raw_offset > 2047 then return FALSE; end;77 let offset_cells = raw_offset as integer {0..2047};78 let writer_cells = BundleLocalGenerationCellCount(79 writer_size as integer {1..12});80 let parent_cells = if assemble.init then81 BundleLocalGenerationCellCount(82 assemble.size_code as integer {1..12})83 else _SharedGenerations[[index]].parent_cell_count;84 if offset_cells + writer_cells > parent_cells then return FALSE; end;85 if !assemble.init then86 for cell = 0 to 2047 do87 if cell < writer_cells &&88 _SharedGenerations[[index]].covered_cells[89 offset_cells + cell] == '1' then90 return FALSE;91 end;92 end;93 end;94 if assemble.last then95 let covered = BundleSharedGenerationCoverageWithCurrent(96 shared_tile_id, offset_cells, writer_cells,97 assemble.init);98 for cell = 0 to 2047 do99 if cell < parent_cells && covered[cell] == '0' then100 return FALSE;101 end;102 end;103 end;104 end;105 end;106 return TRUE;107end;108
109func CommitBundleSharedGenerationCandidate(110 binding: BundleSharedBindingIndex,111 candidate: SharedTileInfo) => boolean112begin113 assert _BundleSharedBindings[[binding]].valid &&114 _BundleSharedBindings[[binding]].destination_assemble.valid;115 let shared_tile_id = _BundleSharedBindings[[binding]].shared_tile_id;116 let index = SharedTileArrayIndex(shared_tile_id);117 let assemble = _BundleSharedBindings[[binding]].destination_assemble;118 let participant_mask = _BundleSharedBindings[[binding]].pe_mask;119 let writer_size = _BundleSharedBindings[[binding]].size_code120 as integer {1..12};121 let offset_cells = UInt(assemble.offset) as integer {0..2047};122 let writer_cells = BundleLocalGenerationCellCount(writer_size);123 if !candidate.descriptor_valid ||124 candidate.allocation_mask != participant_mask then125 return FALSE;126 end;127 if assemble.init then128 let parent_size = assemble.size_code as integer {1..12};129 let parent_bytes = TileSizeCodeBytes(parent_size);130 let parent_rows = DerivedTileRows(131 parent_bytes, candidate.tile.columns, candidate.tile.data_type);132 if parent_rows == 0 then return FALSE; end;133 _SharedGenerations[[index]].open = TRUE;134 _SharedGenerations[[index]].closed = FALSE;135 _SharedGenerations[[index]].published = FALSE;136 _SharedGenerations[[index]].shared_tile_id = shared_tile_id;137 _SharedGenerations[[index]].participant_mask = participant_mask;138 _SharedGenerations[[index]].parent_size_code = parent_size;139 _SharedGenerations[[index]].parent_cell_count =140 BundleLocalGenerationCellCount(parent_size);141 _SharedGenerations[[index]].covered_cells = Zeros{2048};142 _SharedGenerations[[index]].ready_cells = Zeros{2048};143 _SharedGenerations[[index]].last_seen = FALSE;144 _SharedGenerations[[index]].working_valid = TRUE;145 _SharedGenerations[[index]].working_tile = candidate.tile;146 _SharedGenerations[[index]].working_tile.capacity_bytes = parent_bytes;147 _SharedGenerations[[index]].working_tile.rows = parent_rows;148 _SharedGenerations[[index]].working_tile.contents_defined = FALSE;149 _SharedGenerations[[index]].working_tile.defined_elements =150 Zeros{PTO_MODEL_TILE_ELEMENTS};151 _SharedGenerations[[index]].working_tile.packed_defined_elements =152 ZeroPackedTileDefinedElements();153 _SharedGenerations[[index]].working_tile.defined_valid_elements = 0;154 _SharedGenerations[[index]].working_initialized_mask = Zeros{4};155 else156 if !_SharedGenerations[[index]].working_valid ||157 _SharedGenerations[[index]].working_tile.columns !=158 candidate.tile.columns ||159 _SharedGenerations[[index]].working_tile.data_type !=160 candidate.tile.data_type ||161 _SharedGenerations[[index]].working_tile.layout !=162 candidate.tile.layout then163 return FALSE;164 end;165 end;166 let element_bits = TileElementBits(candidate.tile.data_type);167 let destination_offset =168 ((offset_cells * PTO_TILE_CELL_BYTES * 8) DIVRM element_bits)169 as integer {0..524287};170 let source_elements =171 ((candidate.tile.capacity_bytes * 8) DIVRM element_bits)172 as integer {1..524288};173 let parent_elements = TileLogicalElementCapacity(174 _SharedGenerations[[index]].working_tile.capacity_bytes,175 candidate.tile.data_type);176 if destination_offset + source_elements > parent_elements then177 return FALSE;178 end;179 if candidate.tile.valid_rows == 0 ||180 candidate.tile.valid_columns == 0 then181 return FALSE;182 end;183 var working = _SharedGenerations[[index]].working_tile;184 for element = 0 to source_elements - 1 looplimit 524288 do185 let source_index = element as PackedTileElementIndex;186 let destination_index = (destination_offset + element)187 as PackedTileElementIndex;188 if TileLogicalElementDefined(candidate.tile, source_index) then189 working = TileInfoWithLogicalElement(190 working, destination_index,191 TileReadLogicalElement(candidate.tile, source_index));192 end;193 end;194 _SharedGenerations[[index]].working_tile = working;195 let working_columns = working.columns as integer {1..65535};196 let last_valid_row = (candidate.tile.valid_rows - 1)197 as integer {0..65534};198 let last_valid_column = (candidate.tile.valid_columns - 1)199 as integer {0..65534};200 let candidate_valid_extent =201 (TileLogicalLinearIndex(candidate.tile, last_valid_row,202 last_valid_column) + 1) as integer {1..524288};203 let required_end = destination_offset + candidate_valid_extent;204 if required_end > parent_elements then return FALSE; end;205 let required_rows = ((required_end +206 (working_columns - 1)) DIVRM working_columns)207 as integer {1..65535};208 if _SharedGenerations[[index]].working_tile.valid_rows < required_rows then209 _SharedGenerations[[index]].working_tile.valid_rows = required_rows;210 end;211 if _SharedGenerations[[index]].working_tile.valid_columns <212 candidate.tile.valid_columns then213 _SharedGenerations[[index]].working_tile.valid_columns =214 candidate.tile.valid_columns;215 end;216 let covered = BundleSharedGenerationCoverageWithCurrent(217 shared_tile_id, offset_cells, writer_cells, assemble.init);218 _SharedGenerations[[index]].covered_cells = covered;219 _SharedGenerations[[index]].ready_cells = covered;220 _SharedGenerations[[index]].working_initialized_mask =221 _SharedGenerations[[index]].working_initialized_mask OR222 candidate.initialized_mask;223 if assemble.last then224 _SharedGenerations[[index]].last_seen = TRUE;225 _SharedGenerations[[index]].closed = TRUE;226 _SharedGenerations[[index]].open = FALSE;227 _SharedGenerations[[index]].published = TRUE;228 _SharedGenerations[[index]].working_tile.contents_defined = TRUE;229 _SharedTiles[[index]].descriptor_valid = TRUE;230 _SharedTiles[[index]].allocation_mask = participant_mask;231 _SharedTiles[[index]].initialized_mask = participant_mask;232 _SharedTiles[[index]].whole_parent_ready = TRUE;233 _SharedTiles[[index]].published = TRUE;234 _SharedTiles[[index]].tile =235 _SharedGenerations[[index]].working_tile;236 end;237 return TRUE;238end;239
240func BeginBundleSharedGenerationProbe(shared_tile_id: SharedTileID)241 => SharedTileInfo242begin243 let index = SharedTileArrayIndex(shared_tile_id);244 let prior = _SharedTiles[[index]];245 _SharedTiles[[index]].descriptor_valid = FALSE;246 _SharedTiles[[index]].allocation_mask = Zeros{4};247 _SharedTiles[[index]].initialized_mask = Zeros{4};248 _SharedTiles[[index]].whole_parent_ready = FALSE;249 _SharedTiles[[index]].published = FALSE;250 return prior;251end;252
253func RestoreBundleSharedGenerationProbe(254 shared_tile_id: SharedTileID, prior: SharedTileInfo)255begin256 _SharedTiles[[SharedTileArrayIndex(shared_tile_id)]] = prior;257end;258
259readonly func BundleSharedSubviewOffsetRawForPE(260 binding: BundleSharedBindingIndex, pe_identity: MemoryAgentId) => Word261begin262 let modifier = _BundleSharedBindings[[binding]].source0_subview;263 return ReadPEAbsoluteGPROperand(pe_identity, modifier.reg_src) +264 ZeroExtend{PTO_XLEN}(modifier.uimm11);265end;266
267readonly func BundleSharedSubviewOffsetCellsForPE(268 binding: BundleSharedBindingIndex, pe_identity: MemoryAgentId)269 => integer {0..2047}270begin271 let raw_offset = UInt(BundleSharedSubviewOffsetRawForPE(272 binding, pe_identity));273 assert raw_offset <= 2047;274 return raw_offset as integer {0..2047};275end;276
277readonly func BundleSharedSubviewLegal(278 binding: BundleSharedBindingIndex) => boolean279begin280 if !_BundleSharedBindings[[binding]].valid ||281 !_BundleSharedBindings[[binding]].source0_subview.valid ||282 _BundleSharedBindings[[binding]].size_code != 0 then283 return FALSE;284 end;285 let shared_tile_id = _BundleSharedBindings[[binding]].shared_tile_id;286 if !SharedTilePublished(shared_tile_id) then return FALSE; end;287 let parent = SharedTileRecord(shared_tile_id).tile;288 if TileLayoutIsCube(parent.layout) || parent.columns == 0 then289 return FALSE;290 end;291 let modifier = _BundleSharedBindings[[binding]].source0_subview;292 if modifier.size_code == 0 then return FALSE; end;293 let selected_bytes = TileSizeCodeBytes(294 modifier.size_code as integer {1..12});295 let element_bits = TileElementBits(parent.data_type);296 let bounded_columns = parent.columns as integer {1..65535};297 for pe = 0 to PTO_MODEL_MEMORY_AGENTS - 1 do298 let pe_identity = pe as MemoryAgentId;299 if _BundleSharedBindings[[binding]].pe_mask[300 PTOPEMaskBitOfPEIdentity(pe_identity)] == '1' then301 let raw_offset = UInt(BundleSharedSubviewOffsetRawForPE(302 binding, pe_identity));303 if raw_offset > 2047 then return FALSE; end;304 let offset_cells = raw_offset as integer {0..2047};305 if offset_cells * PTO_TILE_CELL_BYTES + selected_bytes >306 parent.capacity_bytes then307 return FALSE;308 end;309 let offset_elements =310 ((offset_cells * PTO_TILE_CELL_BYTES * 8) DIVRM element_bits)311 as integer {0..524287};312 let selected_elements = ((selected_bytes * 8) DIVRM element_bits)313 as integer {1..524288};314 let origin_column = (offset_elements MOD bounded_columns)315 as integer {0..65535};316 if selected_elements > bounded_columns - origin_column &&317 (origin_column != 0 || selected_elements MOD bounded_columns != 0) then318 return FALSE;319 end;320 if selected_elements > bounded_columns - origin_column &&321 selected_elements DIVRM bounded_columns > 65535 then322 return FALSE;323 end;324 end;325 end;326 return TRUE;327end;328
329readonly func MaterializeBundleSharedSubviewForPE(330 binding: BundleSharedBindingIndex, pe_identity: MemoryAgentId) => TileInfo331begin332 assert BundleSharedSubviewLegal(binding);333 let shared_tile_id = _BundleSharedBindings[[binding]].shared_tile_id;334 let parent = SharedTileRecord(shared_tile_id).tile;335 let modifier = _BundleSharedBindings[[binding]].source0_subview;336 let offset_cells = BundleSharedSubviewOffsetCellsForPE(337 binding, pe_identity);338 let selected_bytes = TileSizeCodeBytes(339 modifier.size_code as integer {1..12});340 let element_bits = TileElementBits(parent.data_type);341 let bounded_columns = parent.columns as integer {1..65535};342 let offset_elements =343 ((offset_cells * PTO_TILE_CELL_BYTES * 8) DIVRM element_bits)344 as integer {0..524287};345 let selected_elements = ((selected_bytes * 8) DIVRM element_bits)346 as integer {1..524288};347 let origin_row = (offset_elements DIVRM bounded_columns)348 as integer {0..65535};349 let origin_column = (offset_elements MOD bounded_columns)350 as integer {0..65535};351 let selected_columns = (if selected_elements <=352 bounded_columns - origin_column then selected_elements353 else bounded_columns) as integer {1..65535};354 let selected_rows = (if selected_elements <=355 bounded_columns - origin_column then 1356 else selected_elements DIVRM bounded_columns)357 as integer {1..65535};358 var tile = parent;359 tile.capacity_bytes = selected_bytes;360 tile.rows = DerivedTileRows(361 selected_bytes, selected_columns, parent.data_type);362 tile.columns = selected_columns;363 tile.valid_rows = selected_rows;364 tile.valid_columns = selected_columns;365 if origin_row + tile.valid_rows > parent.valid_rows then366 tile.valid_rows = if origin_row < parent.valid_rows then367 (parent.valid_rows - origin_row) as integer {0..65535}368 else 0;369 end;370 if origin_column + tile.valid_columns > parent.valid_columns then371 tile.valid_columns = if origin_column < parent.valid_columns then372 (parent.valid_columns - origin_column) as integer {0..65535}373 else 0;374 end;375 tile.defined_elements = Zeros{PTO_MODEL_TILE_ELEMENTS};376 tile.packed_defined_elements = ZeroPackedTileDefinedElements();377 tile.defined_valid_elements = 0;378 tile.contents_defined = FALSE;379 for element = 0 to selected_elements - 1 looplimit 524288 do380 let source_index = (offset_elements + element)381 as PackedTileElementIndex;382 let destination_index = element as PackedTileElementIndex;383 tile = TileInfoWithLogicalElement(tile, destination_index,384 ReadSharedTileWord(shared_tile_id, source_index));385 end;386 tile.contents_defined = TRUE;387 tile.defined_valid_elements =388 (tile.valid_rows * tile.valid_columns) as integer {0..524288};389 return tile;390end;391
392readonly func MaterializeBundleSharedSubview(393 binding: BundleSharedBindingIndex) => TileInfo394begin395 return MaterializeBundleSharedSubviewForPE(binding, _CurrentMemoryAgent);396end;397