Skip to content

Commit

Permalink
Fixes the length_check and change files that were flagged
Browse files Browse the repository at this point in the history
  • Loading branch information
Bcorde5 committed Jul 29, 2015
1 parent 0a9c866 commit 07be225
Show file tree
Hide file tree
Showing 43 changed files with 287 additions and 150 deletions.
74 changes: 50 additions & 24 deletions examples/1d_hydro/1d_hydro_upwind.cpp
Expand Up @@ -92,14 +92,16 @@ struct cell{
//
// cell c1, c2;
// c1 = c2; // invoked by this syntax
// Bryce: I think i'd like to change this so the "calculated" is not copied in the assignment op
// Bryce: I think i'd like to change this so the "calculated"
// is not copied in the assignment op
cell& operator=(
cell const& other
)
{
// first, we lock both the mutex of this cell, and the mutex of the other
// cell
// boost::lock_guard<hpx::lcos::local::mutex> this_lock(mtx), other_lock(other.mtx);
// boost::lock_guard<hpx::lcos::local::mutex>
// this_lock(mtx), other_lock(other.mtx);

rho = other.rho;
mom = other.mom;
Expand Down Expand Up @@ -177,7 +179,8 @@ struct time_element{


// Object to store the Fluid seperated in cell and computed by a Time Zone of tie Steps
// Will store the 2d grid created by the division of the fluid into cells and the computation over time
// Will store the 2d grid created by the division
// of the fluid into cells and the computation over time
// Will be able to Retrieve,remove,add a timestep to the grid

class One_Dimension_Grid
Expand All @@ -190,7 +193,8 @@ class One_Dimension_Grid
void addNewTimeStep();

public:
std::vector<time_element> time_array;//pointer to the Grid we will create whden the user starts a simulation
std::vector<time_element> time_array;
//pointer to the Grid we will create whden the user starts a simulation

};
void One_Dimension_Grid::remove_bottom_time_step()
Expand Down Expand Up @@ -246,7 +250,8 @@ double timestep_size(boost::uint64_t timestep)
grid.time_array.at(timestep).dt = dx*0.033;// this should be fine unless
// the initial conditions are changed
if(timestep>0&&grid.time_array.at(timestep-1).computed)
grid.time_array[timestep].physics_time = (grid.time_array.at(timestep-1).physics_time+grid.time_array.at(timestep).dt);
grid.time_array[timestep].physics_time = (grid.time_array.at(timestep-1)
.physics_time+grid.time_array.at(timestep).dt);
// time_array[timestep].dt = cfl_predict_factor*dt_cfl;
else if(timestep==0)
{
Expand All @@ -258,11 +263,13 @@ double timestep_size(boost::uint64_t timestep)
// send back the compute futures for the whole grid
// n_predict timesteps previous to the one we want to decide
// the timestep for
// cout << (boost::format("pushing back futures for ts calc, ts=%1% \n") % timestep) << flush;
// cout << (boost::format
// ("pushing back futures for ts calc, ts=%1% \n") % timestep) << flush;
if(timestep>=n_predict)
{
for (boost::uint64_t i=0;i<nx;i++)
grid.time_array.at(timestep).fluid_future.push_back(async<compute_action>(here,timestep-n_predict,i));
grid.time_array.at(timestep).fluid_future.push_back
(async<compute_action>(here,timestep-n_predict,i));
}

double dt_cfl = 1000.0;
Expand Down Expand Up @@ -324,26 +331,31 @@ double timestep_size(boost::uint64_t timestep)
,
1.25*grid.time_array.at(timestep-1).dt);

// cout << (boost::format("timestep = %1%, dt = %2%\n") % timestep % time_array[timestep].dt) << flush;
// cout << (boost::format
// ("timestep = %1%, dt = %2%\n") % timestep % time_array[timestep].dt) << flush;
return grid.time_array[timestep].dt;
}

cell compute(boost::uint64_t timestep, boost::uint64_t location)
{
boost::lock_guard<hpx::lcos::local::mutex> l(grid.time_array.at(timestep).fluid.at(location).mtx);
boost::lock_guard<hpx::lcos::local::mutex>
l(grid.time_array.at(timestep).fluid.at(location).mtx);

// if it is already computed then just return the value
if (grid.time_array.at(timestep).fluid.at(location).computed == true)
return grid.time_array.at(timestep).fluid.at(location);

// cout << (boost::format("computing new value, loc = %1%,ts=%2% \n") % location % timestep) << flush;
// cout << (boost::format
// ("computing new value, loc = %1%,ts=%2% \n") % location % timestep) << flush;

//initial values
if (timestep == 0)
{
// cout << (boost::format("calling initial_sod, loc = %1%,ts=%2% \n") % location % timestep) << flush;
// cout << (boost::format
// ("calling initial_sod, loc = %1%,ts=%2% \n") % location % timestep) << flush;
grid.time_array.at(timestep).fluid.at(location) = initial_sod(location);
// cout << (boost::format("returning value, loc = %1%,ts=%2% \n") % location % timestep) << flush;
// cout << (boost::format
// ("returning value, loc = %1%,ts=%2% \n") % location % timestep) << flush;
grid.time_array.at(timestep).fluid.at(location).computed = true;
return grid.time_array.at(timestep).fluid.at(location);
}
Expand Down Expand Up @@ -459,11 +471,13 @@ cell compute(boost::uint64_t timestep, boost::uint64_t location)
//cout << (boost::format("gas is shocking!\n")) << flush;
now.tau = pow(e_internal,(1.0/fluid_gamma));
}
// cout << (boost::format("computing new value, loc = %1%, ts= %2%\n") % location % timestep) << flush;
// cout << (boost::format
// ("computing new value, loc = %1%, ts= %2%\n") % location % timestep) << flush;
// cout << (boost::format("loc = %1%, rho = %2%\n") % location % left.rho) << flush;
// cout << (boost::format("loc = %1%, mom = %2%\n") % location % left.mom) << flush;
// cout << (boost::format("loc = %1%, etot = %2%\n") % location % left.etot) << flush;
// cout << (boost::format("loc = %1%, vel left = %2%\n") % location % velocity_left) << flush;
// cout << (boost::format
// ("loc = %1%, vel left = %2%\n") % location % velocity_left) << flush;

// if (location == 1)
// cout << (boost::format("calculating timestep = %1%\n") % timestep) << flush;
Expand All @@ -473,7 +487,8 @@ cell compute(boost::uint64_t timestep, boost::uint64_t location)
bool time_step_complete= false;
for(boost::uint64_t i=0;i<nx;i++)
{
if(grid.time_array[0].fluid.at(i).computed&&grid.time_array[1].fluid.at(i).computed)
if(grid.time_array[0].fluid.at(i).computed
&& grid.time_array[1].fluid.at(i).computed)
time_step_complete=true;
else
time_step_complete=false;
Expand Down Expand Up @@ -535,7 +550,8 @@ cell initial_sod(boost::uint64_t location)
cell_here.tau = pow(e_internal,(1.0/fluid_gamma));
cell_here.etot = e_internal; // ONLY true when mom=0, not in general!

// cout << (boost::format("returning from initial_sod, loc = %1%\n") % location) << flush;
// cout << (boost::format("returning from initial_sod, loc = %1%\n")
// % location) << flush;
return cell_here;
}

Expand All @@ -545,7 +561,8 @@ cell get_analytic(double x_here, double time)

// values for analytic solution come from Patrick Motl's dissertation

// cout << (boost::format("calculating analytic... x=%1% t=%2%\n") % x_here % time) << flush;
// cout << (boost::format("calculating analytic... x=%1% t=%2%\n")
// % x_here % time) << flush;

double x_0 = -0.1;

Expand All @@ -565,7 +582,8 @@ cell get_analytic(double x_here, double time)
double p_4 = 0.3031;
double p_5 = 0.1;

double W = c_5*std::pow( (1.0+(fluid_gamma+1.0)*(p_4 - p_5)/(2.0*fluid_gamma*p_5)), 0.5 );
double W = c_5*std::pow( (1.0+(fluid_gamma+1.0)*(p_4 - p_5)
/(2.0*fluid_gamma*p_5)), 0.5 );

double x_shock = x_0 + W*time;

Expand All @@ -581,7 +599,8 @@ cell get_analytic(double x_here, double time)
double exponent = 2.0/(fluid_gamma-1.0);
output.rho = std::pow( (1.0-(fluid_gamma-1.0)*w_2/(2.0*c_1)), exponent);
output.mom = output.rho*w_2;
output.tau = pow( (1.0-0.5*(fluid_gamma-1)*(w_2/c_1)), exponent)/pow(fluid_gamma-1.0,1.0/fluid_gamma);
output.tau = pow( (1.0-0.5*(fluid_gamma-1)*(w_2/c_1)), exponent)
/pow(fluid_gamma-1.0,1.0/fluid_gamma);
}
else if (x_here < x_contact) // region 3
{
Expand Down Expand Up @@ -665,8 +684,11 @@ int hpx_main(
double tauoverrho = pow(e_internal,(1.0/fluid_gamma))/n.rho;
// double e_internal2 = pow(n.tau,fluid_gamma);

outfile << (boost::format("%1% %2% %3% %4% %5%\n") % x_here % n.rho % pressure_here % tauoverrho % velocity_here) << flush; });
// outfile << (boost::format("%1% %2% %3% %4% %5%\n") % x_here % n.rho % pressure_here % e_internal % e_internal2) << flush; });
outfile << (boost::format("%1% %2% %3% %4% %5%\n")
% x_here % n.rho % pressure_here % tauoverrho % velocity_here)
<< flush; });
// outfile << (boost::format("%1% %2% %3% %4% %5%\n")
// % x_here % n.rho % pressure_here % e_internal % e_internal2) << flush; });

outfile.close();

Expand All @@ -677,11 +699,13 @@ int hpx_main(
// writing the "time array" to a file
grid.time_array[0].elapsed_time = grid.time_array[0].dt;
for (i=1;i<nt;i++)
grid.time_array[i].elapsed_time = grid.time_array[i-1].elapsed_time + grid.time_array[i].dt;
grid.time_array[i].elapsed_time =
grid.time_array[i-1].elapsed_time + grid.time_array[i].dt;

for (i =0;i<nt;i++)
{
outfile2 << (boost::format("%1% %2% %3%\n") % i % grid.time_array[i].dt % grid.time_array[i].elapsed_time) << flush;
outfile2 << (boost::format("%1% %2% %3%\n")
% i % grid.time_array[i].dt % grid.time_array[i].elapsed_time) << flush;
}
outfile2.close();

Expand All @@ -696,7 +720,9 @@ int hpx_main(
double velocity_here = analytic.mom/analytic.rho;
double tauoverrho = analytic.tau/analytic.rho;
double pressure_here = get_pressure(analytic);
analytic_file << (boost::format("%1% %2% %3% %4% %5%\n") % x_here % analytic.rho % pressure_here % tauoverrho % velocity_here) << flush;
analytic_file << (boost::format("%1% %2% %3% %4% %5%\n")
% x_here % analytic.rho % pressure_here % tauoverrho % velocity_here)
<< flush;
total_mass += grid.time_array[nt-1].fluid[i].rho*dx;
}
analytic_file.close();
Expand Down
3 changes: 2 additions & 1 deletion examples/1d_stencil/1d_stencil_3.cpp
Expand Up @@ -125,7 +125,8 @@ struct stepper
space& next = U[(t + 1) % 2];

for (std::size_t i = 0; i != np; ++i)
next[i] = heat_part(current[idx(i, -1, np)], current[i], current[idx(i, +1, np)]);
next[i] =
heat_part(current[idx(i, -1, np)], current[i], current[idx(i, +1, np)]);
}

