[all-commits] [llvm/llvm-project] 39d328: [OpenMP][CUDA] Avoid calling `cuCtxSetCurrent` red...

Shilei Tian via All-commits all-commits at lists.llvm.org
Wed Mar 9 13:33:04 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 39d3283a08ba0d687eba3f74ecb85d60b7c71355
      https://github.com/llvm/llvm-project/commit/39d3283a08ba0d687eba3f74ecb85d60b7c71355
  Author: Shilei Tian <i at tianshilei.me>
  Date:   2022-03-09 (Wed, 09 Mar 2022)

  Changed paths:
    M openmp/libomptarget/plugins/cuda/src/rtl.cpp

  Log Message:
  -----------
  [OpenMP][CUDA] Avoid calling `cuCtxSetCurrent` redundantly

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.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D121322




More information about the All-commits mailing list