Skip to content

Commit

Permalink
some additions for running UQ, not yet tested
Browse files Browse the repository at this point in the history
  • Loading branch information
jjwilke committed Mar 4, 2016
1 parent e3b1245 commit 218b704
Show file tree
Hide file tree
Showing 52 changed files with 251 additions and 140 deletions.
2 changes: 1 addition & 1 deletion bin/top_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ try_top_info_main(int argc, char **argv)
}

sprockit::sim_parameters* params = new sprockit::sim_parameters(oo.configfile);
sstmac_env::params = params;
sstmac::env::params = params;
if (oo.params) {
// there were command-line overrides
oo.params->combine_into(params);
Expand Down
2 changes: 1 addition & 1 deletion configurations/hopper_amm4.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ include hopper_amm.ini
# Network parameters
congestion_model = packet_flow
amm_model = amm4
#router = minimal
router = minimal
netlink_radix = 2

5 changes: 3 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,10 @@ AC_CONFIG_FILES([
sstmac/libraries/sumi/Makefile
sstmac/libraries/pthread/Makefile
sstmac/libraries/sockets/Makefile
sstmac/skeletons/Makefile
sstmac/libraries/Makefile
sstmac/libraries/machines/Makefile
sstmac/libraries/uq/Makefile
sstmac/libraries/Makefile
sstmac/skeletons/Makefile
sstmac/software/Makefile
sstmac/hardware/Makefile
sstmac/sst_core/Makefile
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/classes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ \subsection{Usage}
Inside the main function, we create an object of type \inlinecode{actor}.

\begin{CppCode}
actor* the_guy = actor_factory::get_param("actor_name", sstmac_env::params);
actor* the_guy = actor_factory::get_param("actor_name", sstmac::env::params);
the_guy->act();
return 0;
\end{CppCode}
Expand Down
12 changes: 5 additions & 7 deletions skeletons/load_imbalance/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ load_imbalance_main(int argc, char **argv)
MPI_Comm_size(MPI_COMM_WORLD, &nproc);

int seed;
//seed = sstmac_env::params->get_optional_int_param("os_noise_seed", 145) ^ me + me;
//RNG::UniformInteger* noise_rng = RNG::SHR3::construct(seed);

int niter = sstmac_env::params->get_optional_int_param("num_iterations", 10);
double min_comp_time = sstmac_env::params->get_time_param("min_comp_time");
double max_comp_time = sstmac_env::params->get_time_param("max_comp_time");
int niter = env::params->get_optional_int_param("num_iterations", 10);
double min_comp_time = env::params->get_time_param("min_comp_time");
double max_comp_time = env::params->get_time_param("max_comp_time");
double comp_time_range = max_comp_time - min_comp_time;
bool reshuffle_work = sstmac_env::params->get_optional_bool_param("reshuffle_work", true);
seed = (sstmac_env::params->get_optional_int_param("comp_time_seed", 911) << (me + 5)) << (me + 3) + me;
bool reshuffle_work = env::params->get_optional_bool_param("reshuffle_work", true);
seed = (env::params->get_optional_int_param("comp_time_seed", 911) << (me + 5)) << (me + 3) + me;

//std::cout << seed << std::endl;
RNG::UniformInteger* comp_rng = RNG::SHR3::construct(seed);
Expand Down
2 changes: 1 addition & 1 deletion skeletons/location_trace/print_location_trace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sstmac_register_app(print_location_trace)
int
print_location_trace_main(int argc, char **argv)
{
std::string filename = sstmac_env::params->get_param("trace_file");
std::string filename = env::params->get_param("trace_file");
location_trace* trace = new location_trace;
trace->activate(filename);
timestamp created;
Expand Down
8 changes: 4 additions & 4 deletions skeletons/lulesh/luleshapp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ namespace luleshmodel
}

// calculate data layout
int nx = sstmac::sstmac_env::params->get_int_param("lulesh_nx");
int ny = sstmac::sstmac_env::params->get_int_param("lulesh_ny");
int nz = sstmac::sstmac_env::params->get_int_param("lulesh_nz");
int nx = sstmac::env::params->get_int_param("lulesh_nx");
int ny = sstmac::env::params->get_int_param("lulesh_ny");
int nz = sstmac::env::params->get_int_param("lulesh_nz");

int iter_max = sstmac::sstmac_env::params->get_int_param("lulesh_iter");
int iter_max = sstmac::env::params->get_int_param("lulesh_iter");

if (rank == 0)
{
Expand Down
2 changes: 1 addition & 1 deletion skeletons/minimd/lib_compute_minimd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace mini

{
id_ = id;
using_loops_ = sstmac::sstmac_env::params->get_bool_param(
using_loops_ = sstmac::env::params->get_bool_param(
"lib_compute_loops_enable");
if (!using_loops_)
{
Expand Down
37 changes: 0 additions & 37 deletions skeletons/traffic_matrix/Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion sprockit
24 changes: 12 additions & 12 deletions sstmac/common/c_params.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,85 +19,85 @@ namespace sstmac {
get_bool_param(const char* str)
{
std::string p(str);
return sstmac_env::params->get_bool_param(str);
return sstmac::env::params->get_bool_param(str);
}
extern "C" bool
get_optional_bool_param(const char* str, bool val)
{
std::string p(str);
return sstmac_env::params->get_optional_bool_param(str, val);
return sstmac::env::params->get_optional_bool_param(str, val);
}*/

extern "C" int
get_int_param(char* str)
{
std::string p(str);
return sstmac_env::params->get_int_param(str);
return sstmac::env::params->get_int_param(str);
}

extern "C" int
get_optional_int_param(char* str, int val)
{
std::string p(str);
return sstmac_env::params->get_optional_int_param(str, val);
return sstmac::env::params->get_optional_int_param(str, val);
}

extern "C" long
get_long_param(char* str)
{
std::string p(str);
return sstmac_env::params->get_long_param(str);
return sstmac::env::params->get_long_param(str);
}

extern "C" long
get_optional_long_param(char* str, long val)
{
std::string p(str);
return sstmac_env::params->get_optional_long_param(str, val);
return sstmac::env::params->get_optional_long_param(str, val);
}

extern "C" double
get_double_param(char* str)
{
std::string p(str);
return sstmac_env::params->get_double_param(str);
return sstmac::env::params->get_double_param(str);
}

extern "C" double
get_optional_double_param(char* str, double val)
{
std::string p(str);
return sstmac_env::params->get_optional_double_param(str, val);
return sstmac::env::params->get_optional_double_param(str, val);
}

extern "C" const char*
get_param(char* str)
{
std::string p(str);
return sstmac_env::params->get_param(str).c_str();
return sstmac::env::params->get_param(str).c_str();
}

extern "C" const char*
get_optional_param(char* str, char* val)
{
std::string p(str);
std::string sval(val);
return sstmac_env::params->get_optional_param(str, sval).c_str();
return sstmac::env::params->get_optional_param(str, sval).c_str();
}

extern "C" bool
get_bool_param(char* str)
{
std::string p(str);
return sstmac_env::params->get_bool_param(str);
return sstmac::env::params->get_bool_param(str);
}

extern "C" bool
get_optional_bool_param(char* str, bool val)
{
std::string p(str);
return sstmac_env::params->get_optional_bool_param(str, val);
return sstmac::env::params->get_optional_bool_param(str, val);
}

}
Expand Down
4 changes: 2 additions & 2 deletions sstmac/common/sstmac_env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <sstmac/common/sstmac_env.h>

namespace sstmac {
sprockit::sim_parameters* sstmac_env::params = 0;
parallel_runtime* sstmac_env::rt = 0;
sprockit::sim_parameters* sstmac::env::params = 0;
parallel_runtime* sstmac::env::rt = 0;
}

2 changes: 1 addition & 1 deletion sstmac/common/sstmac_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace sstmac {
/**
* This class holds some global information about the simulation
*/
class sstmac_env
class env
{
public:
static sprockit::sim_parameters* params;
Expand Down
4 changes: 0 additions & 4 deletions sstmac/hardware/packet_flow/packet_flow_nic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,11 @@ packet_flow_netlink::connect(int src_outport, int dst_inport, connection_type_t
{
case connectable::input:
{
::printf("On %d, connecting input %d:%d to %s\n",
int(id_), src_outport, dst_inport, conn->to_string().c_str());
block_->set_input(dst_inport, src_outport, conn);
break;
}
case connectable::output:
{
::printf("On %d, connecting output %d:%d to %s\n",
int(id_), src_outport, dst_inport, conn->to_string().c_str());
block_->set_output(src_outport, dst_inport, conn);
packet_flow_component* comp = safe_cast(packet_flow_component, mod);
debug_printf(sprockit::dbg::packet_flow_config | sprockit::dbg::packet_flow,
Expand Down
1 change: 1 addition & 0 deletions sstmac/install/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ libsstmac_la_LIBADD = \
../common/libsstmac_common.la \
../dumpi_util/libsstmac_dumpi.la \
../hardware/libsstmac_hw.la \
../libraries/uq/libsstmac_uq.la \
../libraries/machines/libsstmac_machines.la \
../libraries/pthread/libsstmac_pthread.la \
../libraries/sockets/libsstmac_sockets.la \
Expand Down
3 changes: 2 additions & 1 deletion sstmac/libraries/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ machines \
blas \
sumi \
sockets \
pthread
pthread \
uq

if WITH_DEFAULT_MPI
SUBDIRS += mpi
Expand Down
23 changes: 23 additions & 0 deletions sstmac/libraries/uq/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# This file is part of SST/macroscale:
# The macroscale architecture simulator from the SST suite.
# Copyright (c) 2009 Sandia Corporation.
# This software is distributed under the BSD License.
# Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
# the U.S. Government retains certain rights in this software.
# For more information, see the LICENSE file in the top
# SST/macroscale directory.
#

include $(top_srcdir)/Makefile.common

noinst_LTLIBRARIES = libsstmac_uq.la

libsstmac_uq_la_SOURCES = \
uq.cc

library_includedir=$(includedir)/sstmac/libraries/uq

nobase_library_include_HEADERS = \
uq.h

64 changes: 64 additions & 0 deletions sstmac/libraries/uq/uq.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include <sstmac/libraries/uq/uq.h>
#include <sstmac/main/driver.h>
#include <sprockit/errors.h>

using namespace sstmac;

extern "C" void*
sstmac_uq_init(int argc, char** argv)
{
SimulationQueue* q = new SimulationQueue;
q->init(argc, argv);
return q;
}

extern "C" void
sstmac_uq_finalize(void* queue)
{
SimulationQueue* q = (SimulationQueue*) queue;
delete q;
}

static void
wait_sims(Simulation** sims, int nsims, double** results, int nresults)
{
for (int i=0; i < nsims; ++i){
sims[i]->wait();
results[i] = sims[i]->results();
if (sims[i]->numResults() != nresults){
spkt_abort_printf("got wrong number of results: expected %d, got %d",
nresults, sims[i]->numResults());
}
delete sims[i];
}
}

extern "C" void
sstmac_uq_run(void* queue,
int njobs, int nparams, int nresults, int max_nthread,
const char* param_names[], double* param_values[],
double* results[])
{
SimulationQueue* q = (SimulationQueue*) queue;
sprockit::sim_parameters params;
Simulation* sims[max_nthread];

int num_running = 0;

for (int j=0; j < njobs; ++j, ++num_running){
if (num_running == max_nthread){
int result_offset = j - max_nthread;
wait_sims(sims, max_nthread, results+result_offset, nresults);
num_running = 0;
}
double* param_vals = param_values[j];
for (int param=0; param < nparams; ++param){
params[param_names[param]] = param_vals[param];
}
sims[num_running++] = q->fork(params);
}
int result_offset = njobs - num_running;
wait_sims(sims, num_running, results+result_offset, nresults);
}


16 changes: 16 additions & 0 deletions sstmac/libraries/uq/uq.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

#ifdef __cplusplus
extern "C" {
#endif
void* sstmac_uq_init(int argc, char** argv);

void sstmac_uq_run(void* queue,
int njobs, int nparams, int nresults, int max_nthread,
const char* param_names[], double* param_values[],
double* results[]);

void sstmac_uq_finalize(void* queue);
#ifdef __cplusplus
}
#endif

Loading

0 comments on commit 218b704

Please sign in to comment.