Skip to content

Commit

Permalink
enable LTO nvrtc function only for 11.*
Browse files Browse the repository at this point in the history
  • Loading branch information
isVoid committed Oct 24, 2024
1 parent 9ea2fd4 commit 27b304d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions numba_cuda/numba/cuda/cudadrv/nvrtc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from numba.core import config
from numba.cuda.cudadrv.error import (NvrtcError, NvrtcCompilationError,
NvrtcSupportError)
from cuda.cuda.cudadrv.driver import get_version

import functools
import os
Expand Down Expand Up @@ -62,6 +63,14 @@ class NVRTC:
NVVM interface. Initialization is protected by a lock and uses the standard
(for Numba) open_cudalib function to load the NVRTC library.
"""

_CU12ONLY_PROTOTYPES = {
# nvrtcResult nvrtcGetLTOIRSize(nvrtcProgram prog, size_t *ltoSizeRet);
"nvrtcGetLTOIRSize": (nvrtc_result, nvrtc_program, POINTER(c_size_t)),
# nvrtcResult nvrtcGetLTOIR(nvrtcProgram prog, char *lto);
"nvrtcGetLTOIR": (nvrtc_result, nvrtc_program, c_char_p)
}

_PROTOTYPES = {
# nvrtcResult nvrtcVersion(int *major, int *minor)
'nvrtcVersion': (nvrtc_result, POINTER(c_int), POINTER(c_int)),
Expand All @@ -84,10 +93,6 @@ class NVRTC:
'nvrtcGetPTXSize': (nvrtc_result, nvrtc_program, POINTER(c_size_t)),
# nvrtcResult nvrtcGetPTX(nvrtcProgram prog, char *ptx);
'nvrtcGetPTX': (nvrtc_result, nvrtc_program, c_char_p),
# nvrtcResult nvrtcGetLTOIRSize(nvrtcProgram prog, size_t *ltoSizeRet);
"nvrtcGetLTOIRSize": (nvrtc_result, nvrtc_program, POINTER(c_size_t)),
# nvrtcResult nvrtcGetLTOIR(nvrtcProgram prog, char *lto);
"nvrtcGetLTOIR": (nvrtc_result, nvrtc_program, c_char_p),
# nvrtcResult nvrtcGetCUBINSize(nvrtcProgram prog,
# size_t *cubinSizeRet);
'nvrtcGetCUBINSize': (nvrtc_result, nvrtc_program, POINTER(c_size_t)),
Expand All @@ -101,6 +106,9 @@ class NVRTC:
'nvrtcGetProgramLog': (nvrtc_result, nvrtc_program, c_char_p),
}

if get_version() >= (12, 0):
_PROTOTYPES |= _CU12ONLY_PROTOTYPES

# Singleton reference
__INSTANCE = None

Expand Down

0 comments on commit 27b304d

Please sign in to comment.