Skip to content

Commit

Permalink
Merge pull request #984 from valassi/gpucpp
Browse files Browse the repository at this point in the history
Improvements to complete PRs 979 and 980
  • Loading branch information
valassi committed Sep 1, 2024
2 parents dedbb15 + 4776d29 commit c153482
Show file tree
Hide file tree
Showing 74 changed files with 586 additions and 778 deletions.
2 changes: 1 addition & 1 deletion MG5aMC/mg5amcnlo
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def reset_simd(self, old_value, new_value, name):
# code can handle the new size -> do not recompile
return
Sourcedir = pjoin(os.path.dirname(os.path.dirname(self.path)), 'Source')
subprocess.call(['make', 'cleanavx'], cwd=Sourcedir, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
subprocess.call(['make', 'cleanall'], cwd=Sourcedir, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)

def reset_makeopts(self, old_value, new_value, name):
if not hasattr(self, 'path'):
Expand All @@ -78,7 +78,7 @@ def reset_makeopts(self, old_value, new_value, name):
else:
raise Exception
Sourcedir = pjoin(os.path.dirname(os.path.dirname(self.path)), 'Source')
subprocess.call(['make', 'cleanavx'], cwd=Sourcedir, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
subprocess.call(['make', 'cleanall'], cwd=Sourcedir, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)

def plugin_input(self, finput):
return
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

cleanavx:
for i in `ls -d ../SubProcesses/P*`; do cd $$i; make cleanavxs; cd -; done;
cleanall: clean # THIS IS THE ONE
cleanavxs: # Clean builds: fortran in all P*; cudacpp for all AVX in all P* and in src
for i in `ls -d ../SubProcesses/P*`; do cd $$i; make cleanavxs; cd -; done;

cleanall: cleanSource cleanavxs # Clean builds: fortran in this Source and in all P*; cudacpp for all AVX in all P* and in src
10 changes: 3 additions & 7 deletions epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,22 +191,18 @@ def copy_template(self, model):
makefile_test = self.read_template_file(self.template_tst_make) % {'model': self.get_model_name(model.get('name'))}
open(os.path.join('test', 'cudacpp_test.mk'), 'w').write(makefile_test)

# OM - overload export_v4.py version to add additional_clean section (and avoid patchMad.sh for Source/makefile)
def write_source_makefile(self, writer, default=None):

if default:
replace_dict = default
else:
raise Exception('primary exporter should have been run first')

path = pjoin(PLUGINDIR , 'madgraph', 'iolibs', 'template_files', 'madevent_makefile_source_addon')
replace_dict['additional_dependencies'] += open(path).read()

path = pjoin(PLUGINDIR , 'madgraph', 'iolibs', 'template_files', 'madevent_makefile_source_addon')
replace_dict['additional_clean'] += open(path).read()
if writer:
path = pjoin(MG5DIR, 'madgraph', 'iolibs','template_files','madevent_makefile_source')
text = open(path).read() % replace_dict
writer.write(text)



# AV - add debug printouts (in addition to the default one from OM's tutorial)
def generate_subprocess_directory(self, subproc_group, fortran_model, me=None):
Expand Down
36 changes: 16 additions & 20 deletions epochX/cudacpp/ee_mumu.mad/CODEGEN_mad_ee_mumu_log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ generate e+ e- > mu+ mu-
No model currently active, so we import the Standard Model
INFO: load particles
INFO: load vertices
DEBUG: model prefixing takes 0.005307912826538086 
DEBUG: model prefixing takes 0.00567936897277832 
INFO: Restrict model sm with file models/sm/restrict_default.dat .
DEBUG: Simplifying conditional expressions 
DEBUG: remove interactions: u s w+ at order: QED=1 
Expand Down Expand Up @@ -154,7 +154,7 @@ INFO: Checking for minimal orders which gives processes.
INFO: Please specify coupling orders to bypass this step.
INFO: Trying process: e+ e- > mu+ mu- WEIGHTED<=4 @1
INFO: Process has 2 diagrams
1 processes with 2 diagrams generated in 0.004 s
1 processes with 2 diagrams generated in 0.005 s
Total: 1 processes with 2 diagrams
output madevent_simd ../TMPOUT/CODEGEN_mad_ee_mumu --hel_recycling=False --vector_size=32
Load PLUGIN.CUDACPP_OUTPUT
Expand All @@ -177,7 +177,6 @@ INFO: Generating Helas calls for process: e+ e- > mu+ mu- WEIGHTED<=4 @1
INFO: Processing color information for process: e+ e- > mu+ mu- @1
INFO: Creating files in directory P1_epem_mupmum
DEBUG: kwargs[prefix] = 0 [model_handling.py at line 1152] 
DEBUG: process_exporter_cpp =  <PLUGIN.CUDACPP_OUTPUT.model_handling.PLUGIN_OneProcessExporter object at 0x7f09ed66e490> [export_v4.py at line 6261] 
INFO: Creating files in directory .
FileWriter <class 'PLUGIN.CUDACPP_OUTPUT.model_handling.PLUGIN_CPPWriter'> for ././CPPProcess.h
FileWriter <class 'PLUGIN.CUDACPP_OUTPUT.model_handling.PLUGIN_CPPWriter'> for ././CPPProcess.cc
Expand All @@ -186,30 +185,30 @@ INFO: Created files CPPProcess.h and CPPProcess.cc in directory ./.
DEBUG: config_map =  [1, 2] [export_cpp.py at line 711] 
DEBUG: subproc_number =  0 [export_cpp.py at line 712] 
DEBUG: Done [export_cpp.py at line 713] 
DEBUG: vector, subproc_group,self.opt['vector_size'] =  False True 32 [export_v4.py at line 1871] 
DEBUG: vector, subproc_group,self.opt['vector_size'] =  False True 32 [export_v4.py at line 1871] 
DEBUG: vector, subproc_group,self.opt['vector_size'] =  32 True 32 [export_v4.py at line 1871] 
DEBUG: vector, subproc_group,self.opt['vector_size'] =  False True 32 [export_v4.py at line 1877] 
DEBUG: vector, subproc_group,self.opt['vector_size'] =  False True 32 [export_v4.py at line 1877] 
DEBUG: vector, subproc_group,self.opt['vector_size'] =  32 True 32 [export_v4.py at line 1877] 
WARNING: vector code for lepton pdf not implemented. We removed the option to run dressed lepton 
DEBUG: vector, subproc_group,self.opt['vector_size'] =  32 True 32 [export_v4.py at line 1871] 
DEBUG: vector, subproc_group,self.opt['vector_size'] =  32 True 32 [export_v4.py at line 1877] 
INFO: Generating Feynman diagrams for Process: e+ e- > mu+ mu- WEIGHTED<=4 @1
INFO: Finding symmetric diagrams for subprocess group epem_mupmum
DEBUG: os.getcwd() =  /data/avalassi/GPU2023/madgraph4gpuX/MG5aMC/TMPOUT/CODEGEN_mad_ee_mumu/SubProcesses/P1_epem_mupmum [export_v4.py at line 6438] 
DEBUG: os.getcwd() =  /data/avalassi/GPU2023/madgraph4gpuX/MG5aMC/TMPOUT/CODEGEN_mad_ee_mumu/SubProcesses/P1_epem_mupmum [export_v4.py at line 6444] 
DEBUG: len(subproc_diagrams_for_config) =  2 [model_handling.py at line 1520] 
DEBUG: iconfig_to_diag =  {1: 1, 2: 2} [model_handling.py at line 1544] 
DEBUG: diag_to_iconfig =  {1: 1, 2: 2} [model_handling.py at line 1545] 
Generated helas calls for 1 subprocesses (2 diagrams) in 0.004 s
Wrote files for 8 helas calls in 0.112 s
Wrote files for 8 helas calls in 0.107 s
ALOHA: aloha starts to compute helicity amplitudes
ALOHA: aloha creates FFV1 routines
ALOHA: aloha creates FFV2 routines
ALOHA: aloha creates FFV4 routines
ALOHA: aloha creates 3 routines in 0.198 s
ALOHA: aloha creates 3 routines in 0.202 s
ALOHA: aloha starts to compute helicity amplitudes
ALOHA: aloha creates FFV1 routines
ALOHA: aloha creates FFV2 routines
ALOHA: aloha creates FFV4 routines
ALOHA: aloha creates FFV2_4 routines
ALOHA: aloha creates 7 routines in 0.253 s
ALOHA: aloha creates 7 routines in 0.258 s
<class 'aloha.create_aloha.AbstractRoutine'> FFV1
<class 'aloha.create_aloha.AbstractRoutine'> FFV1
<class 'aloha.create_aloha.AbstractRoutine'> FFV2
Expand All @@ -235,27 +234,24 @@ INFO: Generate jpeg diagrams
INFO: Generate web pages
DEBUG: cd /data/avalassi/GPU2023/madgraph4gpuX/MG5aMC/TMPOUT/CODEGEN_mad_ee_mumu; patch -p4 -i /data/avalassi/GPU2023/madgraph4gpuX/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/MG5aMC_patches/PROD/patch.common
patching file Source/genps.inc
patching file Source/makefile
patching file SubProcesses/makefile
DEBUG: cd /data/avalassi/GPU2023/madgraph4gpuX/MG5aMC/TMPOUT/CODEGEN_mad_ee_mumu/SubProcesses/P1_epem_mupmum; patch -p6 -i /data/avalassi/GPU2023/madgraph4gpuX/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/MG5aMC_patches/PROD/patch.P1
patching file auto_dsig1.f
Hunk #1 succeeded at 496 (offset 12 lines).
patching file driver.f
patching file matrix1.f
Hunk #3 succeeded at 230 (offset 9 lines).
Hunk #4 succeeded at 267 (offset 18 lines).
Hunk #5 succeeded at 312 (offset 18 lines).
DEBUG: p.returncode =  0 [output.py at line 242] 
Hunk #2 succeeded at 229 (offset 9 lines).
DEBUG: p.returncode =  0 [output.py at line 255] 
Output to directory /data/avalassi/GPU2023/madgraph4gpuX/MG5aMC/TMPOUT/CODEGEN_mad_ee_mumu done.
Type "launch" to generate events from this process, or see
/data/avalassi/GPU2023/madgraph4gpuX/MG5aMC/TMPOUT/CODEGEN_mad_ee_mumu/README
Run "open index.html" to see more information about this process.
quit

real 0m2.067s
user 0m1.807s
sys 0m0.251s
Code generation completed in 2 seconds
real 0m2.783s
user 0m1.820s
sys 0m0.261s
Code generation completed in 3 seconds
************************************************************
* *
* W E L C O M E to *
Expand Down
5 changes: 3 additions & 2 deletions epochX/cudacpp/ee_mumu.mad/Source/MODEL/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ $(LIBDIR)$(LIBRARY): $(MODEL)
clean:
$(RM) *.o $(LIBDIR)$(LIBRARY)

couplings.f: ../maxparticles.inc ../run.inc
couplings.o: ../maxparticles.inc ../run.inc ../vector.inc
couplings2.o: ../vector.inc

../run.inc:
touch ../run.inc

../maxparticles.inc:
touch ../maxparticles.inc
touch ../maxparticles.inc
19 changes: 9 additions & 10 deletions epochX/cudacpp/ee_mumu.mad/Source/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ $(LIBDIR)libcernlib.$(libext): CERNLIB
$(LIBDIR)libbias.$(libext): BIAS/dummy
cd BIAS/dummy; make; cd ../../

$(LIBDIR)libmodel.$(libext): MODEL param_card.inc
$(LIBDIR)libmodel.$(libext): MODEL param_card.inc vector.inc
cd MODEL; make
param_card.inc: ../Cards/param_card.dat
../bin/madevent treatcards param
Expand All @@ -72,15 +72,14 @@ $(BINDIR)gensudgrid: $(GENSUDGRID) $(LIBDIR)libpdf.$(libext) $(LIBDIR)libgammaUP

# Dependencies

dsample.o: DiscreteSampler.o dsample.f genps.inc StringCast.o
dsample.o: DiscreteSampler.o dsample.f genps.inc StringCast.o vector.inc
DiscreteSampler.o: StringCast.o
invarients.o: invarients.f genps.inc
setrun.o: setrun.f nexternal.inc leshouche.inc genps.inc
gen_ximprove.o: gen_ximprove.f run_config.inc run_card.inc
gen_ximprove.o: gen_ximprove.f run_config.inc run_card.inc
#combine_events.o: combine_events.f run_config.inc run_card.inc
combine_runs.o: combine_runs.f run_config.inc run_card.inc
select_events.o: select_events.f run_config.inc
setrun.o: setrun.f nexternal.inc leshouche.inc run_card.inc run_config.inc
setrun.o: setrun.f nexternal.inc leshouche.inc run_card.inc run_config.inc genps.inc vector.inc
rw_events.o: rw_events.f run_config.inc

run_card.inc: ../Cards/run_card.dat
Expand Down Expand Up @@ -120,7 +119,7 @@ $(LIBDIR)libiregi.a: $(IREGIDIR)
cd $(IREGIDIR); make
ln -sf ../Source/$(IREGIDIR)libiregi.a $(LIBDIR)libiregi.a

cleanSource:
cleanSource: # Clean builds: fortran in this Source
$(RM) *.o $(LIBRARIES) $(BINARIES)
cd PDF; make clean; cd ..
cd PDF/gammaUPC; make clean; cd ../../
Expand All @@ -133,10 +132,10 @@ cleanSource:
if [ -d $(CUTTOOLSDIR) ]; then cd $(CUTTOOLSDIR); make clean; cd ..; fi
if [ -d $(IREGIDIR) ]; then cd $(IREGIDIR); make clean; cd ..; fi

clean: cleanSource
clean: cleanSource # Clean builds: fortran in this Source and in all P*
for i in `ls -d ../SubProcesses/P*`; do cd $$i; make clean; cd -; done;

cleanavx:
for i in `ls -d ../SubProcesses/P*`; do cd $$i; make cleanavxs; cd -; done;
cleanall: cleanSource # THIS IS THE ONE
cleanavxs: # Clean builds: fortran in all P*; cudacpp for all AVX in all P* and in src
for i in `ls -d ../SubProcesses/P*`; do cd $$i; make cleanavxs; cd -; done;

cleanall: cleanSource cleanavxs # Clean builds: fortran in this Source and in all P*; cudacpp for all AVX in all P* and in src
5 changes: 0 additions & 5 deletions epochX/cudacpp/ee_mumu.mad/bin/internal/banner.py
Original file line number Diff line number Diff line change
Expand Up @@ -3157,7 +3157,6 @@ def get_value_from_include(self, path, list_of_params, output_dir):
if path does not exists return the current value in self for all parameter"""

#WARNING DOES NOT HANDLE LIST/DICT so far

# handle case where file is missing
if not os.path.exists(pjoin(output_dir,path)):
misc.sprint("include file not existing", pjoin(output_dir,path))
Expand All @@ -3166,13 +3165,9 @@ def get_value_from_include(self, path, list_of_params, output_dir):
with open(pjoin(output_dir,path), 'r') as fsock:
text = fsock.read()

for name in list_of_params:
misc.sprint(name, name in self.fortran_name)
misc.sprint(self.fortran_name[name] if name in self.fortran_name[name] else name)
to_track = [self.fortran_name[name] if name in self.fortran_name else name for name in list_of_params]
pattern = re.compile(r"\(?(%(names)s)\s?=\s?([^)]*)\)?" % {'names':'|'.join(to_track)}, re.I)
out = dict(pattern.findall(text))
misc.sprint(out)
for name in list_of_params:
if name in self.fortran_name:
value = out[self.fortran_name[name]]
Expand Down
4 changes: 2 additions & 2 deletions epochX/cudacpp/ee_mumu.mad/bin/internal/launch_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def reset_simd(self, old_value, new_value, name):
# code can handle the new size -> do not recompile
return
Sourcedir = pjoin(os.path.dirname(os.path.dirname(self.path)), 'Source')
subprocess.call(['make', 'cleanavx'], cwd=Sourcedir, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
subprocess.call(['make', 'cleanall'], cwd=Sourcedir, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)

def reset_makeopts(self, old_value, new_value, name):
if not hasattr(self, 'path'):
Expand All @@ -78,7 +78,7 @@ def reset_makeopts(self, old_value, new_value, name):
else:
raise Exception
Sourcedir = pjoin(os.path.dirname(os.path.dirname(self.path)), 'Source')
subprocess.call(['make', 'cleanavx'], cwd=Sourcedir, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
subprocess.call(['make', 'cleanall'], cwd=Sourcedir, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)

def plugin_input(self, finput):
return
Expand Down
Loading

0 comments on commit c153482

Please sign in to comment.