This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][CUDA] Avoid calling `cuCtxSetCurrent` redundantly
ClosedPublic

Authored by tianshilei1992 on Mar 9 2022, 11:49 AM.

Details

Summary

Currently we set ccontext everywhere accordingly, but that causes many
unnecessary function calls. For example, in the resource pool, if we need to
resize the pool, we need to get from allocator. Each call to allocate sets the
current context once, which is unnecessary. In this patch, we set the context
only in the entry interface functions, if needed. Actually in the best way this
should be implemented via RAII, but since cuCtxSetCurrent could return error,
and we don't use exception, we can't stop the execution if RAII fails.

Diff Detail

Event Timeline

tianshilei1992 created this revision.Mar 9 2022, 11:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 9 2022, 11:49 AM
tianshilei1992 requested review of this revision.Mar 9 2022, 11:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 9 2022, 11:49 AM
jdoerfert accepted this revision.Mar 9 2022, 12:02 PM

Nice, see my comment. LG

openmp/libomptarget/plugins/cuda/src/rtl.cpp
1725

If we don't need setContext for an entry point, add a comment stating that please.

This revision is now accepted and ready to land.Mar 9 2022, 12:02 PM
tianshilei1992 marked an inline comment as done.

fix comments

This revision was landed with ongoing or failed builds.Mar 9 2022, 1:32 PM
This revision was automatically updated to reflect the committed changes.