Skip to content

Commit

Permalink
Merge branch 'dev_debug' of https://github.com/gunrock/gunrock into d…
Browse files Browse the repository at this point in the history
…ev_debug
  • Loading branch information
sgpyc committed Apr 25, 2016
2 parents 57653e1 + 1bb4dd1 commit 380efc7
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 4 deletions.
32 changes: 31 additions & 1 deletion gunrock/util/info.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,17 @@ public:
if (args.CheckCmdLineFlag("src-seed"))
args.GetCmdLineArgument("src-seed", src_seed);
info["source_seed"] = src_seed;
} else if (source_type.compare("list") == 0)
{
if (!args.CheckCmdLineFlag("quiet"))
printf("Using user specified source vertex for each run\n");
info["source_type"] = "list";
} else
{
args.GetCmdLineArgument("src", source);
info["source_type"] = "user-defined";
}
info["source_list"] = GetSourceList(args);
info["source_vertex"] = (int64_t)source;
if (!args.CheckCmdLineFlag("quiet"))
{
Expand All @@ -265,7 +271,7 @@ public:
args.GetCmdLineArgument("grid-size", grid_size);
info["max_grid_size"] = grid_size;
}
if (args.CheckCmdLineFlag("iteration-num"))
if (args.CheckCmdLineFlag("iteration-num") && !args.CheckCmdLineFlag("source-list"))
{
args.GetCmdLineArgument("iteration-num", num_iters);
info["num_iteration"] = num_iters;
Expand Down Expand Up @@ -607,6 +613,30 @@ public:
return device_list;
}

/**
* @brief Utility function to parse source node list.
*
* @param[in] args Command line arguments.
*
* \return json_spirit::mArray object contain source nodes used.
*/
json_spirit::mArray GetSourceList(util::CommandLineArgs &args)
{
json_spirit::mArray source_list; // return mArray
std::vector<int> srcs; // temp storage
if (args.CheckCmdLineFlag("source-list")) // parse command
{
args.GetCmdLineArguments<int>("source-list", srcs);
int num_sources = srcs.size();
info["num_iteration"] = num_sources; // update number of devices
for (int i = 0; i < num_sources; i++)
{
source_list.push_back(srcs[i]);
}
}
return source_list;
}

/**
* @brief Writes the JSON structure to STDOUT (command line --json).
*/
Expand Down
19 changes: 16 additions & 3 deletions tests/bfs/test_bfs.cu
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ void Usage()
"[--instrumented] Keep kernels statics [Default: Disable].\n"
" total_queued, search_depth and barrier duty.\n"
" (a relative indicator of load imbalance.)\n"
"[--src=<Vertex-ID|randomize|largestdegree>]\n"
"[--src=<Vertex-ID|largestdegree|randomize|randomize2|list>]\n"
" Begins traversal from the source (Default: 0).\n"
" If randomize: from a random source vertex.\n"
" If largestdegree: from largest degree vertex.\n"
" If randomize: from a random source vertex.\n"
" If randomize2: from a different random source vertex for each iteration.\n"
" If list: need to provide a source list through --source_list=n0,n1,...,nk\n"
"[--quick] Skip the CPU reference validation process.\n"
"[--mark-pred] Keep both label info and predecessor info.\n"
"[--disable-size-check] Disable frontier queue size check.\n"
Expand Down Expand Up @@ -332,7 +334,7 @@ cudaError_t RunTests(Info<VertexId, SizeT, Value> *info)
cpu_timer.Start();
json_spirit::mArray device_list = info->info["device_list"].get_array();
int* gpu_idx = new int[num_gpus];
for (int i = 0; i < num_gpus; i++) gpu_idx[i] = device_list[i].get_int();
for (int i = 0; i < num_gpus; i++) gpu_idx[i] = device_list[i].get_int();

// TODO: remove after merge mgpu-cq
ContextPtr *context = (ContextPtr*) info->context;
Expand Down Expand Up @@ -423,6 +425,8 @@ cudaError_t RunTests(Info<VertexId, SizeT, Value> *info)
}
if (!quiet_mode)
printf("Using traversal-mode %s\n", traversal_mode.c_str());

json_spirit::mArray source_list = info->info["source_list"].get_array();
for (int iter = 0; iter < iterations; ++iter)
{
if (src_type == "random2")
Expand All @@ -434,6 +438,15 @@ cudaError_t RunTests(Info<VertexId, SizeT, Value> *info)
if (graph -> row_offsets[src] != graph -> row_offsets[src+1])
src_valid = true;
}
} else if (src_type == "list")
{
if (source_list.size() == 0) {
if (!quiet_mode)
printf("No source list found. Use 0 as source.\n");
src = 0;
} else {
src = source_list[iter].get_int();
}
}

if (retval = util::GRError(problem->Reset(
Expand Down

0 comments on commit 380efc7

Please sign in to comment.