# common rcfile for the CUDA toolkit trampoline drivers

suffix other is default;
cinclude rcfiles/persnvirc;
include rcfiles/cudaselectrc;
cinclude rcfiles/persngirc;

variable VERBOSE is default(0);
variable INHIBIT_WARNINGS is default(0);
replace variable NOSWITCHERROR is default(1);
variable ADDARGS is default();
variable RMARGS is default();
# List pairs of flags. First item in the pair is the original flag, second item
# is the flag to use as replacement.  Items in the pairs are separated by
# comma, pairs are separated by semicolon.
# Some toolkit drivers do not understand the -V shorthand for the long form --version.
variable FLAGREPLACEMENTTABLE is default(-V,--version);
variable REPLACESWITCHES is default(0);
variable DETECTCUDA is default(1);

variable CUDA_DRIVER_VERSION is default($action(cudadriver()));
variable CUDA_DRIVER_VERSION_STR is default($remove($CUDA_DRIVER_VERSION,.));
variable CUDA_DRIVERS_SUPPORTED is default($if($expr($CUDA_DRIVER_VERSION_STR>110),11.0 or $CUDAVERSION,$CUDAVERSION));
variable CUDA_ERROR is default($if($SETVER,
	$if($equal($CUDAVERSION,),
	    CUDA version $REQCUDAVERSION was not installed with this HPC SDK,
	    CUDA version $CUDAVERSION was not installed with this HPC SDK: $CUDADIR),
	    $if($notequal($NVCOMPILER_CUDA_HOME_ENV,),NVCOMPILER_CUDA_HOME directory not found: $NVCOMPILER_CUDA_HOME_ENV,
	    $if($notequal($PGI_CUDA_HOME_ENV,),PGI_CUDA_HOME directory not found: $PGI_CUDA_HOME_ENV,
	    $if($notequal($NVHPC_CUDA_HOME_ENV,),NVHPC_CUDA_HOME directory not found: $NHVPC_CUDA_HOME_ENV,
	    $if($notequal($CUDAVERSION,),A CUDA toolkit matching the current driver version ($CUDA_DRIVER_VERSION) or a supported older version ($CUDA_DRIVERS_SUPPORTED) was not installed with this HPC SDK,
	        An appropriate CUDA Toolkit was not installed with this HPC SDK; ask your administrator to install with apt install nvidia-cuda-toolkit)))))
	);

switch -V$ is
	early
	optional(vsn)
	help(Change CUDA version)
	# if -V is used with no CUDA version, pass --version so the toolkit driver prints the version and exits.
	set(REPLACESWITCHES=1)
	# if -V is used with an argument, change the cuda version and erase
	append(RMARGS=$if($notequal($vsn,),-V$vsn))
	set(CUDAVERSION=$if($notequal($vsn,),$vsn,$DEFAULTCUDAVER))
	set(SETVER=$if($notequal($vsn,),1,0));

switch --version is
	early
	set(INHIBIT_WARNINGS=1);

switch -vv is
	early
	erase
	help(Display commands as executed)
	set(VERBOSE=1);

switch -w is
	early
	help(Inhibit warning messages)
	set(INHIBIT_WARNINGS=1);
