Add omp_get_device_num() function for 5.0 which returns the number of the device the current thread is running on. Also, did some cleanup and updating of device API functions to make them into weak functions that should be replaced with libomptarget functions when libomptarget is present.
AndreyChurbanov hbae RaviNarayanaswamy jlpeyton
- rL347799: [OpenMP] Add omp_get_device_num() and update several other device API functions
rOMP347799: [OpenMP] Add omp_get_device_num() and update several other device API functions
rGa17318b89b97: [OpenMP] Add omp_get_device_num() and update several other device API functions
This commit conflicts with libomptarget. libomptarget have the same functions and the code may be confused during execution which version of the functions should be executed. This conflict should be resolved somehow. Before that, I think, this patch must be reverted.
Can you enable LIBOMPTARGET_DEBUG and see if this is printed from libomptarget to confirm libomptarget is loaded and its api is used
DP("Call to omp_get_num_devices returning %zd\n", Devices_size);
I was wrong -- here are the weak symbols that are showing up in libomp:
nm runtime/exports/lin_32e.50.ompt.optional/lib/libomp.so | grep " W "
00000000000a4540 W omp_get_device_num
00000000000a5dd0 W omp_get_device_num_
00000000000a3f20 W omp_get_initial_device
00000000000a57c0 W omp_get_initial_device_
00000000000a3ee0 W omp_get_num_devices@@VERSION
00000000000a5780 W omp_get_num_devices_@@VERSION
00000000000a3f10 W omp_is_initial_device@@VERSION
00000000000a57b0 W omp_is_initial_device_@@VERSION
00000000000a7d20 W ompt_start_tool
So, it looks like weak symbols work better with static libraries. For dynamic, try linking libomptarget first.