Skip to content

Add support for 32/16-bit mem-mode truncation through assigning 32/16-bit ID#13

Draft
MinliLiao wants to merge 12 commits into
RIKEN-RCCS:developfrom
MinliLiao:mem-mode-id
Draft

Add support for 32/16-bit mem-mode truncation through assigning 32/16-bit ID#13
MinliLiao wants to merge 12 commits into
RIKEN-RCCS:developfrom
MinliLiao:mem-mode-id

Conversation

@MinliLiao
Copy link
Copy Markdown

@MinliLiao MinliLiao commented May 28, 2026

To retain __raptor_fp for native floating point variables across function boundaries, mem-mode stores the address of the __raptor_fp into the native floating point value to retrieve __raptor_fp.
However, this limits the mem-mode support to truncate from floating point types as large as a pointer (i.e. double on a 64-bit machine), since floating point types of smaller bit width is not able to hold the address of the __raptor_fp.

This pull request adds support for mem-mode truncation from floating point types that have smaller bit width than a pointer through assigning unique IDs as wide as the floating point type:

  • A new vector of __raptor_fp * is added per C++ floating point types.
  • Once a new __raptor_fp for a C++ floating point value is created, the address of the __raptor_fp is added to the vector for the corresponding C++ floating point type.
  • The index in the vector for the __raptor_fp * is stored into the C++ floating point value as an ID.
  • Across function boundaries, the C++ floating point value carries this ID, which is then used to index into the vector of corresponding C++ floating point type to retrieve the __raptor_fp *.

Since the unique IDs are as wide as the floating point type, this limits the number of floating point values that can be truncated. To handle this limitation:

  • A runtime check is added where if a new ID to be assigned to a new __raptor_fp would exceed the limit of the corresponding native floating point type bit width, an error message will be printed before sending an abort signal.
  • Upon the destruction of a GCFloatTy, the address of the __raptor_fp it contains is removed from the vector of __raptor_fp *, freeing up it's corresponding ID.
  • A second vector of IDs is added per C++ floating point types to hold the pool free IDs.
  • If there are any free IDs, a free ID is reused for a new __raptor_fp instead of incrementing the size of the __raptor_fp * vector to obtain new ID.

Compile-time constraints have also been added to check if the type used as input for mem-mode truncation is supported.
Compile-time constraints also make sure that ID is not used when truncating from types as wide as a pointer, preserving the 64-bit truncation behavior.
Using mem-mode truncation on unsupported types will result in compile time error (instead of the previous behavior of runtime abort).

While this pull request is independent, testing this feature with any floating point operations or standard math lib functions requires applying fixes for issue #10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant