Emit pool size annotation into the IR. Must be called after all ``alloc()`` / ``move_base_to()`` calls. Parameters ---------- size : int, optional Explicit shared memory size in bytes. When *None* (the default), the high-water mark ``max_off
(self, size=None)
| 502 | self.max_offset = max(self.max_offset, self.offset) |
| 503 | |
| 504 | def commit(self, size=None): |
| 505 | """Emit pool size annotation into the IR. |
| 506 | |
| 507 | Must be called after all ``alloc()`` / ``move_base_to()`` calls. |
| 508 | |
| 509 | Parameters |
| 510 | ---------- |
| 511 | size : int, optional |
| 512 | Explicit shared memory size in bytes. When *None* (the default), |
| 513 | the high-water mark ``max_offset`` tracked by the allocator is used. |
| 514 | """ |
| 515 | if not self._owns_buffer: |
| 516 | return |
| 517 | ir = _get_ir() |
| 518 | frame_mod = _get_frame() |
| 519 | resolved = size if size is not None else self.max_offset |
| 520 | assert resolved >= self.max_offset, ( |
| 521 | f"Specified smem size ({resolved}) is smaller than " |
| 522 | f"the pool high-water mark ({self.max_offset})" |
| 523 | ) |
| 524 | attr_frame = ir.attr(self.ptr, "tirx.pool_max_bytes", resolved) |
| 525 | if isinstance(attr_frame, frame_mod.AttrFrame): |
| 526 | from functools import partial |
| 527 | |
| 528 | attr_frame.add_callback(partial(attr_frame.__exit__, None, None, None)) |
| 529 | attr_frame.__enter__() |