Replace calls to __oclc_option_mask in a kernel.
If there is call to __oclc_option_mask in a function,
add option mask as argument and pass it through all calls to this function.
Paths
| Differential D22751
AMDGPU Device Libs pass. AbandonedPublic Authored by nhaustov on Jul 25 2016, 5:45 AM.
Details
Summary Replace calls to __oclc_option_mask in a kernel. If there is call to __oclc_option_mask in a function,
Diff Detail Event Timelinenhaustov updated this object.
Comment Actions Should this really be in the backend? I also thought we were going to use a global constant variable instead of a function call Comment Actions
Yes, it needs to be. Global variable approach doesn't support functions in different modes. Comment Actions
The idea was that would be controlled by multiple globals with private visibility in different modules linked together. Comment Actions
Multiple variables would not work with function calls (see example with call in the review). Yes, it will be run before backend passes (in pre-link phase). It's common for all languages though. Comment Actions Can we have a test like this: int f() { if (__oclc_option_mask() & X) return 1 else if (__oclc_option_mask() & Y) return 2; } then call it in different kernels.
Comment Actions I am thinking probably this should be a post-linking pass. The library functions can be identified by prefixes or name mangling. All OpenCL builtin functions start with _Z ( IA64 mangled ) and other library functions have specific prefixes. We add an extra option argument to all library functions. If a library function calls other library functions, pass this option argument down. Non-library functions are compiled with cl- options which become function attributes. We just need to translate them to option mask and pass it to the OpenCL buitin functions called by this non-library function. After this transformation, all library function calls will have an option argument equivalent to the cl- options they are compiled with in the original compilation unit. Comment Actions Due to difficulties, it was decided to pursue different approach - create control functions in Runtime and link them as bitcode libraries.
Revision Contents
Diff 65731 lib/Target/AMDGPU/AMDGPU.h
lib/Target/AMDGPU/AMDGPUDeviceLibs.h
lib/Target/AMDGPU/AMDGPUDeviceLibsPass.cpp
lib/Target/AMDGPU/AMDGPUTargetMachine.h
lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
lib/Target/AMDGPU/CMakeLists.txt
test/CodeGen/AMDGPU/device-libs.ll
|
Header comment is missing.