This is an archive of the discontinued LLVM Phabricator instance.

Add omp_get_device_num() and update several other device API functions (FIXED)
ClosedPublic

Authored by tlwilmar on Dec 11 2018, 2:13 PM.

Details

Summary

Add omp_get_device_num() function for 5.0 which returns the number of the device the current thread is running on. Currently, we are leaving it to the compiler to handle this properly if it is called inside target.

Also, did some cleanup and updating of duplicate device API functions (in both libomp andlibomptarget) to make them into weak functions that check for the symbol from libomptarget, and will call the version in libomptarget if it is present. If any additional device API functions are implemented also in libomptarget in the future, we should add the dlsym calls to the host functions. Also, if the omp_target_* functions are to be implemented for the host (this has been requested), they should attempt to call the libomptarget versions as well.

Diff Detail

Repository
rOMP OpenMP

Event Timeline

tlwilmar created this revision.Dec 11 2018, 2:13 PM

Since you're using it twice already, is it worth abstracting the "find the appropriate function using dlsym" logic into a function?
I imagine that there will be other user-interface functions which will also need this, so abstracting it sooner rather than later seems a good thing to do.

Since you're using it twice already, is it worth abstracting the "find the appropriate function using dlsym" logic into a function?
I imagine that there will be other user-interface functions which will also need this, so abstracting it sooner rather than later seems a good thing to do.

We are doing implementations of the omp_target_* functions in the host runtime. We can abstract it to a function or macro then.

tlwilmar updated this revision to Diff 178786.Dec 18 2018, 2:24 PM

Tests added.

Is the intention to have this ready for the 8.0 release?

Is the intention to have this ready for the 8.0 release?

I have no particular intention to target it for a release, but if someone could please review it, that'd be great.
Thanks!

jlpeyton accepted this revision.Jan 3 2019, 1:14 PM

LGTM

This revision is now accepted and ready to land.Jan 3 2019, 1:14 PM
This revision was automatically updated to reflect the committed changes.