kparzysz wrote: > Yeah I was actually wondering if I should go for something like this: > > ```c > #ifdef __NVPTX__ > uint32_t nvptx_get_thread_id_x() { return __nvvm_ptx_read_sreg_tid_x(); } > #define IMPL nvptx > #endif > uint32_t gpu_get_thread_id_x() { return ##IMPL##_get_thread_id_x(); } > #undef IMPL > ```
You could put all the common prototypes in the common include, e.g. ``` inline uint32_t gpu_get_thread_id_x() { return __impl_gpu_get_thread_id_x(); } ``` Then each arch-specific header would define the "impl" versions: ``` inline uint32_t __impl_gpu_get_thread_id_x() { return __nvvm_ptx_read_sreg_tid_x(); } ``` This way the common intrinsics would be defined in a single location, and it would be harder for someone to add a new intrinsic without realizing that all files should implement a common interface. https://github.com/llvm/llvm-project/pull/110179 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits