Skip to content

Commit

Permalink
fix valgrind errors
Browse files Browse the repository at this point in the history
  • Loading branch information
1duo committed Aug 7, 2015
1 parent 4813056 commit b8245ab
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 72 deletions.
24 changes: 11 additions & 13 deletions gunrock/app/bc/bc_app.cu
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ using namespace gunrock::oprtr;
using namespace gunrock::app::bc;

/**
* @brief Test_Parameter structure
* @brief BC_Parameter structure
*/
struct Test_Parameter : gunrock::app::TestParameter_Base
struct BC_Parameter : gunrock::app::TestParameter_Base
{
public:
std::string ref_filename;
double max_queue_sizing1;

Test_Parameter()
BC_Parameter()
{
ref_filename = "";
max_queue_sizing1 = -1.0;
}

~Test_Parameter()
~BC_Parameter()
{
}
};
Expand All @@ -63,7 +63,7 @@ template <
bool INSTRUMENT,
bool DEBUG,
bool SIZE_CHECK >
void runBC(GRGraph* output, Test_Parameter *parameter);
void runBC(GRGraph* output, BC_Parameter *parameter);

/**
* @brief Run test
Expand All @@ -83,7 +83,7 @@ template <
typename SizeT,
bool INSTRUMENT,
bool DEBUG >
void RunTests_size_check(GRGraph* output, Test_Parameter *parameter)
void RunTests_size_check(GRGraph* output, BC_Parameter *parameter)
{
if (parameter->size_check)
runBC<VertexId, Value, SizeT, INSTRUMENT,
Expand All @@ -109,7 +109,7 @@ template <
typename Value,
typename SizeT,
bool INSTRUMENT >
void RunTests_debug(GRGraph* output, Test_Parameter *parameter)
void RunTests_debug(GRGraph* output, BC_Parameter *parameter)
{
if (parameter->debug)
RunTests_size_check<VertexId, Value, SizeT,
Expand All @@ -133,7 +133,7 @@ template <
typename VertexId,
typename Value,
typename SizeT >
void RunTests_instrumented(GRGraph* output, Test_Parameter *parameter)
void RunTests_instrumented(GRGraph* output, BC_Parameter *parameter)
{
if (parameter->instrumented)
RunTests_debug<VertexId, Value, SizeT, true>(output, parameter);
Expand Down Expand Up @@ -161,7 +161,7 @@ template <
bool INSTRUMENT,
bool DEBUG,
bool SIZE_CHECK >
void runBC(GRGraph* output, Test_Parameter *parameter)
void runBC(GRGraph* output, BC_Parameter *parameter)
{
typedef BCProblem <VertexId,
SizeT,
Expand Down Expand Up @@ -253,7 +253,6 @@ void runBC(GRGraph* output, Test_Parameter *parameter)
max_queue_sizing, max_queue_sizing1),
"BC Problem Data Reset Failed", __FILE__, __LINE__);

if (!quiet) { printf("__________________________\n"); fflush(stdout); }
cpu_timer.Start();
for (VertexId i = start_src; i < end_src; ++i)
{
Expand All @@ -275,7 +274,7 @@ void runBC(GRGraph* output, Test_Parameter *parameter)
(Value)0.5f, (int)(problem->sub_graphs[gpu].nodes));
}
cpu_timer.Stop();
if (!quiet) { printf("--------------------------\n"); fflush(stdout); }

float elapsed = cpu_timer.ElapsedMillis();

// Copy out results
Expand Down Expand Up @@ -317,7 +316,7 @@ void dispatchBC(
ContextPtr* context,
cudaStream_t* streams)
{
Test_Parameter* parameter = new Test_Parameter;
BC_Parameter* parameter = new BC_Parameter;
parameter->g_quiet = config.quiet;
parameter->context = context;
parameter->streams = streams;
Expand Down Expand Up @@ -486,7 +485,6 @@ void bc(
graphi->num_edges = num_edges; // setting graph edges
graphi->row_offsets = (void*)&row_offsets[0]; // setting row_offsets
graphi->col_indices = (void*)&col_indices[0]; // setting col_indices
printf(" loaded %d nodes and %d edges\n", num_nodes, num_edges);

gunrock_bc(grapho, graphi, config, data_t);
memcpy(bc_scores, (float*)grapho->node_value1, num_nodes * sizeof(float));
Expand Down
28 changes: 13 additions & 15 deletions gunrock/app/bfs/bfs_app.cu
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,31 @@ using namespace gunrock::oprtr;
using namespace gunrock::app::bfs;

/**
* @brief Test_Parameter structure
* @brief BFS_Parameter structure
*/
struct Test_Parameter : gunrock::app::TestParameter_Base
struct BFS_Parameter : gunrock::app::TestParameter_Base
{
public:
bool mark_predecessors ; // mark src-distance vs. parent vertices
bool enable_idempotence; // enable idempotence operation
double max_queue_sizing1 ; // maximum queue sizing factor

Test_Parameter()
BFS_Parameter()
{
mark_predecessors = false;
enable_idempotence = false;
max_queue_sizing1 = -1.0f;
}

~Test_Parameter()
~BFS_Parameter()
{
}
};

template<typename VertexId, typename Value, typename SizeT,
bool INSTRUMENT, bool DEBUG, bool SIZE_CHECK,
bool MARK_PREDECESSORS, bool ENABLE_IDEMPOTENCE>
void runBFS(GRGraph* output, Test_Parameter *parameter);
void runBFS(GRGraph* output, BFS_Parameter *parameter);

/**
* @brief Run test
Expand All @@ -77,7 +77,7 @@ template <
bool DEBUG,
bool SIZE_CHECK,
bool MARK_PREDECESSORS >
void RunTests_enable_idempotence(GRGraph* output, Test_Parameter *parameter)
void RunTests_enable_idempotence(GRGraph* output, BFS_Parameter *parameter)
{
if (parameter->enable_idempotence)
runBFS<VertexId, Value, SizeT, INSTRUMENT, DEBUG,
Expand Down Expand Up @@ -107,7 +107,7 @@ template <
bool INSTRUMENT,
bool DEBUG,
bool SIZE_CHECK >
void RunTests_mark_predecessors(GRGraph* output, Test_Parameter *parameter)
void RunTests_mark_predecessors(GRGraph* output, BFS_Parameter *parameter)
{
if (parameter->mark_predecessors)
RunTests_enable_idempotence<VertexId, Value, SizeT, INSTRUMENT, DEBUG,
Expand Down Expand Up @@ -135,7 +135,7 @@ template <
typename SizeT,
bool INSTRUMENT,
bool DEBUG >
void RunTests_size_check(GRGraph* output, Test_Parameter *parameter)
void RunTests_size_check(GRGraph* output, BFS_Parameter *parameter)
{
if (parameter->size_check)
RunTests_mark_predecessors<VertexId, Value, SizeT, INSTRUMENT,
Expand All @@ -161,7 +161,7 @@ template <
typename Value,
typename SizeT,
bool INSTRUMENT >
void RunTests_debug(GRGraph* output, Test_Parameter *parameter)
void RunTests_debug(GRGraph* output, BFS_Parameter *parameter)
{
if (parameter->debug)
RunTests_size_check<VertexId, Value, SizeT, INSTRUMENT,
Expand All @@ -185,7 +185,7 @@ template <
typename VertexId,
typename Value,
typename SizeT >
void RunTests_instrumented(GRGraph* output, Test_Parameter *parameter)
void RunTests_instrumented(GRGraph* output, BFS_Parameter *parameter)
{
if (parameter->instrumented)
RunTests_debug<VertexId, Value, SizeT, true>(output, parameter);
Expand Down Expand Up @@ -217,7 +217,7 @@ template <
bool SIZE_CHECK,
bool MARK_PREDECESSORS,
bool ENABLE_IDEMPOTENCE >
void runBFS(GRGraph* output, Test_Parameter *parameter)
void runBFS(GRGraph* output, BFS_Parameter *parameter)
{
typedef BFSProblem < VertexId,
SizeT,
Expand Down Expand Up @@ -296,15 +296,14 @@ void runBFS(GRGraph* output, Test_Parameter *parameter)
util::GRError(
enactor->Reset(), "BFS Enactor Reset failed", __FILE__, __LINE__);

if (!quiet) { printf("__________________________\n"); fflush(stdout); }
cpu_timer.Start();

util::GRError(
enactor->Enact(src, traversal_mode),
"BFS Problem Enact Failed", __FILE__, __LINE__);

cpu_timer.Stop();
if (!quiet) { printf("--------------------------\n"); fflush(stdout); }

float elapsed = cpu_timer.ElapsedMillis();

// Copy out results
Expand Down Expand Up @@ -344,7 +343,7 @@ void dispatch_bfs(
ContextPtr* context,
cudaStream_t* streams)
{
Test_Parameter *parameter = new Test_Parameter;
BFS_Parameter *parameter = new BFS_Parameter;
parameter->context = context;
parameter->streams = streams;
parameter->g_quiet = config.quiet;
Expand Down Expand Up @@ -519,7 +518,6 @@ void bfs(
graphi->num_edges = num_edges; // setting graph edges
graphi->row_offsets = (void*)&row_offsets[0]; // setting row_offsets
graphi->col_indices = (void*)&col_indices[0]; // setting col_indices
printf(" loaded %d nodes and %d edges\n", num_nodes, num_edges);

gunrock_bfs(grapho, graphi, config, data_t);
memcpy(bfs_label, (int*)grapho->node_value1, num_nodes * sizeof(int));
Expand Down
21 changes: 10 additions & 11 deletions gunrock/app/cc/cc_app.cu
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ using namespace gunrock::oprtr;
using namespace gunrock::app::cc;

/**
* @brief Test_Parameter structure
* @brief CC_Parameter structure
*/
struct Test_Parameter : gunrock::app::TestParameter_Base
struct CC_Parameter : gunrock::app::TestParameter_Base
{
public:
Test_Parameter() { }
~Test_Parameter() { }
CC_Parameter() { }
~CC_Parameter() { }
};

template <
Expand All @@ -43,7 +43,7 @@ template <
bool INSTRUMENT,
bool DEBUG,
bool SIZE_CHECK >
void runCC(GRGraph* output, Test_Parameter *parameter);
void runCC(GRGraph* output, CC_Parameter *parameter);

/**
* @brief Run test
Expand All @@ -63,7 +63,7 @@ template <
typename SizeT,
bool INSTRUMENT,
bool DEBUG >
void sizeCheckCC(GRGraph* output, Test_Parameter *parameter)
void sizeCheckCC(GRGraph* output, CC_Parameter *parameter)
{
if (parameter->size_check)
runCC<VertexId, Value, SizeT, INSTRUMENT, DEBUG,
Expand All @@ -90,7 +90,7 @@ template <
typename Value,
typename SizeT,
bool INSTRUMENT >
void debugCC(GRGraph* output, Test_Parameter *parameter)
void debugCC(GRGraph* output, CC_Parameter *parameter)
{
if (parameter->debug)
sizeCheckCC<VertexId, Value, SizeT, INSTRUMENT,
Expand All @@ -114,7 +114,7 @@ template <
typename VertexId,
typename Value,
typename SizeT >
void instrumentedCC(GRGraph* output, Test_Parameter *parameter)
void instrumentedCC(GRGraph* output, CC_Parameter *parameter)
{
if (parameter->instrumented)
debugCC<VertexId, Value, SizeT, true>(output, parameter);
Expand Down Expand Up @@ -142,7 +142,7 @@ template <
bool INSTRUMENT,
bool DEBUG,
bool SIZE_CHECK >
void runCC(GRGraph* output, Test_Parameter *parameter)
void runCC(GRGraph* output, CC_Parameter *parameter)
{
typedef CCProblem < VertexId,
SizeT,
Expand Down Expand Up @@ -254,7 +254,7 @@ void dispatch_cc(
ContextPtr* context,
cudaStream_t* streams)
{
Test_Parameter *parameter = new Test_Parameter;
CC_Parameter *parameter = new CC_Parameter;
parameter->context = context;
parameter->streams = streams;
parameter->g_quiet = config.quiet;
Expand Down Expand Up @@ -391,7 +391,6 @@ int cc(
graphi->num_edges = num_edges; // setting graph edges
graphi->row_offsets = (void*)&row_offsets[0]; // setting row_offsets
graphi->col_indices = (void*)&col_indices[0]; // setting col_indices
printf(" loaded %d nodes and %d edges\n", num_nodes, num_edges);

gunrock_cc(grapho, graphi, config, data_t);
int* num_components = (int*)grapho->aggregation;
Expand Down
Loading

0 comments on commit b8245ab

Please sign in to comment.