Hide shim function linkables behind typing/lowering pass, removes c_ext_shim_func variable#102
Hide shim function linkables behind typing/lowering pass, removes c_ext_shim_func variable#102isVoid wants to merge 7 commits intoNVIDIA:mainfrom
c_ext_shim_func variable#102Conversation
|
The reason why this error happens is that the link argument is only picked up if the declared device function is used in a proper type inference pass. However in Numbast, the link to external function is used directly in lowering via |
declare_device(link) to add shim functionsc_ext_shim_func variable
|
Progress: Current state of the PR attempts to add the linkable object at lowering time to an additional attribute Some of this relates to what's visible at lowering time. It seems like some metadata can be rolled over in compilation pipeline and yields in the final *Technically, the |
|
So far I quite prefer adding linkable code at lowering time since it keeps the shim function local. It has much less code change than the |
|
Superceded by #106 |
- The linkable code object that contains the shim functions are added to `active_linking_library` in python. - Streamed Shim Function Writes. The shim functions are written to a string stream at lowering time using a special class named `KeyedStringIO` that prevents double write of the same shim function. - Ruff formatting generated code (with import sort): #108 - Generation metadata added to binding: #116 - Allow user to specify entry point and retain file list in config file using relative path d1e7aa2 - Allow user to add additional imports via `Additional Import` config item 8f7bd22 - Allow user to override the include line in shim function via `Shim Include Override` config item 8f7bd22 - Allow user to specify whether to include check in the binding to assert existence of pynvjitlink [bad0c69](bad0c69) - Allow user to specify a custom macro, which dictates both how clangTooling parses the header file, as well as how the shim function is compiled with NVRTC. [0f0ee9c](0f0ee9c) [ORIGINAL] This PR supercedes #102, which hand picked the parts where only lowering modifications are involved. In essence, this PR uses a new attribute in Numba-cuda target context named `_external_linkage`. By inserting the correct external linkables in the context, this PR hides the shim function usage to user, therefore eliminating the need for `c_ext_shim_func` variable. Additionally, since each shim function is isolated into the sub scope inside each function lowering, the monolithic shim function block no longer exists. This should presumably speedup compilation due to reduced IO burden on the size of the shim function being parsed by the RTC. ~~depends on NVIDIA/numba-cuda#165 Jointly in work with NVIDIA/numba-cuda#166 Includes changes from #116, #108 --------- Co-authored-by: isVoid <isVoid@users.noreply.github.com> Co-authored-by: Yevhenii Havrylko <yhavrylko@nvidia.com>
Numba_cuda introduced a new way to auto link external functions to declared functions in Numba. Numbast leverages this new mechanism to auto link shim functions, hiding away its linkage from user API.
Currently failing with linker error:
undefined reference to add_1 in <unnamed-ptx>