Skip to content
Snippets Groups Projects
Commit 854011d2 authored by Kurt A. O'Hearn's avatar Kurt A. O'Hearn
Browse files

sPuReMD: change static allocation in ICHOLT to dynamic allocation. Update run script.

parent 85945de1
No related branches found
No related tags found
No related merge requests found
......@@ -159,7 +159,7 @@ static void Calculate_Droptol( const sparse_matrix * const A, real * const dropt
unsigned int tid;
#endif
#pragma omp parallel default(none) private(i, j, k, val, tid), shared(droptol_local)
#pragma omp parallel default(none) private(i, j, k, val, tid), shared(droptol_local, stderr)
{
#ifdef _OPENMP
tid = omp_get_thread_num();
......@@ -172,6 +172,7 @@ static void Calculate_Droptol( const sparse_matrix * const A, real * const dropt
{
if ( (droptol_local = (real*) malloc( omp_get_num_threads() * A->n * sizeof(real))) == NULL )
{
fprintf( stderr, "Not enough space for droptol. Terminating...\n" );
exit( INSUFFICIENT_MEMORY );
}
}
......@@ -597,16 +598,21 @@ static real diag_pre_comp( const reax_system * const system, real * const Hdia_i
static real ICHOLT( const sparse_matrix * const A, const real * const droptol,
sparse_matrix * const L, sparse_matrix * const U )
{
//TODO: either add compilation parameter or dynamically allocate
int tmp_j[1000];
real tmp_val[1000];
int *tmp_j;
real *tmp_val;
int i, j, pj, k1, k2, tmptop, Ltop;
real val, start;
int *Utop;
start = Get_Time( );
Utop = (int*) malloc((A->n + 1) * sizeof(int));
if( ( Utop = (int*) malloc((A->n + 1) * sizeof(int)) ) == NULL ||
( tmp_j = (int*) malloc(A->n * sizeof(int)) ) == NULL ||
( tmp_val = (real*) malloc(A->n * sizeof(real)) ) == NULL )
{
fprintf( stderr, "not enough memory for ICHOLT preconditioning matrices. terminating.\n" );
exit( INSUFFICIENT_MEMORY );
}
// clear variables
Ltop = 0;
......@@ -726,7 +732,9 @@ static real ICHOLT( const sparse_matrix * const A, const real * const droptol,
// fprintf( stderr, "nnz(U): %d, max: %d\n", Utop[U->n], U->n * 50 );
free(Utop);
free( tmp_val );
free( tmp_j );
free( Utop );
return Get_Timing_Info( start );
}
......@@ -750,7 +758,7 @@ static real ICHOL_PAR( const sparse_matrix * const A, const unsigned int sweeps,
if ( Allocate_Matrix( &DAD, A->n, A->m ) == 0 )
{
fprintf( stderr, "not enough memory for preconditioning matrices. terminating.\n" );
fprintf( stderr, "not enough memory for ICHOL_PAR preconditioning matrices. terminating.\n" );
exit( INSUFFICIENT_MEMORY );
}
......@@ -758,7 +766,7 @@ static real ICHOL_PAR( const sparse_matrix * const A, const unsigned int sweeps,
( D_inv = (real*) malloc(A->n * sizeof(real)) ) == NULL ||
( Utop = (int*) malloc((A->n + 1) * sizeof(int)) ) == NULL )
{
fprintf( stderr, "not enough memory for preconditioning matrices. terminating.\n" );
fprintf( stderr, "not enough memory for ICHOL_PAR preconditioning matrices. terminating.\n" );
exit( INSUFFICIENT_MEMORY );
}
......@@ -948,14 +956,14 @@ static real ILU_PAR( const sparse_matrix * const A, const unsigned int sweeps,
if ( Allocate_Matrix( &DAD, A->n, A->m ) == 0 )
{
fprintf( stderr, "not enough memory for preconditioning matrices. terminating.\n" );
fprintf( stderr, "not enough memory for ILU_PAR preconditioning matrices. terminating.\n" );
exit( INSUFFICIENT_MEMORY );
}
if( ( D = (real*) malloc(A->n * sizeof(real)) ) == NULL ||
( D_inv = (real*) malloc(A->n * sizeof(real)) ) == NULL )
{
fprintf( stderr, "not enough memory for preconditioning matrices. terminating.\n" );
fprintf( stderr, "not enough memory for ILU_PAR preconditioning matrices. terminating.\n" );
exit( INSUFFICIENT_MEMORY );
}
......@@ -1158,14 +1166,14 @@ static real ILUT_PAR( const sparse_matrix * const A, const real * droptol,
Allocate_Matrix( &L_temp, A->n, A->m ) == 0 ||
Allocate_Matrix( &U_temp, A->n, A->m ) == 0 )
{
fprintf( stderr, "not enough memory for preconditioning matrices. terminating.\n" );
fprintf( stderr, "not enough memory for ILUT_PAR preconditioning matrices. terminating.\n" );
exit( INSUFFICIENT_MEMORY );
}
if( ( D = (real*) malloc(A->n * sizeof(real)) ) == NULL ||
( D_inv = (real*) malloc(A->n * sizeof(real)) ) == NULL )
{
fprintf( stderr, "not enough memory for preconditioning matrices. terminating.\n" );
fprintf( stderr, "not enough memory for ILUT_PAR preconditioning matrices. terminating.\n" );
exit( INSUFFICIENT_MEMORY );
}
......
......@@ -103,18 +103,28 @@ class TestCase():
env['OMP_NUM_THREADS'] = param_dict['threads']
start = time()
proc_handle = Popen([bin_path, self.__geo_file, self.__ffield_file, temp_file],
stdout=PIPE, stderr=PIPE, env=env)
stdout=PIPE, stderr=PIPE, env=env, universal_newlines=True)
stdout, stderr = proc_handle.communicate()
stop = time()
if proc_handle.returncode < 0:
print("WARNING: process terminated with code {0}".format(proc_handle.returncode))
else:
print('stdout:')
print(stdout)
print('stderr:')
print(stderr)
else:
#TODO: fix
start = 0.
stop = 0.
self._process_result(fout, stop - start, param_dict)
fout.close()
remove(temp_file)
rmdir(temp_dir)
if path.exists(temp_file):
remove(temp_file)
if path.exists(temp_dir):
rmdir(temp_dir)
def _process_result(self, fout, time, param):
qeq = 0.
......@@ -123,7 +133,12 @@ class TestCase():
pre_app = 0.
spmv = 0.
cnt = 0
with open(param['name'] + '.log', 'r') as fp:
log_file = param['name'] + '.log'
if not path.exists(log_file):
print('***WARNING: {0} does not exist!'.format(log_file))
return
with open(log_file, 'r') as fp:
for line in fp:
line = line.split()
try:
......@@ -219,7 +234,7 @@ if __name__ == '__main__':
geo_format=['1'], result_file=result_file))
if 'water_78480' in args.data:
test_cases.append(
TestCase(path.join(data_dir, 'water/water_78480.pdb'),
TestCase(path.join(data_dir, 'water/water_78480.geo'),
path.join(data_dir, 'water/ffield.water'),
path.join(control_dir, 'param.gpu.water'),
params=params, result_header_fmt=header_fmt_str,
......@@ -241,6 +256,14 @@ if __name__ == '__main__':
params=params, result_header_fmt=header_fmt_str,
result_header = header_str, result_body_fmt=body_fmt_str,
geo_format=['1'], result_file=result_file))
if 'bilayer_340800' in args.data:
test_cases.append(
TestCase(path.join(data_dir, 'bilayer/bilayer_340800.geo'),
path.join(data_dir, 'bilayer/ffield-bio'),
path.join(control_dir, 'param.gpu.water'),
params=params, result_header_fmt=header_fmt_str,
result_header = header_str, result_body_fmt=body_fmt_str,
geo_format=['0'], result_file=result_file))
if 'dna_19733' in args.data:
test_cases.append(
TestCase(path.join(data_dir, 'dna/dna_19733.pdb'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment