1 | import glob |
---|
2 | import sys |
---|
3 | import subprocess |
---|
4 | import os |
---|
5 | |
---|
6 | user_acct=os.getenv("user_account") |
---|
7 | |
---|
8 | def OSinfo(runthis): |
---|
9 | red = lambda text: '\033[0;31m' + text + '\033[0m' |
---|
10 | osstdout = subprocess.Popen(runthis, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True) |
---|
11 | theInfo, theErr = osstdout.communicate() |
---|
12 | if theErr: |
---|
13 | print(red(runthis+" FAILED")) |
---|
14 | print(theErr) |
---|
15 | sys.exit() |
---|
16 | |
---|
17 | |
---|
18 | def generate_compile_job_irene(revision): |
---|
19 | with open("job_compile_irene.sh", "w") as f: |
---|
20 | f.write("#!/bin/bash\n") |
---|
21 | f.write("#=====================================\n") |
---|
22 | f.write("#script generated by config_compile.py\n") |
---|
23 | f.write("#=====================================\n") |
---|
24 | f.write("#MSUB -r XIOS_rev"+revision+"\n") |
---|
25 | f.write("#MSUB -o client_output.out\n") |
---|
26 | f.write("#MSUB -e client_error.err\n") |
---|
27 | f.write("#MSUB -eo\n") |
---|
28 | f.write("#MSUB -c 16\n") |
---|
29 | f.write("#MSUB -n 1\n") |
---|
30 | f.write("#MSUB -X\n") |
---|
31 | f.write("#MSUB -x\n") |
---|
32 | f.write("#MSUB -T 1800\n") |
---|
33 | f.write("#MSUB -q skylake\n") |
---|
34 | f.write("#MSUB -A "+user_acct+"\n") |
---|
35 | f.write("#MSUB -Q test\n") |
---|
36 | f.write("#MSUB -m work,scratch\n") |
---|
37 | f.write("cd $BRIDGE_MSUB_PWD\n") |
---|
38 | f.write("cmake .\n") |
---|
39 | f.write("ctest -V\n") |
---|
40 | f.write("exit\n") |
---|
41 | |
---|
42 | |
---|
43 | |
---|
44 | def generate_compile_job_jeanzay(revision): |
---|
45 | print("generating compile job for jz") |
---|
46 | with open("job_compile_jeanzay.sh", "w") as f: |
---|
47 | f.write("#!/bin/bash\n") |
---|
48 | f.write("#=====================================\n") |
---|
49 | f.write("#script generated by config_compile.py\n") |
---|
50 | f.write("#=====================================\n") |
---|
51 | f.write("#SBATCH --ntasks=1\n") |
---|
52 | f.write("#SBATCH --cpus-per-task=16\n") |
---|
53 | f.write("#SBATCH --hint=nomultithread\n") |
---|
54 | f.write("#SBATCH -t 00:30:00\n") |
---|
55 | f.write("#SBATCH -o output.out\n") |
---|
56 | f.write("#SBATCH -e error.err \n") |
---|
57 | f.write("#SBATCH -A "+user_acct+"\n") |
---|
58 | f.write("#SBATCH --job-name=XIOS_rev"+revision+"\n") |
---|
59 | f.write("#SBATCH --qos=qos_cpu-dev\n") |
---|
60 | f.write("cd ${SLURM_SUBMIT_DIR}\n") |
---|
61 | f.write("cmake .\n") |
---|
62 | f.write("ctest -V\n") |
---|
63 | f.write("exit\n") |
---|
64 | |
---|
65 | |
---|
66 | def main(): |
---|
67 | machine=os.getenv('xios_machine_name') |
---|
68 | revision=os.getenv('revision') |
---|
69 | |
---|
70 | |
---|
71 | default_nb_config = 2 |
---|
72 | nb_config = 1 |
---|
73 | configs = [0]*default_nb_config |
---|
74 | configs_arg = [[], []] |
---|
75 | |
---|
76 | f=open("compile_param_"+machine+".def", "r") |
---|
77 | for line in f: |
---|
78 | line = line.strip() |
---|
79 | if len(line) != 0: |
---|
80 | if not line.startswith("#"): |
---|
81 | nb_config = nb_config * (line.count(",")+1) |
---|
82 | line = line.replace(",", "") |
---|
83 | line = line.replace("=", "") |
---|
84 | if line.startswith("arch"): |
---|
85 | line = line.replace("arch", "") |
---|
86 | for word in line.split(): |
---|
87 | configs[0] += 1 |
---|
88 | configs_arg[0].append(word) |
---|
89 | elif line.startswith("mode"): |
---|
90 | line = line.replace("mode", "") |
---|
91 | for word in line.split(): |
---|
92 | configs[1] += 1 |
---|
93 | configs_arg[1].append(word) |
---|
94 | f.close() |
---|
95 | |
---|
96 | f=open("CMakeLists.txt", "w") |
---|
97 | f.write("#######################################\n") |
---|
98 | f.write("# file generated by config_compile.py #\n") |
---|
99 | f.write("# DO NOT modify #\n") |
---|
100 | f.write("#######################################\n\n") |
---|
101 | f.write("cmake_minimum_required(VERSION 2.8.12.2)\n\n") |
---|
102 | f.write("project(generic_testcase)\n\n") |
---|
103 | f.write("find_package(PythonInterp REQUIRED)\n\n") |
---|
104 | f.write("enable_testing()\n\n") |
---|
105 | |
---|
106 | for i in range(len(configs_arg[0])): |
---|
107 | for j in range(len(configs_arg[1])): |
---|
108 | build_dir_name = configs_arg[0][i]+"_"+configs_arg[1][j] |
---|
109 | g=open("build_"+revision+"_"+machine+"_"+build_dir_name+".txt", "w") |
---|
110 | g.write("arch "+configs_arg[0][i]+"\n") |
---|
111 | g.write("mode "+configs_arg[1][j]+"\n") |
---|
112 | g.write("machine "+machine+"\n") |
---|
113 | g.write("revision "+revision+"\n") |
---|
114 | g.close() |
---|
115 | |
---|
116 | f.write("add_test( NAME "+build_dir_name+'\n') |
---|
117 | f.write(" COMMAND bash -c \"source ../ARCH/arch-"+configs_arg[0][i]+".env && cd ../.. && ./make_xios --use_tv --arch_path `pwd`/xios_test_suite/ARCH --arch "+configs_arg[0][i]+" --"+configs_arg[1][j]+" --job 16 --build_dir xios_test_suite/BUILD/build_"+build_dir_name+" ; echo $? >> xios_test_suite/COMPILE/build_"+revision+"_"+machine+"_"+build_dir_name+".txt\")\n\n") |
---|
118 | f.write("set_tests_properties( "+build_dir_name+" PROPERTIES\n") |
---|
119 | f.write(" FAIL_REGULAR_EXPRESSION \"failed\")\n\n") |
---|
120 | |
---|
121 | |
---|
122 | f.close() |
---|
123 | |
---|
124 | globals()['generate_compile_job_'+machine](revision) |
---|
125 | |
---|
126 | if __name__== "__main__": |
---|
127 | main() |
---|