CHIP-SPV / chipStar

chipStar is a tool for compiling and running HIP/CUDA on SPIR-V via OpenCL or Level Zero APIs.
Other
157 stars 27 forks source link

rtdevlib: fix function signature mismatches #851

Closed linehill closed 1 month ago

linehill commented 1 month ago

A issue discovered while running HIP programs on OpenCL-BE->rusticl (with #830). Linking of __chip_atomic_add_f* symbols failed because the caller's and callee's function signature differed by their pointer parameters (pointee type didn't match).

The mismatch was caused by LLVM-SPIRV-Translator's feature that attempts to recover original pointee types in LLVM bitcodes that use opaque pointers. But the way it attempts to infer the types may end up with SPIR-V functions with different pointee type across SPIR-V modules.

The issue is worked around by passing pointers as integers for functions whose definitions are linked in at runtime.