This patch enables omp_get_num_devices() and omp_get_initial_device() on
Windows by providing an alternative to dlsym on Windows, and proposes to
add a new libomptarget entry, __tgt_get_num_devices().
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
If I add GetProcAddress result conversion to (void *) I get linker error if built by clang or gcc. E.g. for clang:
C:\Progs\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\ld.exe: CMakeFiles\omp.dir/objects.a(z_Windows_NT_util.cpp.obj):z_Windows_NT_util.:(.text+0x1dfa): undefined reference to `EnumProcessModules'
C:\Progs\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\ld.exe: CMakeFiles\omp.dir/objects.a(z_Windows_NT_util.cpp.obj):z_Windows_NT_util.:(.text+0x1e26): undefined reference to `EnumProcessModules'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: * [runtime/src/libomp.dll] Error 1
make[1]: * [runtime/src/CMakeFiles/omp.dir/all] Error 2
make: *** [all] Error 2
That indicates missing -lpsapi on link line.
openmp/runtime/src/z_Windows_NT_util.cpp | ||
---|---|---|
1652 | clang complains on this line: C:\tmp\llvm\trunk\runtime\src\z_Windows_NT_util.cpp:1652:12: error: assigning to 'void *' from 'FARPROC' (aka 'long long (*)()') converts between void pointer and function pointer proc = GetProcAddress(modules[i], name); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I guess the result should be converted to (void *) before assignment. Similar complaint from gcc: C:/tmp/llvm/trunk/runtime/src/z_Windows_NT_util.cpp:1652:26: error: invalid conversion from 'FARPROC' {aka 'long long int (*)()'} to 'void*' [-fpermissive] | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ | | | FARPROC {aka long long int (*)()} |
Two comments, that are not directly related to this patch, but could be addressed while we are here.
openmp/runtime/src/kmp_ftn_entry.h | ||
---|---|---|
967–968 | Why is there no KMP_EXPAND_NAME macro applied to this function? | |
971–972 | Conceptually, we could really just call the omp_get_num_devices function from above. |
Why is there no KMP_EXPAND_NAME macro applied to this function?