The defintion of OFFLOAD_SUCCESS and OFFLOAD_FAIL used in plugin APIs and libomptarget public APIs are not consistent.
Create __tgt_target_return_t for libomptarget public APIs.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I think an enum is great. We should remove the old macros though. I'm also not sure to change the behavior for the return rc cases in this patch.
In my understanding of the return of __tgt_target_mapper __tgt_target_teams_mapper, when offload is disabled via environment variable, there are early returns to return OMP_TGT_FAIL. When actually offload to target device executes, handleTargetOutcome aborts if rc != OFFLOAD_SUCCESS, thus return value is always OMP_TGT_SUCCESS although return rc seems like being able to return OFFLOAD_FAIL.
OMP_TGT_FAIL is recoverable and the host fallback runs.
OFFLOAD_FAIL is generally unrecoverable and should be stopped by handleTargetOutcome.
openmp/libomptarget/src/interface.cpp | ||
---|---|---|
384–386 | What is this for? |
openmp/libomptarget/src/interface.cpp | ||
---|---|---|
384–386 | right now if rc != OFFLOAD_SUCCESS, handleTargetOutcome abort the execution. So once this assert line was reached, rc should be always OFFLOAD_SUCCESS and thus return OMP_TGT_SUCCESS is safe. If one day, the behavior of handleTargetOutcome changes, this assertion should catch unexpected inconsistency. |
I had another look at this. It seems the assertion is just fine, we would return SUCCESS anyway right after assert(), so we are now double-checking that SUCCESS is indeed the correct value to return.
openmp/libomptarget/src/interface.cpp | ||
---|---|---|
24–34 | This should be moved to include/omptarget.h - that's where we currently define OFFLOAD_SUCCESS and OFFLOAD_FAIL. OMP_TGT_SUCCESS and OMP_TGT_FAIL are the values which are checked to decided whether offloading has been successful or we should fallback to the host, so their definitions should reside in the header file that the outside world will include. Meanwhile, OFFLOAD_SUCCESS and OFFLOAD_FAIL are no longer used for inter-component communication, so we can move them to private.h or some new header file (do that as part of D109277). |
openmp/libomptarget/src/interface.cpp | ||
---|---|---|
24–34 | yes. I think after this patch OFFLOAD_SUCCESS/OFFLOAD_FAIL are only for libomptarget internal use, it will be shared between the plugin and libomptarget and thus needs to be on a separate header file instead of inside private.h. Will do the change as part of D109277 |
This should be moved to include/omptarget.h - that's where we currently define OFFLOAD_SUCCESS and OFFLOAD_FAIL. OMP_TGT_SUCCESS and OMP_TGT_FAIL are the values which are checked to decided whether offloading has been successful or we should fallback to the host, so their definitions should reside in the header file that the outside world will include. Meanwhile, OFFLOAD_SUCCESS and OFFLOAD_FAIL are no longer used for inter-component communication, so we can move them to private.h or some new header file (do that as part of D109277).