diff --git a/.github/workflows/madgraph_launch_test.yml b/.github/workflows/madgraph_launch_test.yml new file mode 100644 index 0000000000..39e0f89f43 --- /dev/null +++ b/.github/workflows/madgraph_launch_test.yml @@ -0,0 +1,112 @@ +# WARNING THIS FILE IS AUTOGENERATED -> edit test_simd_madevent.template + + +# This is a basic workflow to help you get started with Actions + +name: running acceptance test +# Controls when the workflow will run +# branches: [ main LTS ] +on: + # Triggers the workflow on push or pull request events but only for the 3.4.0 branch + push: + paths-ignore: + - 'docs/**' +# - '.github/**' + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + inputs: + message: + description: 'running acceptance test' + required: true + +env: + commitmsg: ${{ github.event.head_commit.message }} + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + + simd_cpp_heft_ggh_double: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + with: + submodules: 'true' + + # Runs a set of commands using the runners shell + - name: test one of the test testIO_AcceptanceProcOutputIOTests + run: | + cd $GITHUB_WORKSPACE + cd MG5aMC/mg5amcnlo/ + cp input/.mg5_configuration_default.txt input/mg5_configuration.txt + cp Template/LO/Source/.make_opts Template/LO/Source/make_opts + ./tests/test_manager.py -p./PLUGIN/CUDACPP_OUTPUT/acceptance_tests/ test_simd_cpp_heft_ggh_double + + simd_cpp_pptt_mixed: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + with: + submodules: 'true' + + # Runs a set of commands using the runners shell + - name: test one of the test testIO_AcceptanceProcOutputIOTests + run: | + cd $GITHUB_WORKSPACE + cd MG5aMC/mg5amcnlo/ + cp input/.mg5_configuration_default.txt input/mg5_configuration.txt + cp Template/LO/Source/.make_opts Template/LO/Source/make_opts + ./tests/test_manager.py -p./PLUGIN/CUDACPP_OUTPUT/acceptance_tests/ test_simd_cpp_pptt_mixed + + simd_cpp_eemumua_float: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + with: + submodules: 'true' + + # Runs a set of commands using the runners shell + - name: test one of the test testIO_AcceptanceProcOutputIOTests + run: | + cd $GITHUB_WORKSPACE + cd MG5aMC/mg5amcnlo/ + cp input/.mg5_configuration_default.txt input/mg5_configuration.txt + cp Template/LO/Source/.make_opts Template/LO/Source/make_opts + ./tests/test_manager.py -p./PLUGIN/CUDACPP_OUTPUT/acceptance_tests/ test_simd_cpp_eemumua_float + + simd_cpp_vector_size: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + with: + submodules: 'true' + + # Runs a set of commands using the runners shell + - name: test one of the test testIO_AcceptanceProcOutputIOTests + run: | + cd $GITHUB_WORKSPACE + cd MG5aMC/mg5amcnlo/ + cp input/.mg5_configuration_default.txt input/mg5_configuration.txt + cp Template/LO/Source/.make_opts Template/LO/Source/make_opts + ./tests/test_manager.py -p./PLUGIN/CUDACPP_OUTPUT/acceptance_tests/ test_simd_cpp_vector_size diff --git a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/create_acceptance_from_file.py b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/create_acceptance_from_file.py new file mode 100644 index 0000000000..93b02d64b2 --- /dev/null +++ b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/create_acceptance_from_file.py @@ -0,0 +1,128 @@ +#### +## Automatic creation of CI/CD for the plugin repo +## and automatic test in madgraph format style +## test can be added easily by adding a file in the directory +## simple_cross_check +## format of the file is the cmd file to pass to the code +## two type of additional metadata line are present +## #title provide the documentation information for the unittest (docstring) +## #check RUN_NAME CROSS ERROR NB_EVENT provide the target cross-section/error/requested event + + +import os +import glob + +curr_dir = os.path.dirname(__file__) +pjoin = os.path.join +template_runtest = """ +# WARNING THIS FILE IS AUTOGENERATED -> edit test_simd_madevent.template + def test_%(name)s(self): + \"\"\"%(doc)s\"\"\" + + if logging.getLogger('madgraph').level <= 20: + stdout=None + stderr=None + else: + devnull =open(os.devnull,'w') + stdout=devnull + stderr=devnull + + try: + shutil.rmtree('/tmp/MGPROCESS/') + except Exception as error: + pass + + cmd = \"\"\"%(cmd)s + \"\"\" %%self.run_dir + + open(pjoin(self.path, 'mg5_cmd'),'w').write(cmd) + + subprocess.call([sys.executable, pjoin(MG5DIR, 'bin','mg5_aMC'), + pjoin(self.path, 'mg5_cmd')], + #cwd=self.path, + stdout=stdout, stderr=stderr) +""" + +template_onecheck = """ + self.check_parton_output(cross=%(cross)s, error=%(err)s, run_name='%(run_name)s', html=%(html)s) + event = '%%s/Events/%(run_name)s/unweighted_events.lhe' %% self.run_dir + if not os.path.exists(event): + misc.gunzip(event) + + lhefile = lhe_parser.EventFile(event) + nb_event = 0 + for event in lhe_parser.EventFile(event): + event.check() + nb_event+=1 + + self.assertEqual(nb_event, %(nb_event)s)""" + + +def create_test_simd_madevent(): + + text = "# WARNING THIS FILE IS AUTOGENERATED -> edit test_simd_madevent.template\n\n\n" + text += open(pjoin(curr_dir, 'test_simd_madevent.template'),'r').read() + + for filename in os.listdir(pjoin(curr_dir, 'simple_cross_check')): + + opt = {} + opt['name'] = filename + opt['cmd'] = open(pjoin(curr_dir, 'simple_cross_check',filename)).read() + opt['doc'] = "\n".join([line[5:] for line in opt['cmd'].split('\n') if line.startswith('#title')]) + + text += template_runtest % opt + + checks = [line.split() for line in opt['cmd'].split('\n') if line.startswith('#check')] + + for i, check in enumerate(checks): + _, name, cross, err, nb_event = check + opt['run_name'] = name + opt['cross'] = cross + opt['err'] = err + opt['nb_event'] = nb_event + opt['html'] = 'True' if i==0 else 'False' + + text += template_onecheck % opt + + open(pjoin(curr_dir, 'test_simd_madevent.py'), 'w').write(text) + +template_one_cicd=""" + %(name)s: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + with: + submodules: 'true' + + # Runs a set of commands using the runners shell + - name: test one of the test testIO_AcceptanceProcOutputIOTests + run: | + cd $GITHUB_WORKSPACE + cd MG5aMC/mg5amcnlo/ + cp input/.mg5_configuration_default.txt input/mg5_configuration.txt + cp Template/LO/Source/.make_opts Template/LO/Source/make_opts + ./tests/test_manager.py -p./PLUGIN/CUDACPP_OUTPUT/acceptance_tests/ test_%(name)s +""" + +def create_cicd(): + + text = "# WARNING THIS FILE IS AUTOGENERATED -> edit test_simd_madevent.template\n\n\n" + text += open(pjoin(curr_dir, 'madgraph_launch.template'),'r').read() + + for filename in os.listdir(pjoin(curr_dir, 'simple_cross_check')): + text += template_one_cicd % {'name': filename} + + GITDIR =pjoin(os.path.realpath(curr_dir), os.path.pardir,os.path.pardir,os.path.pardir,os.path.pardir,os.path.pardir,os.path.pardir) + GITDIR = os.path.realpath(GITDIR) + open(pjoin(GITDIR, '.github', 'workflows', 'madgraph_launch_test.yml'), 'w').write(text) + + +if __name__ == '__main__': + create_test_simd_madevent() + create_cicd() + + diff --git a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/madgraph_launch.template b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/madgraph_launch.template new file mode 100644 index 0000000000..7a8a08aba9 --- /dev/null +++ b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/madgraph_launch.template @@ -0,0 +1,29 @@ +# This is a basic workflow to help you get started with Actions + +name: running acceptance test +# Controls when the workflow will run +# branches: [ main LTS ] +on: + # Triggers the workflow on push or pull request events but only for the 3.4.0 branch + push: + paths-ignore: + - 'docs/**' +# - '.github/**' + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + inputs: + message: + description: 'running acceptance test' + required: true + +env: + commitmsg: ${{ github.event.head_commit.message }} + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" diff --git a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/simple_cross_check/simd_cpp_eemumua_float b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/simple_cross_check/simd_cpp_eemumua_float new file mode 100644 index 0000000000..5b63dd1bff --- /dev/null +++ b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/simple_cross_check/simd_cpp_eemumua_float @@ -0,0 +1,10 @@ +#title check eemumua in single precision +import model sm + set automatic_html_opening False --no_save + set notification_center False --no_save + generate e+ e- > mu+ mu- a + output madevent_simd %s -f -nojpeg + launch + set nevents 100 + set floating_type f +#check run_01 0.0266 0.0002854 100 diff --git a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/simple_cross_check/simd_cpp_heft_ggh_double b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/simple_cross_check/simd_cpp_heft_ggh_double new file mode 100644 index 0000000000..21ea1875b0 --- /dev/null +++ b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/simple_cross_check/simd_cpp_heft_ggh_double @@ -0,0 +1,10 @@ +#title testing a HEFT process gg>aa in double precision +import model heft + set automatic_html_opening False --no_save + set notification_center False --no_save + generate g g > h > a a + output madevent_simd %s -f -nojpeg + launch + set nevents 100 + set floating_type d +#check run_01 0.01859 0.0002853789088650386 100 diff --git a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/simple_cross_check/simd_cpp_pptt_mixed b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/simple_cross_check/simd_cpp_pptt_mixed new file mode 100644 index 0000000000..8cd87df8f1 --- /dev/null +++ b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/simple_cross_check/simd_cpp_pptt_mixed @@ -0,0 +1,10 @@ +#title check ggtt within mixed mode +import model sm + set automatic_html_opening False --no_save + set notification_center False --no_save + generate p p > t t~ + output madevent_simd %s -f -nojpeg + launch + set nevents 100 + set floating_type m +#check run_01 505.5 2.749 100 diff --git a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/simple_cross_check/simd_cpp_vector_size b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/simple_cross_check/simd_cpp_vector_size new file mode 100644 index 0000000000..10396147fd --- /dev/null +++ b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/simple_cross_check/simd_cpp_vector_size @@ -0,0 +1,17 @@ +#title: check that multiple vector size returns the same value +import model sm +set automatic_html_opening False --no_save +set notification_center False --no_save +generate p p > t t~ +output madevent_simd %s -f -nojpeg +launch +set nevents 100 +set floating_type m +set vector_size 16 +launch +set vector_size 32 +launch +set vector_size 64 +#check run_01 505.5 2.749 100 +#check run_02 505.5 2.749 100 +#check run_03 505.5 2.749 100 diff --git a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/test_simd_madevent.py b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/test_simd_madevent.py new file mode 100644 index 0000000000..c820e9a1f9 --- /dev/null +++ b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/test_simd_madevent.py @@ -0,0 +1,346 @@ +# WARNING THIS FILE IS AUTOGENERATED -> edit test_simd_madevent.template + + +################################################################################ +# +# Copyright (c) 2009 The MadGraph5_aMC@NLO Development team and Contributors +# +# This file is a part of the MadGraph5_aMC@NLO project, an application which +# automatically generates Feynman diagrams and matrix elements for arbitrary +# high-energy processes in the Standard Model and beyond. +# +# It is subject to the MadGraph5_aMC@NLO license which should accompany this +# distribution. +# +# For more information, visit madgraph.phys.ucl.ac.be and amcatnlo.web.cern.ch +# +################################################################################ +from __future__ import division +from __future__ import absolute_import +import subprocess +import unittest +import os +import re +import shutil +import sys +import logging +import time +import tempfile +import math +import madgraph + + +logger = logging.getLogger('test_cmd') + +import tests.unit_tests.iolibs.test_file_writers as test_file_writers + +import madgraph.interface.master_interface as MGCmd +import madgraph.interface.madevent_interface as MECmd +import madgraph.interface.launch_ext_program as launch_ext +import madgraph.iolibs.files as files + +import madgraph.various.misc as misc +import madgraph.various.lhe_parser as lhe_parser +import madgraph.various.banner as banner_mod +import madgraph.various.lhe_parser as lhe_parser +import madgraph.various.banner as banner + +_file_path = os.path.split(os.path.dirname(os.path.realpath(__file__)))[0] +_pickle_path =os.path.join(_file_path, 'input_files') + +from madgraph import MG4DIR, MG5DIR, MadGraph5Error, InvalidCmd + +from tests.acceptance_tests.test_cmd_madevent import check_html_page +pjoin = os.path.join + + +#=============================================================================== +# TestCmd +#=============================================================================== +class TestCPPfromfile(unittest.TestCase): # inherit from upstream test_cmd_madevent + """test that we can launch everything from a single file""" + + + def setUp(self): + + self.debuging = unittest.debug + if self.debuging: + self.path = pjoin(MG5DIR, 'ACC_TEST') + if os.path.exists(self.path): + shutil.rmtree(self.path) + os.mkdir(self.path) + else: + self.path = tempfile.mkdtemp(prefix='acc_test_mg5') + self.run_dir = pjoin(self.path, 'MGPROC') + + + def tearDown(self): + + if not self.debuging: + shutil.rmtree(self.path) + self.assertFalse(self.debuging) + + def load_result(self, run_name): + + import madgraph.iolibs.save_load_object as save_load_object + import madgraph.madevent.gen_crossxhtml as gen_crossxhtml + + result = save_load_object.load_from_file(pjoin(self.run_dir,'HTML/results.pkl')) + return result[run_name] + + def check_parton_output(self, run_name='run_01', target_event=100, cross=0, error=9e99, delta_event=0, html=True): + """Check that parton output exists and reach the targert for event""" + + # check that the number of event is fine: + data = self.load_result(run_name) + if target_event > 0: + if delta_event == 0: + self.assertEqual(target_event, int(data[0]['nb_event'])) + else: + self.assertLessEqual(abs(int(data[0]['nb_event'])-target_event), delta_event) + self.assertIn('lhe', data[0].parton) + + if cross: + import math + new_error = math.sqrt(error**2 + float(data[0]['error'])**2) + self.assertLess( + abs(cross - float(data[0]['cross']))/new_error, + 3, + 'cross is %s and not %s. NB_SIGMA %s' % (float(data[0]['cross']), cross, float(data[0]['cross'])/new_error) + ) + self.assertLess(float(data[0]['error']), 3 * error) + if html: + check_html_page(self, pjoin(self.run_dir, 'crossx.html')) + if 'decayed' not in run_name: + check_html_page(self, pjoin(self.run_dir,'HTML', run_name, 'results.html')) + + + + +# WARNING THIS FILE IS AUTOGENERATED -> edit test_simd_madevent.template + def test_simd_cpp_heft_ggh_double(self): + """e testing a HEFT process gg>aa in double precision""" + + if logging.getLogger('madgraph').level <= 20: + stdout=None + stderr=None + else: + devnull =open(os.devnull,'w') + stdout=devnull + stderr=devnull + + try: + shutil.rmtree('/tmp/MGPROCESS/') + except Exception as error: + pass + + cmd = """#title testing a HEFT process gg>aa in double precision +import model heft + set automatic_html_opening False --no_save + set notification_center False --no_save + generate g g > h > a a + output madevent_simd %s -f -nojpeg + launch + set nevents 100 + set floating_type d +#check run_01 0.01859 0.0002853789088650386 100 + + """ %self.run_dir + + open(pjoin(self.path, 'mg5_cmd'),'w').write(cmd) + + subprocess.call([sys.executable, pjoin(MG5DIR, 'bin','mg5_aMC'), + pjoin(self.path, 'mg5_cmd')], + #cwd=self.path, + stdout=stdout, stderr=stderr) + + self.check_parton_output(cross=0.01859, error=0.0002853789088650386, run_name='run_01', html=True) + event = '%s/Events/run_01/unweighted_events.lhe' % self.run_dir + if not os.path.exists(event): + misc.gunzip(event) + + lhefile = lhe_parser.EventFile(event) + nb_event = 0 + for event in lhe_parser.EventFile(event): + event.check() + nb_event+=1 + + self.assertEqual(nb_event, 100) +# WARNING THIS FILE IS AUTOGENERATED -> edit test_simd_madevent.template + def test_simd_cpp_pptt_mixed(self): + """e check ggtt within mixed mode""" + + if logging.getLogger('madgraph').level <= 20: + stdout=None + stderr=None + else: + devnull =open(os.devnull,'w') + stdout=devnull + stderr=devnull + + try: + shutil.rmtree('/tmp/MGPROCESS/') + except Exception as error: + pass + + cmd = """#title check ggtt within mixed mode +import model sm + set automatic_html_opening False --no_save + set notification_center False --no_save + generate p p > t t~ + output madevent_simd %s -f -nojpeg + launch + set nevents 100 + set floating_type m +#check run_01 505.5 2.749 100 + + """ %self.run_dir + + open(pjoin(self.path, 'mg5_cmd'),'w').write(cmd) + + subprocess.call([sys.executable, pjoin(MG5DIR, 'bin','mg5_aMC'), + pjoin(self.path, 'mg5_cmd')], + #cwd=self.path, + stdout=stdout, stderr=stderr) + + self.check_parton_output(cross=505.5, error=2.749, run_name='run_01', html=True) + event = '%s/Events/run_01/unweighted_events.lhe' % self.run_dir + if not os.path.exists(event): + misc.gunzip(event) + + lhefile = lhe_parser.EventFile(event) + nb_event = 0 + for event in lhe_parser.EventFile(event): + event.check() + nb_event+=1 + + self.assertEqual(nb_event, 100) +# WARNING THIS FILE IS AUTOGENERATED -> edit test_simd_madevent.template + def test_simd_cpp_eemumua_float(self): + """e check eemumua in single precision""" + + if logging.getLogger('madgraph').level <= 20: + stdout=None + stderr=None + else: + devnull =open(os.devnull,'w') + stdout=devnull + stderr=devnull + + try: + shutil.rmtree('/tmp/MGPROCESS/') + except Exception as error: + pass + + cmd = """#title check eemumua in single precision +import model sm + set automatic_html_opening False --no_save + set notification_center False --no_save + generate e+ e- > mu+ mu- a + output madevent_simd %s -f -nojpeg + launch + set nevents 100 + set floating_type f +#check run_01 0.0266 0.0002854 100 + + """ %self.run_dir + + open(pjoin(self.path, 'mg5_cmd'),'w').write(cmd) + + subprocess.call([sys.executable, pjoin(MG5DIR, 'bin','mg5_aMC'), + pjoin(self.path, 'mg5_cmd')], + #cwd=self.path, + stdout=stdout, stderr=stderr) + + self.check_parton_output(cross=0.0266, error=0.0002854, run_name='run_01', html=True) + event = '%s/Events/run_01/unweighted_events.lhe' % self.run_dir + if not os.path.exists(event): + misc.gunzip(event) + + lhefile = lhe_parser.EventFile(event) + nb_event = 0 + for event in lhe_parser.EventFile(event): + event.check() + nb_event+=1 + + self.assertEqual(nb_event, 100) +# WARNING THIS FILE IS AUTOGENERATED -> edit test_simd_madevent.template + def test_simd_cpp_vector_size(self): + """e: check that multiple vector size returns the same value""" + + if logging.getLogger('madgraph').level <= 20: + stdout=None + stderr=None + else: + devnull =open(os.devnull,'w') + stdout=devnull + stderr=devnull + + try: + shutil.rmtree('/tmp/MGPROCESS/') + except Exception as error: + pass + + cmd = """#title: check that multiple vector size returns the same value +import model sm +set automatic_html_opening False --no_save +set notification_center False --no_save +generate p p > t t~ +output madevent_simd %s -f -nojpeg +launch +set nevents 100 +set floating_type m +set vector_size 16 +launch +set vector_size 32 +launch +set vector_size 64 +#check run_01 505.5 2.749 100 +#check run_02 505.5 2.749 100 +#check run_03 505.5 2.749 100 + + """ %self.run_dir + + open(pjoin(self.path, 'mg5_cmd'),'w').write(cmd) + + subprocess.call([sys.executable, pjoin(MG5DIR, 'bin','mg5_aMC'), + pjoin(self.path, 'mg5_cmd')], + #cwd=self.path, + stdout=stdout, stderr=stderr) + + self.check_parton_output(cross=505.5, error=2.749, run_name='run_01', html=True) + event = '%s/Events/run_01/unweighted_events.lhe' % self.run_dir + if not os.path.exists(event): + misc.gunzip(event) + + lhefile = lhe_parser.EventFile(event) + nb_event = 0 + for event in lhe_parser.EventFile(event): + event.check() + nb_event+=1 + + self.assertEqual(nb_event, 100) + self.check_parton_output(cross=505.5, error=2.749, run_name='run_02', html=False) + event = '%s/Events/run_02/unweighted_events.lhe' % self.run_dir + if not os.path.exists(event): + misc.gunzip(event) + + lhefile = lhe_parser.EventFile(event) + nb_event = 0 + for event in lhe_parser.EventFile(event): + event.check() + nb_event+=1 + + self.assertEqual(nb_event, 100) + self.check_parton_output(cross=505.5, error=2.749, run_name='run_03', html=False) + event = '%s/Events/run_03/unweighted_events.lhe' % self.run_dir + if not os.path.exists(event): + misc.gunzip(event) + + lhefile = lhe_parser.EventFile(event) + nb_event = 0 + for event in lhe_parser.EventFile(event): + event.check() + nb_event+=1 + + self.assertEqual(nb_event, 100) \ No newline at end of file diff --git a/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/test_simd_madevent.template b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/test_simd_madevent.template new file mode 100755 index 0000000000..3b9b8e2c7d --- /dev/null +++ b/epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/acceptance_tests/test_simd_madevent.template @@ -0,0 +1,115 @@ +################################################################################ +# +# Copyright (c) 2009 The MadGraph5_aMC@NLO Development team and Contributors +# +# This file is a part of the MadGraph5_aMC@NLO project, an application which +# automatically generates Feynman diagrams and matrix elements for arbitrary +# high-energy processes in the Standard Model and beyond. +# +# It is subject to the MadGraph5_aMC@NLO license which should accompany this +# distribution. +# +# For more information, visit madgraph.phys.ucl.ac.be and amcatnlo.web.cern.ch +# +################################################################################ +from __future__ import division +from __future__ import absolute_import +import subprocess +import unittest +import os +import re +import shutil +import sys +import logging +import time +import tempfile +import math +import madgraph + + +logger = logging.getLogger('test_cmd') + +import tests.unit_tests.iolibs.test_file_writers as test_file_writers + +import madgraph.interface.master_interface as MGCmd +import madgraph.interface.madevent_interface as MECmd +import madgraph.interface.launch_ext_program as launch_ext +import madgraph.iolibs.files as files + +import madgraph.various.misc as misc +import madgraph.various.lhe_parser as lhe_parser +import madgraph.various.banner as banner_mod +import madgraph.various.lhe_parser as lhe_parser +import madgraph.various.banner as banner + +_file_path = os.path.split(os.path.dirname(os.path.realpath(__file__)))[0] +_pickle_path =os.path.join(_file_path, 'input_files') + +from madgraph import MG4DIR, MG5DIR, MadGraph5Error, InvalidCmd + +from tests.acceptance_tests.test_cmd_madevent import check_html_page +pjoin = os.path.join + + +#=============================================================================== +# TestCmd +#=============================================================================== +class TestCPPfromfile(unittest.TestCase): # inherit from upstream test_cmd_madevent + """test that we can launch everything from a single file""" + + + def setUp(self): + + self.debuging = unittest.debug + if self.debuging: + self.path = pjoin(MG5DIR, 'ACC_TEST') + if os.path.exists(self.path): + shutil.rmtree(self.path) + os.mkdir(self.path) + else: + self.path = tempfile.mkdtemp(prefix='acc_test_mg5') + self.run_dir = pjoin(self.path, 'MGPROC') + + + def tearDown(self): + + if not self.debuging: + shutil.rmtree(self.path) + self.assertFalse(self.debuging) + + def load_result(self, run_name): + + import madgraph.iolibs.save_load_object as save_load_object + import madgraph.madevent.gen_crossxhtml as gen_crossxhtml + + result = save_load_object.load_from_file(pjoin(self.run_dir,'HTML/results.pkl')) + return result[run_name] + + def check_parton_output(self, run_name='run_01', target_event=100, cross=0, error=9e99, delta_event=0, html=True): + """Check that parton output exists and reach the targert for event""" + + # check that the number of event is fine: + data = self.load_result(run_name) + if target_event > 0: + if delta_event == 0: + self.assertEqual(target_event, int(data[0]['nb_event'])) + else: + self.assertLessEqual(abs(int(data[0]['nb_event'])-target_event), delta_event) + self.assertIn('lhe', data[0].parton) + + if cross: + import math + new_error = math.sqrt(error**2 + float(data[0]['error'])**2) + self.assertLess( + abs(cross - float(data[0]['cross']))/new_error, + 3, + 'cross is %s and not %s. NB_SIGMA %s' % (float(data[0]['cross']), cross, float(data[0]['cross'])/new_error) + ) + self.assertLess(float(data[0]['error']), 3 * error) + if html: + check_html_page(self, pjoin(self.run_dir, 'crossx.html')) + if 'decayed' not in run_name: + check_html_page(self, pjoin(self.run_dir,'HTML', run_name, 'results.html')) + + +