// Return the solution at time-step 'nt'.
Expand Down
3 changes: 2 additions & 1 deletion examples/1d_stencil/1d_stencil_3_omp.cpp
Expand Up @@ -142,7 +142,8 @@ struct stepper
// Visual Studio requires OMP loop variables to be signed :/
# pragma omp for schedule(static)
for (boost::int64_t i = 0; i < (boost::int64_t)np; ++i)
next[i] = heat_part(current[idx(i-1, np)], current[i], current[idx(i+1, np)]);
next[i] =
heat_part(current[idx(i-1, np)], current[i], current[idx(i+1, np)]);
}
}
// Return the solution at time-step 'nt'.
Expand Down
12 changes: 8 additions & 4 deletions examples/1d_stencil/1d_stencil_8.cpp
Expand Up @@ -321,8 +321,10 @@ struct stepper_server : hpx::components::simple_component_base<stepper_server>
stepper_server() {}

stepper_server(std::size_t nl)
: left_(hpx::find_id_from_basename(stepper_basename, idx(hpx::get_locality_id(), -1, nl))),
right_(hpx::find_id_from_basename(stepper_basename, idx(hpx::get_locality_id(), +1, nl))),
: left_(hpx::find_id_from_basename
(stepper_basename, idx(hpx::get_locality_id(), -1, nl))),
right_(hpx::find_id_from_basename
(stepper_basename, idx(hpx::get_locality_id(), +1, nl))),
U_(2)
{
}
Expand Down Expand Up @@ -411,9 +413,11 @@ struct stepper : hpx::components::client_base<stepper, stepper_server>

