[Openmp-commits] [PATCH] D121322: [OpenMP][CUDA] Avoid calling `cuCtxSetCurrent` redundantly

Shilei Tian via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Mar 9 11:49:56 PST 2022


tianshilei1992 created this revision.
tianshilei1992 added reviewers: jdoerfert, jhuber6, JonChesterfield.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
tianshilei1992 requested review of this revision.
Herald added subscribers: openmp-commits, sstefan1.
Herald added a project: OpenMP.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121322

Files:
  openmp/libomptarget/plugins/cuda/src/rtl.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121322.414177.patch
Type: text/x-patch
Size: 12121 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220309/6b9e7745/attachment-0001.bin>


More information about the Openmp-commits mailing list