Newer
Older
}
total_hbonds = MAX( total_hbonds, MIN_CAP * MIN_HBONDS );
//fprintf (stderr, "HCap value is --> %d, system->n is : %d (%d)\n", system->Hcap, system->n, count);
//fprintf (stderr, "Total Hydrogen Bonds --> %d ** misc %d \n", total_hbonds, hb_top[4021] );
//if( !Dev_Make_List( system->local_cap, total_hbonds, TYP_HBOND, *dev_lists+HBONDS) ) {
/*************/
//CHANGE ORIGINAL
//if( !Dev_Make_List( system->total_cap, total_hbonds, TYP_HBOND, *dev_lists+HBONDS) ) {
if ( !Dev_Make_List( system->total_cap, system->total_cap * system->max_hbonds, TYP_HBOND, *dev_lists + HBONDS) )
{
/**************/
fprintf( stderr, "not enough space for hbonds list. terminating!\n" );
MPI_Abort( MPI_COMM_WORLD, INSUFFICIENT_MEMORY );
}
Kurt A. O'Hearn
committed
#if defined(DEBUG_FOCUS)
fprintf (stderr, "**** Total HBonds allocated --> %d total_cap: %d per atom: %d, max_hbonds: %d \n",
total_hbonds, system->total_cap, (total_hbonds / system->total_cap), system->max_hbonds );
Kurt A. O'Hearn
committed
#endif
//TODO
//Cuda_Init_HBond_Indices (hb_top, system->n);
/****/
//THIS IS COMMENTED OUT - CHANGE ORIGINAL
//Cuda_Init_HBond_Indices (hb_top, system->N);
//THIS IS COMMENTED OUT - CHANGE ORIGINAL
/****/
fprintf( stderr, "p%d: allocated hbonds: total_hbonds=%d, space=%dMB\n",
system->my_rank, total_hbonds,
(int)(total_hbonds * sizeof(hbond_data) / (1024 * 1024)) );
}
/* bonds list */
total_bonds = 0;
for ( i = 0; i < system->N; ++i )
{
//system->my_atoms[i].num_bonds = bond_top[i];
num_3body += SQR (bond_top [i]);
total_bonds += MAX (bond_top[i] * 4, MIN_BONDS);
}
bond_cap = MAX( total_bonds, MIN_CAP * MIN_BONDS );
Kurt A. O'Hearn
committed
#if defined(DEBUG)
fprintf (stderr, "**** Total Bonds allocated --> %d total_cap: %d per atom: %d, max_bonds: %d \n",
bond_cap, system->total_cap, (bond_cap / system->total_cap), system->max_bonds );
Kurt A. O'Hearn
committed
#endif
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
/***************/
//CHANGE ORIGINAL
//if( !Dev_Make_List( system->total_cap, bond_cap, TYP_BOND, *dev_lists + BONDS) ) {
if ( !Dev_Make_List( system->total_cap, system->total_cap * system->max_bonds, TYP_BOND, *dev_lists + BONDS) )
{
/***************/
fprintf( stderr, "not enough space for bonds list. terminating!\n" );
MPI_Abort( MPI_COMM_WORLD, INSUFFICIENT_MEMORY );
}
//TODO
//if( !Make_List( system->total_cap, bond_cap, TYP_BOND, *lists + BONDS) ) {
if ( !Make_List( system->total_cap, system->total_cap * system->max_bonds, TYP_BOND, *lists + BONDS) )
{
fprintf( stderr, "not enough space for bonds list. terminating!\n" );
MPI_Abort( MPI_COMM_WORLD, INSUFFICIENT_MEMORY );
}
//TODO
/****/
//CHANGE ORIGINAL
//Cuda_Init_Bond_Indices (bond_top, system->N, bond_cap);
//CHANGE ORIGINAL
/****/
fprintf( stderr, "p%d: allocated bonds: total_bonds=%d, space=%dMB\n",
system->my_rank, bond_cap,
(int)(bond_cap * sizeof(bond_data) / (1024 * 1024)) );
/* 3bodies list */
//cap_3body = MAX( num_3body*SAFE_ZONE, MIN_3BODIES );
cap_3body = MAX( num_3body * SAFE_ZONE, MIN_3BODIES );
//fprintf (stderr, "Total 3 bodies n: %d num_intrs: %d \n", bond_cap, bond_cap * MAX_THB_INTRS);
//if( !Dev_Make_List(bond_cap, cap_3body, TYP_THREE_BODY, *lists + THREE_BODIES) ){
// if( !Dev_Make_List(bond_cap, bond_cap * MAX_THB_INTRS, TYP_THREE_BODY, *dev_lists + THREE_BODIES) ){
// fprintf( stderr, "Problem in initializing angles list. Terminating!\n" );
// MPI_Abort( MPI_COMM_WORLD, INSUFFICIENT_MEMORY );
// }
#if defined(DEBUG_FOCUS)
fprintf( stderr, "p%d: allocated 3-body list: num_3body=%d, space=%dMB\n",
system->my_rank, cap_3body,
(int)(cap_3body * sizeof(three_body_interaction_data) / (1024 * 1024)) );
Kurt A. O'Hearn
committed
#endif
void Initialize( reax_system *system, control_params *control,
simulation_data *data, storage *workspace,
reax_list **lists, output_controls *out_control,
mpi_datatypes *mpi_data )
host_scratch = (void *)malloc( HOST_SCRATCH_SIZE );
char msg[MAX_STR];
if ( Init_MPI_Datatypes( system, workspace, mpi_data, msg ) == FAILURE )
{
fprintf( stderr, "p%d: init_mpi_datatypes: could not create datatypes\n",
system->my_rank );
fprintf( stderr, "p%d: mpi_data couldn't be initialized! terminating.\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
}
fprintf( stderr, "p%d: initialized mpi datatypes\n", system->my_rank );
if ( Init_System(system, control, data, workspace, mpi_data, msg) == FAILURE )
{
fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
fprintf( stderr, "p%d: system could not be initialized! terminating.\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
}
fprintf( stderr, "p%d: system initialized\n", system->my_rank );
if ( Init_Simulation_Data( system, control, data, msg ) == FAILURE )
{
fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
fprintf( stderr, "p%d: sim_data couldn't be initialized! terminating.\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
}
fprintf( stderr, "p%d: initialized simulation data\n", system->my_rank );
if ( Init_Workspace( system, control, workspace, msg ) == FAILURE )
{
fprintf( stderr, "p%d:init_workspace: not enough memory\n",
system->my_rank );
fprintf( stderr, "p%d:workspace couldn't be initialized! terminating.\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
}
fprintf( stderr, "p%d: initialized workspace\n", system->my_rank );
if ( Init_Lists( system, control, data, workspace, lists, mpi_data, msg ) ==
FAILURE )
{
fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
fprintf( stderr, "p%d: system could not be initialized! terminating.\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
fprintf( stderr, "p%d: initialized lists\n", system->my_rank );
if (Init_Output_Files(system, control, out_control, mpi_data, msg) == FAILURE)
{
fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
fprintf( stderr, "p%d: could not open output files! terminating...\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
}
fprintf( stderr, "p%d: output files opened\n", system->my_rank );
Kurt A. O'Hearn
committed
if ( Init_Lookup_Tables(system, control, workspace->Tap, mpi_data, msg) == FAILURE )
{
fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
fprintf( stderr, "p%d: couldn't create lookup table! terminating.\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
}
fprintf( stderr, "p%d: initialized lookup tables\n", system->my_rank );
fprintf( stderr, "p%d: initialized force functions\n", system->my_rank );
/*#ifdef TEST_FORCES
Init_Force_Test_Functions();
fprintf(stderr,"p%d: initialized force test functions\n",system->my_rank);
#endif */
void Pure_Initialize( reax_system *system, control_params *control,
simulation_data *data, storage *workspace,
reax_list **lists, output_controls *out_control,
mpi_datatypes *mpi_data )
char msg[MAX_STR];
if ( Init_Simulation_Data( system, control, data, msg ) == FAILURE )
{
fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
fprintf( stderr, "p%d: sim_data couldn't be initialized! terminating.\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
}
fprintf( stderr, "p%d: initialized simulation data\n", system->my_rank );
fprintf( stderr, "p%d: pure initialized simulation data\n", system->my_rank );
if ( Init_Workspace( system, control, workspace, msg ) == FAILURE )
{
fprintf( stderr, "p%d:init_workspace: not enough memory\n",
system->my_rank );
fprintf( stderr, "p%d:workspace couldn't be initialized! terminating.\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
}
fprintf( stderr, "p%d: initialized workspace\n", system->my_rank );
fprintf( stderr, "p%d: pure initialized workspace\n", system->my_rank );
if ( Init_Lists( system, control, data, workspace, lists, mpi_data, msg ) ==
FAILURE )
{
fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
fprintf( stderr, "p%d: system could not be initialized! terminating.\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
fprintf( stderr, "p%d: initialized lists\n", system->my_rank );
fprintf( stderr, "p%d: pure initialized lists done \n", system->my_rank );
Kurt A. O'Hearn
committed
#ifdef HAVE_CUDA
void Cuda_Initialize( reax_system *system, control_params *control,
simulation_data *data, storage *workspace,
reax_list **lists, output_controls *out_control,
mpi_datatypes *mpi_data )
char msg[MAX_STR];
real t_start, t_end;
//HOST SCRATCH and Device SCRATCH
Cuda_Init_ScratchArea( );
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
//MPI_DATATYPES
if ( Init_MPI_Datatypes( system, workspace, mpi_data, msg ) == FAILURE )
{
fprintf( stderr, "p%d: init_mpi_datatypes: could not create datatypes\n",
system->my_rank );
fprintf( stderr, "p%d: mpi_data couldn't be initialized! terminating.\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
}
//SYSTEM
if ( Cuda_Init_System(system, control, data, workspace, mpi_data, msg) == FAILURE )
{
fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
fprintf( stderr, "p%d: system could not be initialized! terminating.\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
}
//GRID
dev_alloc_grid (system);
Sync_Grid (&system->my_grid, &system->d_my_grid);
//validate_grid (system);
//exit (0);
//SIMULATION_DATA
dev_alloc_simulation_data (data);
if ( Cuda_Init_Simulation_Data( system, control, data, msg ) == FAILURE )
{
fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
fprintf( stderr, "p%d: sim_data couldn't be initialized! terminating.\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
}
//WORKSPACE
if ( Cuda_Init_Workspace( system, control, workspace, msg ) == FAILURE )
{
fprintf( stderr, "p%d:init_workspace: not enough memory\n",
system->my_rank );
fprintf( stderr, "p%d:workspace couldn't be initialized! terminating.\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
}
fprintf( stderr, "p%d: initialized workspace\n", system->my_rank );
//Sync the taper here from host to device.
//CONTROL
dev_alloc_control (control);
//LISTS
if ( Cuda_Init_Lists( system, control, data, workspace, lists, mpi_data, msg ) ==
FAILURE )
{
fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
fprintf( stderr, "p%d: system could not be initialized! terminating.\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
fprintf( stderr, "p%d: initialized lists\n", system->my_rank );
//OUTPUT Files
if (Init_Output_Files(system, control, out_control, mpi_data, msg) == FAILURE)
{
fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
fprintf( stderr, "p%d: could not open output files! terminating...\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
}
fprintf( stderr, "p%d: output files opened\n", system->my_rank );
//Lookup Tables
if ( control->tabulate )
{
if ( Init_Lookup_Tables(system, control, dev_workspace->Tap, mpi_data, msg) == FAILURE )
{
fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
fprintf( stderr, "p%d: couldn't create lookup table! terminating.\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
}
fprintf( stderr, "p%d: initialized lookup tables\n", system->my_rank );
fprintf( stderr, "p%d: Device Initialization Done \n", system->my_rank );
Kurt A. O'Hearn
committed
#endif
void Initialize( reax_system *system, control_params *control,
simulation_data *data, storage *workspace,
reax_list **lists, output_controls *out_control,
mpi_datatypes *mpi_data )
host_scratch = (void *)malloc( HOST_SCRATCH_SIZE );
if ( Init_System(system, msg) == FAILURE )
{
fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
fprintf( stderr, "p%d: system could not be initialized! terminating.\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
}
fprintf( stderr, "p%d: system initialized\n", system->my_rank );
if ( Init_Simulation_Data( system, control, data, msg ) == FAILURE )
{
fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
fprintf( stderr, "p%d: sim_data couldn't be initialized! terminating.\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
}
fprintf( stderr, "p%d: initialized simulation data\n", system->my_rank );
if ( Init_Workspace( system, control, workspace, msg ) == FAILURE )
{
fprintf( stderr, "p%d:init_workspace: not enough memory\n",
system->my_rank );
fprintf( stderr, "p%d:workspace couldn't be initialized! terminating.\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
}
fprintf( stderr, "p%d: initialized workspace\n", system->my_rank );
if ( Init_MPI_Datatypes( system, workspace, mpi_data, msg ) == FAILURE )
{
fprintf( stderr, "p%d: init_mpi_datatypes: could not create datatypes\n",
system->my_rank );
fprintf( stderr, "p%d: mpi_data couldn't be initialized! terminating.\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
}
fprintf( stderr, "p%d: initialized mpi datatypes\n", system->my_rank );
if ( Init_Lists( system, control, workspace, lists, msg ) == FAILURE )
{
fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
fprintf( stderr, "p%d: system could not be initialized! terminating.\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
fprintf( stderr, "p%d: initialized lists\n", system->my_rank );
if ( Init_Output_Files(system, control, out_control, mpi_data, msg) == FAILURE)
{
fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
fprintf( stderr, "p%d: could not open output files! terminating...\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
}
fprintf( stderr, "p%d: output files opened\n", system->my_rank );
Kurt A. O'Hearn
committed
if ( Init_Lookup_Tables( system, control, workspace->Tap, mpi_data, msg ) == FAILURE )
{
fprintf( stderr, "p%d: %s\n", system->my_rank, msg );
fprintf( stderr, "p%d: couldn't create lookup table! terminating.\n",
system->my_rank );
MPI_Abort( MPI_COMM_WORLD, CANNOT_INITIALIZE );
}
fprintf( stderr, "p%d: initialized lookup tables\n", system->my_rank );
fprintf( stderr, "p%d: initialized force functions\n", system->my_rank );
/*#if defined(TEST_FORCES)
Init_Force_Test_Functions();
fprintf(stderr,"p%d: initialized force test functions\n",system->my_rank);
#endif*/
}