https://gcc.gnu.org/g:b062c86fe0e51bd859496ced40de2f7376c8bca3
commit r17-6523-gb062c86fe0e51bd859496ced40de2f7376c8bca3 Author: Thomas Schwinge <[email protected]> Date: Fri Mar 13 21:06:59 2026 +0100 libgomp NVIDIA GPU plugin: Fix CUDA 13 '-DPLUGIN_NVPTX_INCLUDE_SYSTEM_CUDA_H' build In CUDA 13, the 'cuCtxCreate' API (internally switched to 'cuCtxCreate_v4', and) changed from: CUresult cuCtxCreate (CUcontext *, unsigned int, CUdevice); ... to: CUresult cuCtxCreate (CUcontext *, CUctxCreateParams *, unsigned int, CUdevice); ..., causing: ../../../source-gcc/libgomp/plugin/plugin-nvptx.c: In function ‘nvptx_open_device’: [...]/include/cuda.h:90:45: error: too few arguments to function ‘cuCtxCreate_v4’; expected 4, have 3 90 | #define cuCtxCreate cuCtxCreate_v4 | ^~~~~~~~~~~~~~ ../../../source-gcc/libgomp/plugin/plugin-nvptx.c:168:26: note: in definition of macro ‘CUDA_CALL_ERET’ 168 | = CUDA_CALL_PREFIX FN (__VA_ARGS__); \ | ^~ ../../../source-gcc/libgomp/plugin/plugin-nvptx.c:477:27: note: in expansion of macro ‘cuCtxCreate’ 477 | CUDA_CALL_ERET (NULL, cuCtxCreate, &ptx_dev->ctx, CU_CTX_SCHED_AUTO, dev); | ^~~~~~~~~~~ [...] libgomp/ * plugin/plugin-nvptx.c: Handle CUDA 13 'cuCtxCreate': 'cuCtxCreate_v4'. Diff: --- libgomp/plugin/plugin-nvptx.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c index f3755d46feed..9a46ceff985f 100644 --- a/libgomp/plugin/plugin-nvptx.c +++ b/libgomp/plugin/plugin-nvptx.c @@ -483,7 +483,13 @@ nvptx_open_device (int n) CUDA_CALL_ERET (NULL, cuCtxGetCurrent, &ptx_dev->ctx); if (!ptx_dev->ctx) - CUDA_CALL_ERET (NULL, cuCtxCreate, &ptx_dev->ctx, CU_CTX_SCHED_AUTO, dev); + { +#if CUDA_VERSION >= 13000 + CUDA_CALL_ERET (NULL, cuCtxCreate, &ptx_dev->ctx, NULL, CU_CTX_SCHED_AUTO, dev); +#else + CUDA_CALL_ERET (NULL, cuCtxCreate, &ptx_dev->ctx, CU_CTX_SCHED_AUTO, dev); +#endif + } else ptx_dev->ctx_shared = true; @@ -2707,8 +2713,13 @@ GOMP_OFFLOAD_openacc_get_property (int n, enum goacc_property prop) { CUcontext new_ctx; +#if CUDA_VERSION >= 13000 + CUDA_CALL_ERET (propval, cuCtxCreate, &new_ctx, NULL, CU_CTX_SCHED_AUTO, + ptx_dev->dev); +#else CUDA_CALL_ERET (propval, cuCtxCreate, &new_ctx, CU_CTX_SCHED_AUTO, ptx_dev->dev); +#endif CUDA_CALL_ERET (propval, cuMemGetInfo, &free_mem, &total_mem); CUDA_CALL_ASSERT (cuCtxDestroy, new_ctx); }
