Getting the current device using cuda.core is quite a bit slower than CuPy:
In [1]: importcupyascpIn [2]: %timeitcp.cuda.Device()
69ns ± 0.496nsperloop (mean ± std. dev. of7runs, 10,000,000loopseach)
In [3]: fromcuda.core.experimentalimportDeviceIn [4]: %timeitDevice()
795ns ± 0.273nsperloop (mean ± std. dev. of7runs, 1,000,000loopseach)
Ultimately, my goal is to get the compute capability of the current device, and this is even slower:
In [5]: %timeitcp.cuda.Device().compute_capability89.1ns ± 0.413nsperloop (mean ± std. dev. of7runs, 10,000,000loopseach)
In [6]: %timeitDevice().compute_capability2.64μs ± 122nsperloop (mean ± std. dev. of7runs, 100,000loopseach)
Are there tricks (e.g., caching) CuPy is employing here that cuda.core can use as well? Alternately, is there another way for me to use cuda.core or cuda.bindings to get this information quickly? Note that for my use case, I'm not super concerned about the first call to Device(), but I do want subsequent calls to be trivially inexpensive if the current device hasn't changed.
Using the low-level cuda.bindings is also not quite as fast:
In [11]: defget_cc():
...: dev=runtime.cudaGetDevice()[1]
...: returndriver.cuDeviceComputeCapability(dev)
...:
In [12]: get_cc()
Out[12]: (<CUresult.CUDA_SUCCESS: 0>, 7, 5)
In [13]: %timeitget_cc()
597ns ± 0.494nsperloop (mean ± std. dev. of7runs, 1,000,000loopseach)
Getting the current device using
cuda.coreis quite a bit slower than CuPy:Ultimately, my goal is to get the compute capability of the current device, and this is even slower:
Are there tricks (e.g., caching) CuPy is employing here that
cuda.corecan use as well? Alternately, is there another way for me to usecuda.coreorcuda.bindingsto get this information quickly? Note that for my use case, I'm not super concerned about the first call toDevice(), but I do want subsequent calls to be trivially inexpensive if the current device hasn't changed.Using the low-level cuda.bindings is also not quite as fast: