Skip to content

Commit

Permalink
[runcard] in ggtt.mad driver.f, remove the two extra input parameters…
Browse files Browse the repository at this point in the history
… fbridge_mode and vecsize_used and replace them by env variables (madgraph5#658, also related to madgraph5#690)

The two env variables are CUDACPP_RUNTIME_FBRIDGEMODE and CUDACPP_RUNTIME_VECSIZEUSED.
These are meant to be used only by expert developers, not for general users.
  • Loading branch information
valassi committed Jun 11, 2023
1 parent c65f1de commit 0ddb7a9
Showing 1 changed file with 35 additions and 12 deletions.
47 changes: 35 additions & 12 deletions epochX/cudacpp/gg_tt.mad/SubProcesses/P1_gg_ttx/driver.f
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ Program DRIVER
include 'vector.inc' ! defines VECSIZE_MEMMAX
include 'coupl.inc' ! needs VECSIZE_MEMMAX (defined in vector.inc)
INTEGER VECSIZE_USED
DATA VECSIZE_USED/VECSIZE_MEMMAX/ ! initial value

character*255 env_name, env_value
integer env_length, env_status

#ifdef MG5AMC_MEEXPORTER_CUDACPP
INCLUDE 'fbridge.inc'
Expand All @@ -93,22 +95,43 @@ Program DRIVER
#endif
CALL COUNTERS_INITIALISE()

c#ifdef MG5AMC_MEEXPORTER_CUDACPP
write(*,*) 'Enter fbridge_mode'
read(*,*) FBRIDGE_MODE ! (CppOnly=1, FortranOnly=0, BothQuiet=-1, BothDebug=-2)
write(*,'(a16,i6)') ' FBRIDGE_MODE = ', FBRIDGE_MODE
#ifdef MG5AMC_MEEXPORTER_CUDACPP
fbridge_mode = 1 ! CppOnly=1, default for CUDACPP
#else
fbridge_mode = 0 ! FortranOnly=0, default for FORTRAN
#endif
env_name = 'CUDACPP_RUNTIME_FBRIDGEMODE'
call get_environment_variable(env_name, env_value, env_length, env_status)
if( env_status.eq.0 ) then
write(*,*) 'Found environment variable "', trim(env_name), '" with value "', trim(env_value), '"'
read(env_value,'(I255)') FBRIDGE_MODE ! see https://gcc.gnu.org/onlinedocs/gfortran/ICHAR.html
write(*,*) 'FBRIDGE_MODE (from env) = ', FBRIDGE_MODE
else if( env_status.eq.1 ) then ! 1 = not defined
write(*,*) 'FBRIDGE_MODE (default) = ', FBRIDGE_MODE
else ! -1 = too long for env_value, 2 = not supported by O/S
write(*,*) 'ERROR! get_environment_variable failed for "', trim(env_name), '"'
STOP
endif
#ifndef MG5AMC_MEEXPORTER_CUDACPP
if( fbridge_mode.ne.0 ) then
write(*,*) 'ERROR! Invalid fbridge_mode = ', fbridge_mode
write(*,*) 'ERROR! Invalid fbridge_mode (in FORTRAN backend mode) = ', fbridge_mode
STOP
endif
#endif
write(*,*) 'Enter #events in a vector loop (max=',VECSIZE_MEMMAX,',)'
read(*,*) VECSIZE_USED
c#else
c VECSIZE_USED = 32
c#endif
write(*,'(a16,i6)') ' VECSIZE_USED = ', VECSIZE_USED

vecsize_used = vecsize_memmax ! default ! CppOnly=1, default for CUDACPP
env_name = 'CUDACPP_RUNTIME_VECSIZEUSED'
call get_environment_variable(env_name, env_value, env_length, env_status)
if( env_status.eq.0 ) then
write(*,*) 'Found environment variable "', trim(env_name), '" with value "', trim(env_value), '"'
read(env_value,'(I255)') VECSIZE_USED ! see https://gcc.gnu.org/onlinedocs/gfortran/ICHAR.html
write(*,*) 'VECSIZE_USED (from env) = ', VECSIZE_USED
else if( env_status.eq.1 ) then ! 1 = not defined
write(*,*) 'VECSIZE_USED (default) = ', VECSIZE_USED
else ! -1 = too long for env_value, 2 = not supported by O/S
write(*,*) 'ERROR! get_environment_variable failed for "', trim(env_name), '"'
STOP
endif
if( VECSIZE_USED.gt.VECSIZE_MEMMAX .or. VECSIZE_USED.le.0 ) then
write(*,*) 'ERROR! Invalid VECSIZE_USED = ', VECSIZE_USED
STOP
Expand Down

0 comments on commit 0ddb7a9

Please sign in to comment.