From 6253c07f03a00887b8347326b0fd958810015c4b Mon Sep 17 00:00:00 2001 From: arghdos Date: Tue, 17 May 2016 17:44:57 -0400 Subject: [PATCH 1/6] bugfix fo how the data.bin's are created for testing --- .../performance_tester/performance_tester.py | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/pyjac/performance_tester/performance_tester.py b/pyjac/performance_tester/performance_tester.py index c68dc0c..4598601 100644 --- a/pyjac/performance_tester/performance_tester.py +++ b/pyjac/performance_tester/performance_tester.py @@ -305,27 +305,27 @@ def false_factory(): subprocess.check_call(['mkdir', '-p', build_dir]) subprocess.check_call(['mkdir', '-p', test_dir]) - #clear old data - with open(os.path.join('data.bin'), 'wb') as file: - pass - + num_conditions = 0 npy_files = [f for f in os.listdir(os.path.join(work_dir, mech_name)) if f.endswith('.npy') and os.path.isfile(f)] - num_conditions = 0 - #load PaSR data for different pressures/conditions, - # and save to binary C file - for npy in npy_files: - state_data = np.load(npy) - state_data = state_data.reshape(state_data.shape[0] * - state_data.shape[1], - state_data.shape[2] - ) - with open(os.path.join('data.bin'), "ab") as file: - state_data.tofile(file) - - num_conditions += state_data.shape[0] - print(num_conditions) + data = None + with open('data.bin', 'wb') as file: + #load PaSR data for different pressures/conditions, + # and save to binary C file + for npy in sorted(npy_files): + state_data = np.load(npy) + state_data = state_data.reshape(state_data.shape[0] * + state_data.shape[1], + state_data.shape[2] + ) + if data is None: + data = state_data + else: + data = np.vstack((data, state_data)) + num_conditions += state_data.shape[0] + print(num_conditions, data.shape) + data.tofile(file) if num_conditions == 0: print('No data found in folder {}, continuing...'.format(mech_name)) From be0a98f8d0be732cdd36f431205f129d2683f59b Mon Sep 17 00:00:00 2001 From: arghdos Date: Tue, 17 May 2016 17:47:11 -0400 Subject: [PATCH 2/6] moveup incase data is None --- pyjac/functional_tester/pasr_input.yaml | 5 ++--- pyjac/performance_tester/performance_tester.py | 7 +++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/pyjac/functional_tester/pasr_input.yaml b/pyjac/functional_tester/pasr_input.yaml index 7021708..3ae4976 100644 --- a/pyjac/functional_tester/pasr_input.yaml +++ b/pyjac/functional_tester/pasr_input.yaml @@ -4,16 +4,15 @@ temperature: 300.0 pressure: 1.0 equivalence ratio: 1.0 fuel: - CH4: 1.0 + H2: 1.0 oxidizer: O2: 1.0 N2: 3.76 complete products: - - CO2 - H2O - N2 number of particles: 100 residence time: 10.e-3 mixing time: 1.e-3 pairing time: 1.e-3 -number of residence times: 5 +number of residence times: 10 diff --git a/pyjac/performance_tester/performance_tester.py b/pyjac/performance_tester/performance_tester.py index 4598601..20f9256 100644 --- a/pyjac/performance_tester/performance_tester.py +++ b/pyjac/performance_tester/performance_tester.py @@ -325,12 +325,11 @@ def false_factory(): data = np.vstack((data, state_data)) num_conditions += state_data.shape[0] print(num_conditions, data.shape) + if num_conditions == 0: + print('No data found in folder {}, continuing...'.format(mech_name)) + continue data.tofile(file) - if num_conditions == 0: - print('No data found in folder {}, continuing...'.format(mech_name)) - continue - #figure out gpu steps step_size = 1 steplist = [] From 43ffa83edcf5beeff6f1687dd5070e4fd7b6c60a Mon Sep 17 00:00:00 2001 From: arghdos Date: Tue, 17 May 2016 17:52:18 -0400 Subject: [PATCH 3/6] unused --- pyjac/performance_tester/performance_tester.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pyjac/performance_tester/performance_tester.py b/pyjac/performance_tester/performance_tester.py index 20f9256..a033a98 100644 --- a/pyjac/performance_tester/performance_tester.py +++ b/pyjac/performance_tester/performance_tester.py @@ -266,11 +266,6 @@ def performance_tester(home, work_dir, use_old_opt, num_threads): else: raise SystemError('TCHEM_HOME environment variable not set.') - - cache_opt_base = [False, True] - shared_base = [True, False] - finite_diffs_base = [False, True] - cpu_repeats = 10 gpu_repeats = 10 From b54e04555335134176914b4749a75e7085468f3f Mon Sep 17 00:00:00 2001 From: arghdos Date: Tue, 17 May 2016 17:58:03 -0400 Subject: [PATCH 4/6] turn off tchem for cheb/plog --- pyjac/performance_tester/performance_tester.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pyjac/performance_tester/performance_tester.py b/pyjac/performance_tester/performance_tester.py index a033a98..3dcd922 100644 --- a/pyjac/performance_tester/performance_tester.py +++ b/pyjac/performance_tester/performance_tester.py @@ -359,6 +359,14 @@ def false_factory(): opt = state['cache_opt'] smem = state['shared'] + if any([isinstance(rxn, ct.PlogReaction) or + isinstance(rxn, ct.ChebyshevReaction) for rxn in gas.reactions() + ]) and lang == 'tchem': + print('TChem performance evaluation disabled; ' + 'not compatible with Plog or Chebyshev reactions.' + ) + continue + data_output = ('{}_{}_{}_{}'.format(lang, 'co' if opt else 'nco', 'smem' if smem else 'nosmem', 'fd' if FD else 'ajac' From 46f70eee3d8a7d52c8546c494b7c00c0aac87d47 Mon Sep 17 00:00:00 2001 From: arghdos Date: Tue, 24 May 2016 12:54:46 -0400 Subject: [PATCH 5/6] these are defined in GPU macros now --- pyjac/performance_tester/tester.cu.in | 2 -- 1 file changed, 2 deletions(-) diff --git a/pyjac/performance_tester/tester.cu.in b/pyjac/performance_tester/tester.cu.in index e302eb3..593e57a 100644 --- a/pyjac/performance_tester/tester.cu.in +++ b/pyjac/performance_tester/tester.cu.in @@ -21,8 +21,6 @@ void eval_jacob (const double, const double, const double *, double *, const mec __host__ void read_initial_conditions(const char*, int, double**, double**); -#define T_ID (threadIdx.x + (blockDim.x * blockIdx.x)) -#define GRID_SIZE (blockDim.x * gridDim.x) __global__ #ifdef FINITE_DIFF void jac_driver(int NUM, const double* pres, const double* y, const mechanism_memory* d_mem, double* y_temp) From 4310b6ac41338652901e970c2c2165a59710969e Mon Sep 17 00:00:00 2001 From: arghdos Date: Wed, 25 May 2016 11:38:57 -0400 Subject: [PATCH 6/6] minor change to how the omp thread # was being set, was previously in ENV but this seems to fail in some cases. Instead directly pass command line arguement and set manually --- pyjac/performance_tester/performance_tester.py | 6 +++--- pyjac/performance_tester/tc_tester.c.in | 6 ++++++ pyjac/performance_tester/tester.c.in | 6 ++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/pyjac/performance_tester/performance_tester.py b/pyjac/performance_tester/performance_tester.py index 3dcd922..5720065 100644 --- a/pyjac/performance_tester/performance_tester.py +++ b/pyjac/performance_tester/performance_tester.py @@ -285,8 +285,8 @@ def false_factory(): #set up testing environment env = os.environ.copy() - env['OMP_NUM_THREADS'] = str(num_threads) - env['MKL_NUM_THREADS'] = str(num_threads) + env['OMP_NUM_THREADS'] = str(1) + env['MKL_NUM_THREADS'] = str(1) for mech_name, mech_info in sorted(mechanism_list.items(), key=lambda x:x[1]['ns'] @@ -482,5 +482,5 @@ def false_factory(): subprocess.check_call( [os.path.join(the_path, test_dir, 'speedtest'), - str(stepsize)], stdout=file, env=env + str(stepsize), str(num_threads)], stdout=file, env=env ) diff --git a/pyjac/performance_tester/tc_tester.c.in b/pyjac/performance_tester/tc_tester.c.in index 4e5fd12..76b5d17 100644 --- a/pyjac/performance_tester/tc_tester.c.in +++ b/pyjac/performance_tester/tc_tester.c.in @@ -15,6 +15,12 @@ int main(int argc, char *argv[]) { exit(-1); } + int num_threads = 1; + if (sscanf(argv[1], "%i", &num_threads) !=1 || (num_threads <= 0)) + { + exit(-1); + } + omp_set_num_threads(num_threads); double* y_host; double* var_host; diff --git a/pyjac/performance_tester/tester.c.in b/pyjac/performance_tester/tester.c.in index ca880fc..8ea3741 100644 --- a/pyjac/performance_tester/tester.c.in +++ b/pyjac/performance_tester/tester.c.in @@ -10,6 +10,12 @@ void read_initial_conditions(const char* filename, int NUM, double** y_host, dou { exit(-1); } + int num_threads = 1; + if (sscanf(argv[1], "%i", &num_threads) !=1 || (num_threads <= 0)) + { + exit(-1); + } + omp_set_num_threads(num_threads); double* y_host; double* var_host; read_initial_conditions("$datafile", num_odes, &y_host, &var_host);