// construct new instances/wrap existing steppers from other localities
stepper()
: base_type(hpx::new_<stepper_server>(hpx::find_here(), hpx::get_num_localities_sync()))
: base_type(hpx::new_<stepper_server>
(hpx::find_here(), hpx::get_num_localities_sync()))
{
hpx::register_id_with_basename(stepper_basename, get_id(), hpx::get_locality_id());
hpx::register_id_with_basename
(stepper_basename, get_id(), hpx::get_locality_id());
}

stepper(hpx::future<hpx::id_type> && id)
Expand Down
Expand Up @@ -63,7 +63,8 @@ namespace examples { namespace stubs
static void
add_sync(hpx::naming::id_type const& gid, T arg)
{
typedef typename server::template_function_accumulator::add_action<T> action_type;
typedef typename server::template_function_accumulator::add_action<T>
action_type;
hpx::async<action_type>(gid, arg).get();
}

Expand Down
48 changes: 32 additions & 16 deletions examples/diskperf/diskperf_ofs_pxfs_action.cpp
Expand Up @@ -173,8 +173,10 @@ RESULT write_files_test(ofs_test_info_type ofs_test_info, int proc)
boost::shared_array<ssize_t> num_written_array(new ssize_t[count * wfiles]);
std::vector<hpx::lcos::future<int> > futures;

boost::shared_array<int_promise_type> int_promise_array(new int_promise_type[count * wfiles]);
boost::shared_array<promise_rt_ptr_type> promise_rt_ptr_array(new promise_rt_ptr_type[count * wfiles]);
boost::shared_array<int_promise_type>
int_promise_array(new int_promise_type[count * wfiles]);
boost::shared_array<promise_rt_ptr_type>
promise_rt_ptr_array(new promise_rt_ptr_type[count * wfiles]);

srand((unsigned)time(0));
for(ssize_t c = 0; c < bufsiz; c++)
Expand All @@ -189,7 +191,8 @@ RESULT write_files_test(ofs_test_info_type ofs_test_info, int proc)
int oflags;

oflags = O_WRONLY|O_CREAT;
sprintf(filename, "%s/loc_%d_file%d.%ld", ofspath.c_str(), hpx::get_locality_id(), proc, i);
sprintf(filename, "%s/loc_%d_file%d.%ld",
ofspath.c_str(), hpx::get_locality_id(), proc, i);

int_promise_type open_p;
std::ostringstream sstream;
Expand Down Expand Up @@ -253,8 +256,10 @@ RESULT write_files_test(ofs_test_info_type ofs_test_info, int proc)
}

r.real = ((double) end - (double) start) / (double) sysconf(_SC_CLK_TCK);
r.user = ((double) t2.tms_utime - (double) t1.tms_utime) / (double) sysconf(_SC_CLK_TCK);
r.sys = ((double) t2.tms_stime - (double) t1.tms_stime) / (double) sysconf(_SC_CLK_TCK);
r.user = ((double) t2.tms_utime - (double) t1.tms_utime)
/ (double) sysconf(_SC_CLK_TCK);
r.sys = ((double) t2.tms_stime - (double) t1.tms_stime)
/ (double) sysconf(_SC_CLK_TCK);

