Skip to content

Commit

Permalink
Merge branch 'master' of github.com:kyleniemeyer/pyJac
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleniemeyer committed May 26, 2016
2 parents 66e8a85 + 4310b6a commit c0c7b09
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 35 deletions.
5 changes: 2 additions & 3 deletions pyjac/functional_tester/pasr_input.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
62 changes: 32 additions & 30 deletions pyjac/performance_tester/performance_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -290,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']
Expand All @@ -305,31 +300,30 @@ 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)

if num_conditions == 0:
print('No data found in folder {}, continuing...'.format(mech_name))
continue
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)
if num_conditions == 0:
print('No data found in folder {}, continuing...'.format(mech_name))
continue
data.tofile(file)

#figure out gpu steps
step_size = 1
Expand Down Expand Up @@ -365,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'
Expand Down Expand Up @@ -480,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
)
6 changes: 6 additions & 0 deletions pyjac/performance_tester/tc_tester.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions pyjac/performance_tester/tester.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions pyjac/performance_tester/tester.cu.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c0c7b09

Please sign in to comment.