for(uint64_t i=0; i<wfiles; i++)
{
Expand Down Expand Up @@ -299,8 +304,10 @@ RESULT read_files_test(ofs_test_info_type ofs_test_info, int proc)
boost::shared_array<ssize_t> num_read_array(new ssize_t[count * rfiles]);
std::vector<hpx::lcos::future<int> > futures;

boost::shared_array<int_promise_type> int_promise_array(new int_promise_type[count * rfiles]);
boost::shared_array<promise_rt_ptr_type> promise_rt_ptr_array(new promise_rt_ptr_type[count * rfiles]);
boost::shared_array<int_promise_type>
int_promise_array(new int_promise_type[count * rfiles]);
boost::shared_array<promise_rt_ptr_type>
promise_rt_ptr_array(new promise_rt_ptr_type[count * rfiles]);

start = times(&t1);

Expand All @@ -311,7 +318,8 @@ RESULT read_files_test(ofs_test_info_type ofs_test_info, int proc)
int oflags;

oflags = O_RDONLY;
sprintf(filename, "%s/loc_%d_file%d.%ld", ofspath.c_str(), hpx::get_locality_id(), proc, i);
sprintf(filename, "%s/loc_%d_file%d.%ld",
ofspath.c_str(), hpx::get_locality_id(), proc, i);

int_promise_type open_p;
std::ostringstream sstream;
Expand Down Expand Up @@ -376,8 +384,10 @@ RESULT read_files_test(ofs_test_info_type ofs_test_info, int proc)


r.real = ((double) end - (double) start) / (double) sysconf(_SC_CLK_TCK);
r.user = ((double) t2.tms_utime - (double) t1.tms_utime) / (double) sysconf(_SC_CLK_TCK);
r.sys = ((double) t2.tms_stime - (double) t1.tms_stime) / (double) sysconf(_SC_CLK_TCK);
r.user = ((double) t2.tms_utime - (double) t1.tms_utime)
/ (double) sysconf(_SC_CLK_TCK);
r.sys = ((double) t2.tms_stime - (double) t1.tms_stime)
/ (double) sysconf(_SC_CLK_TCK);


for(uint64_t i=0; i<rfiles; i++)
Expand Down Expand Up @@ -425,7 +435,8 @@ int hpx_main(variables_map& vm)
return hpx::finalize();
}

hpx::cout<<"Disk performance test with OrangeFS PXFS APIs and HPX actions."<<hpx::endl;
hpx::cout<<
"Disk performance test with OrangeFS PXFS APIs and HPX actions."<<hpx::endl;

if(vm.count("pvfs2tab"))
{
Expand Down Expand Up @@ -511,11 +522,13 @@ int hpx_main(variables_map& vm)

if(rfiles > 0)
{
hpx::cout << (boost::format("%1% localities each has %2% threads, Reading %3% files") % localities.size() % procs % rfiles);
hpx::cout << (boost::format("%1% localities each has %2% threads,
Reading %3% files") % localities.size() % procs % rfiles);
}
else
{
hpx::cout << (boost::format("%1% localities each has %2% threads, Writing %3% files") % localities.size() % procs % wfiles);
hpx::cout << (boost::format("%1% localities each has %2% threads,
Writing %3% files") % localities.size() % procs % wfiles);
}

char const* fmt = " with count %1% x buffer size %2%M: \n";
Expand Down Expand Up @@ -546,7 +559,8 @@ int hpx_main(variables_map& vm)
if(rfiles > 0)
{
hpx::cout<<(boost::format("Aggregate Reading Throughput: %1% [MB/s]\n") %
(localities.size() * procs * rfiles * count * bufsiz / tt / (1024*1024)));
(localities.size() * procs * rfiles
* count * bufsiz / tt / (1024*1024)));
hpx::cout<<(boost::format("\t Max Throughput per thread: %1% [MB/s]\n") %
(rfiles * count * bufsiz / min_time / (1024*1024)));
hpx::cout<<(boost::format("\t Min Throughput per thread: %1% [MB/s]\n") %
Expand All @@ -555,7 +569,8 @@ int hpx_main(variables_map& vm)
else
{
hpx::cout<<(boost::format("Aggregate Writing Throughput: %1% [MB/s]\n") %
(localities.size() * procs * wfiles * count * bufsiz / tt / (1024*1024)));
(localities.size() * procs * wfiles
* count * bufsiz / tt / (1024*1024)));
hpx::cout<<(boost::format("\t Max Throughput per thread: %1% [MB/s]\n") %
(wfiles * count * bufsiz / min_time / (1024*1024)));
hpx::cout<<(boost::format("\t Min Throughput per thread: %1% [MB/s]\n") %
Expand All @@ -578,7 +593,8 @@ int hpx_main(variables_map& vm)
{
for(uint64_t i = 0; i < fileno; ++i)
{
sprintf(filename, "%s/loc_%d_file%d.%ld", ofspath.c_str(), loc, proc, i);
sprintf(filename, "%s/loc_%d_file%d.%ld",
ofspath.c_str(), loc, proc, i);
pvfs_unlink(filename);
}
}
Expand Down

0 comments on commit 07be225

Please sign in to comment.