Skip to content

Commit

Permalink
Add input arg option to automate block factor choice
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsinc committed Jun 1, 2024
1 parent e6bc6b8 commit e2fc08e
Show file tree
Hide file tree
Showing 15 changed files with 106 additions and 46 deletions.
12 changes: 9 additions & 3 deletions LONESTAR/apps/bfs/kernel_ccg.cu
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ void kernel_sizing(CSRGraph &, dim3 &, dim3 &);
const char *GGC_OPTIONS = "coop_conv=False $ outline_iterate_gb=True $ backoff_blocking_factor=4 $ parcomb=True $ np_schedulers=set(['fg', 'tb', 'wp']) $ cc_disable=set([]) $ tb_lb=True $ hacks=set([]) $ np_factor=8 $ instrument=set([]) $ unroll=[] $ read_props=None $ outline_iterate=True $ ignore_nested_errors=False $ np=True $ write_props=None $ quiet_cgen=True $ retry_backoff=True $ cuda.graph_type=basic $ cuda.use_worklist_slots=True $ cuda.worklist_type=basic";
struct ThreadWork t_work;
extern int start_node;
extern int block_factor;
bool enable_lb = false;
typedef int edge_data_type;
typedef int node_data_type;
Expand Down Expand Up @@ -407,13 +408,18 @@ void gg_main_pipe_1_wrapper(CSRGraph& gg, int& LEVEL, PipeContextT<Worklist2>& p
check_cuda(cudaFree(cl_LEVEL));
}
}

void gg_main(CSRGraph& hg, CSRGraph& gg)
{
dim3 blocks, threads;
kernel_sizing(gg, blocks, threads);
std::cout << " Enter Block factor" << std::endl;
int block_factor;
std::cin >> block_factor;
// if no user input block factor then request
if (block_factor == 0) {
std::cout << " Enter Block factor" << std::endl;
std::cin >> block_factor;
assert(block_factor > 0);
}
fprintf(stdout, "Using block factor: %d\n", block_factor);
blocks = ggc_get_nSM()*block_factor;
t_work.init_thread_work(gg.nnodes);
PipeContextT<Worklist2> wl;
Expand Down
11 changes: 8 additions & 3 deletions LONESTAR/apps/bfs/kernel_gcpusrb.cu
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ void kernel_sizing(CSRGraph &, dim3 &, dim3 &);
const char *GGC_OPTIONS = "coop_conv=False $ outline_iterate_gb=True $ backoff_blocking_factor=4 $ parcomb=True $ np_schedulers=set(['fg', 'tb', 'wp']) $ cc_disable=set([]) $ tb_lb=True $ hacks=set([]) $ np_factor=8 $ instrument=set([]) $ unroll=[] $ read_props=None $ outline_iterate=True $ ignore_nested_errors=False $ np=True $ write_props=None $ quiet_cgen=True $ retry_backoff=True $ cuda.graph_type=basic $ cuda.use_worklist_slots=True $ cuda.worklist_type=basic";
struct ThreadWork t_work;
extern int start_node;
extern int block_factor;
bool enable_lb = false;
typedef int edge_data_type;
typedef int node_data_type;
Expand Down Expand Up @@ -715,9 +716,13 @@ void gg_main(CSRGraph& hg, CSRGraph& gg)
{
dim3 blocks, threads;
kernel_sizing(gg, blocks, threads);
std::cout << " Enter Block factor" << std::endl;
int block_factor;
std::cin >> block_factor;
// if no user input block factor then request
if (block_factor == 0) {
std::cout << " Enter Block factor" << std::endl;
std::cin >> block_factor;
assert(block_factor > 0);
}
fprintf(stdout, "Using block factor: %d\n", block_factor);
blocks = ggc_get_nSM()*block_factor;
t_work.init_thread_work(gg.nnodes);
PipeContextT<Worklist2> wl;
Expand Down
11 changes: 8 additions & 3 deletions LONESTAR/apps/bfs/kernel_gsrb.cu
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ void kernel_sizing(CSRGraph &, dim3 &, dim3 &);
const char *GGC_OPTIONS = "coop_conv=False $ outline_iterate_gb=True $ backoff_blocking_factor=4 $ parcomb=True $ np_schedulers=set(['fg', 'tb', 'wp']) $ cc_disable=set([]) $ tb_lb=True $ hacks=set([]) $ np_factor=8 $ instrument=set([]) $ unroll=[] $ read_props=None $ outline_iterate=True $ ignore_nested_errors=False $ np=True $ write_props=None $ quiet_cgen=True $ retry_backoff=True $ cuda.graph_type=basic $ cuda.use_worklist_slots=True $ cuda.worklist_type=basic";
struct ThreadWork t_work;
extern int start_node;
extern int block_factor;
bool enable_lb = false;
typedef int edge_data_type;
typedef int node_data_type;
Expand Down Expand Up @@ -713,9 +714,13 @@ void gg_main(CSRGraph& hg, CSRGraph& gg)
{
dim3 blocks, threads;
kernel_sizing(gg, blocks, threads);
std::cout << " Enter Block factor" << std::endl;
int block_factor;
std::cin >> block_factor;
// if no user input block factor then request
if (block_factor == 0) {
std::cout << " Enter Block factor" << std::endl;
std::cin >> block_factor;
assert(block_factor > 0);
}
fprintf(stdout, "Using block factor: %d\n", block_factor);
blocks = ggc_get_nSM()*block_factor;
t_work.init_thread_work(gg.nnodes);
PipeContextT<Worklist2> wl;
Expand Down
6 changes: 3 additions & 3 deletions LONESTAR/apps/bfs/run.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

# Run GPU SRB (sense-reversing barrier) variant
../../bin/bfs_gsrb -s 0 -o outfile.txt ../../inputs/USA-road-d.W.gr
../../bin/bfs_gsrb -s 0 -b 4 -o outfile.txt ../../inputs/USA-road-d.W.gr
# Run GPU SRB variant that uses CPU-style SRBs
../../bin/bfs_gcpusrb -s 0 -o outfile.txt ../../inputs/USA-road-d.W.gr
../../bin/bfs_gcpusrb -s 0 -b 4 -o outfile.txt ../../inputs/USA-road-d.W.gr
# Run CUDA Cooperative Graphs (CCG) variant
../../bin/bfs_ccg -s 0 -o outfile.txt ../../inputs/USA-road-d.W.gr
../../bin/bfs_ccg -s 0 -b 4 -o outfile.txt ../../inputs/USA-road-d.W.gr
14 changes: 9 additions & 5 deletions LONESTAR/apps/bfs/support.cu
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,29 @@

#include "gg.h"

const char *prog_opts = "ls:";
const char *prog_usage = "[-l] [-s startNode]";
const char *prog_opts = "ls:b:";
const char *prog_usage = "[-l] [-s startNode] [-b blockFactor]";
const char *prog_args_usage = "-l: enable thread block load balancer (by default false)";

extern const int INF;
int start_node = 0;
int block_factor = 0;
extern bool enable_lb;

int process_prog_arg(int argc, char *argv[], int arg_start) {
return 1;
}

void process_prog_opt(char c, char *optarg) {
if(c == 's') {
if (c == 's') {
start_node = atoi(optarg);
assert(start_node >= 0);
}
if(c == 'l') {
enable_lb = true;
if (c == 'l') {
enable_lb = true;
}
if (c == 'b') {
block_factor = atoi(optarg);
}
}

Expand Down
11 changes: 8 additions & 3 deletions LONESTAR/apps/pr/kernel_ccg.cu
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ float* P_NEXT ;
extern const float ALPHA = 0.85;
extern const float EPSILON = 0.000001;
extern int MAX_ITERATIONS ;
extern int block_factor;
static const int __tb_gg_main_pipe_1_gpu_gb = 32;
static const int __tb_one = 1;
static const int __tb_pagerank_main = TB_SIZE;
Expand Down Expand Up @@ -385,9 +386,13 @@ void gg_main(CSRGraph& hg, CSRGraph& gg)
{
dim3 blocks, threads;
kernel_sizing(gg, blocks, threads);
std::cout << " Enter Block factor" << std::endl;
int block_factor;
std::cin >> block_factor;
// if no user input block factor then request
if (block_factor == 0) {
std::cout << " Enter Block factor" << std::endl;
std::cin >> block_factor;
assert(block_factor > 0);
}
fprintf(stdout, "Using block factor: %d\n", block_factor);
blocks = ggc_get_nSM()*block_factor;
t_work.init_thread_work(gg.nnodes);
static GlobalBarrierLifetime remove_dups_barrier;
Expand Down
11 changes: 8 additions & 3 deletions LONESTAR/apps/pr/kernel_gcpusrb.cu
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ float* P_NEXT ;
extern const float ALPHA = 0.85;
extern const float EPSILON = 0.000001;
extern int MAX_ITERATIONS ;
extern int block_factor;
static const int __tb_gg_main_pipe_1_gpu_gb = 32;
static const int __tb_one = 1;
static const int __tb_pagerank_main = TB_SIZE;
Expand Down Expand Up @@ -684,9 +685,13 @@ void gg_main(CSRGraph& hg, CSRGraph& gg)
{
dim3 blocks, threads;
kernel_sizing(gg, blocks, threads);
std::cout << " Enter Block factor" << std::endl;
int block_factor;
std::cin >> block_factor;
// if no user input block factor then request
if (block_factor == 0) {
std::cout << " Enter Block factor" << std::endl;
std::cin >> block_factor;
assert(block_factor > 0);
}
fprintf(stdout, "Using block factor: %d\n", block_factor);
blocks = ggc_get_nSM()*block_factor;
t_work.init_thread_work(gg.nnodes);
static GlobalBarrierLifetime remove_dups_barrier;
Expand Down
11 changes: 8 additions & 3 deletions LONESTAR/apps/pr/kernel_gsrb.cu
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ float* P_NEXT ;
extern const float ALPHA = 0.85;
extern const float EPSILON = 0.000001;
extern int MAX_ITERATIONS ;
extern int block_factor;
static const int __tb_gg_main_pipe_1_gpu_gb = 32;
static const int __tb_one = 1;
static const int __tb_pagerank_main = TB_SIZE;
Expand Down Expand Up @@ -684,9 +685,13 @@ void gg_main(CSRGraph& hg, CSRGraph& gg)
{
dim3 blocks, threads;
kernel_sizing(gg, blocks, threads);
std::cout << " Enter Block factor" << std::endl;
int block_factor;
std::cin >> block_factor;
// if no user input block factor then request
if (block_factor == 0) {
std::cout << " Enter Block factor" << std::endl;
std::cin >> block_factor;
assert(block_factor > 0);
}
fprintf(stdout, "Using block factor: %d\n", block_factor);
blocks = ggc_get_nSM()*block_factor;
t_work.init_thread_work(gg.nnodes);
static GlobalBarrierLifetime remove_dups_barrier;
Expand Down
6 changes: 3 additions & 3 deletions LONESTAR/apps/pr/run.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

# Run GPU SRB (sense-reversing barrier) variant
../../bin/pr_gsrb -o outfile.txt -x 1000000 ../../inputs/USA-road-d.W.gr
../../bin/pr_gsrb -b 4 -o outfile.txt -x 1000000 ../../inputs/USA-road-d.W.gr
# Run GPU SRB variant that uses CPU-style SRBs
../../bin/pr_gcpusrb -o outfile.txt -x 1000000 ../../inputs/USA-road-d.W.gr
../../bin/pr_gcpusrb -b 4 -o outfile.txt -x 1000000 ../../inputs/USA-road-d.W.gr
# Run CUDA Cooperative Graphs (CCG) variant
../../bin/pr_ccg -o outfile.txt -x 1000000 ../../inputs/USA-road-d.W.gr
../../bin/pr_ccg -b 4 -o outfile.txt -x 1000000 ../../inputs/USA-road-d.W.gr
12 changes: 9 additions & 3 deletions LONESTAR/apps/pr/support.cu
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ struct pr_value {
};

/* TODO: accept ALPHA and EPSILON */
const char *prog_opts = "nt:x:";
const char *prog_usage = "[-n] [-t top_ranks] [-x max_iterations]";
const char *prog_opts = "nt:x:b:";
const char *prog_usage = "[-n] [-t top_ranks] [-x max_iterations] [-b blockFactor]";
const char *prog_args_usage = "";

extern float *P_CURR, *P_NEXT;
extern const float ALPHA, EPSILON;
extern int MAX_ITERATIONS;
int block_factor = 0;

int NO_PRINT_PAGERANK = 0;
int PRINT_TOP = 0;
Expand All @@ -30,8 +31,9 @@ int process_prog_arg(int argc, char *argv[], int arg_start) {
}

void process_prog_opt(char c, char *optarg) {
if(c == 'n')
if(c == 'n') {
NO_PRINT_PAGERANK = 1;
}

if(c == 't') {
PRINT_TOP = atoi(optarg);
Expand All @@ -40,6 +42,10 @@ void process_prog_opt(char c, char *optarg) {
if(c == 'x') {
MAX_ITERATIONS = atoi(optarg);
}

if (c == 'b') {
block_factor = atoi(optarg);
}
}

void output(CSRGraphTy &g, const char *output_file) {
Expand Down
11 changes: 8 additions & 3 deletions LONESTAR/apps/sssp/kernel_ccg.cu
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const char *GGC_OPTIONS = "coop_conv=False $ outline_iterate_gb=True $ backoff_b
struct ThreadWork t_work;
extern int DELTA;
extern int start_node;
extern int block_factor;
bool enable_lb = false;
typedef int edge_data_type;
typedef int node_data_type;
Expand Down Expand Up @@ -484,9 +485,13 @@ void gg_main(CSRGraph& hg, CSRGraph& gg)
{
dim3 blocks, threads;
kernel_sizing(gg, blocks, threads);
std::cout << " Enter Block factor" << std::endl;
int block_factor;
std::cin >> block_factor;
// if no user input block factor then request
if (block_factor == 0) {
std::cout << " Enter Block factor" << std::endl;
std::cin >> block_factor;
assert(block_factor > 0);
}
fprintf(stdout, "Using block factor: %d\n", block_factor);
blocks = ggc_get_nSM()*block_factor;
t_work.init_thread_work(gg.nnodes);
static GlobalBarrierLifetime remove_dups_barrier;
Expand Down
11 changes: 8 additions & 3 deletions LONESTAR/apps/sssp/kernel_gcpusrb.cu
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ const char *GGC_OPTIONS = "coop_conv=False $ outline_iterate_gb=True $ backoff_b
struct ThreadWork t_work;
extern int DELTA;
extern int start_node;
extern int block_factor;
bool enable_lb = false;
typedef int edge_data_type;
typedef int node_data_type;
Expand Down Expand Up @@ -796,9 +797,13 @@ void gg_main(CSRGraph& hg, CSRGraph& gg)
{
dim3 blocks, threads;
kernel_sizing(gg, blocks, threads);
std::cout << " Enter Block factor" << std::endl;
int block_factor;
std::cin >> block_factor;
// if no user input block factor then request
if (block_factor == 0) {
std::cout << " Enter Block factor" << std::endl;
std::cin >> block_factor;
assert(block_factor > 0);
}
fprintf(stdout, "Using block factor: %d\n", block_factor);
blocks = ggc_get_nSM()*block_factor;
t_work.init_thread_work(gg.nnodes);
static GlobalBarrierLifetime remove_dups_barrier;
Expand Down
11 changes: 8 additions & 3 deletions LONESTAR/apps/sssp/kernel_gsrb.cu
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ const char *GGC_OPTIONS = "coop_conv=False $ outline_iterate_gb=True $ backoff_b
struct ThreadWork t_work;
extern int DELTA;
extern int start_node;
extern int block_factor;
bool enable_lb = false;
typedef int edge_data_type;
typedef int node_data_type;
Expand Down Expand Up @@ -791,9 +792,13 @@ void gg_main(CSRGraph& hg, CSRGraph& gg)
{
dim3 blocks, threads;
kernel_sizing(gg, blocks, threads);
std::cout << " Enter Block factor" << std::endl;
int block_factor;
std::cin >> block_factor;
// if no user input block factor then request
if (block_factor == 0) {
std::cout << " Enter Block factor" << std::endl;
std::cin >> block_factor;
assert(block_factor > 0);
}
fprintf(stdout, "Using block factor: %d\n", block_factor);
blocks = ggc_get_nSM()*block_factor;
t_work.init_thread_work(gg.nnodes);
static GlobalBarrierLifetime remove_dups_barrier;
Expand Down
6 changes: 3 additions & 3 deletions LONESTAR/apps/sssp/run.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

# Run GPU SRB (sense-reversing barrier) variant
../../bin/sssp_gsrb -s 0 -o outfile.txt ../../inputs/USA-road-d.W.gr
../../bin/sssp_gsrb -s 0 -b 4 -o outfile.txt ../../inputs/USA-road-d.W.gr
# Run GPU SRB variant that uses CPU-style SRBs
../../bin/sssp_gcpusrb -s 0 -o outfile.txt ../../inputs/USA-road-d.W.gr
../../bin/sssp_gcpusrb -s 0 -b 4 -o outfile.txt ../../inputs/USA-road-d.W.gr
# Run CUDA Cooperative Graphs (CCG) variant
../../bin/sssp_ccg -s 0 -o outfile.txt ../../inputs/USA-road-d.W.gr
../../bin/sssp_ccg -s 0 -b 4 -o outfile.txt ../../inputs/USA-road-d.W.gr
8 changes: 6 additions & 2 deletions LONESTAR/apps/sssp/support.cu
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
#include "gg.h"
#include <cassert>

const char *prog_opts = "ls:d:";
const char *prog_usage = "[-l] [-d delta] [-s startNode]";
const char *prog_opts = "ls:d:b:";
const char *prog_usage = "[-l] [-d delta] [-s startNode] [-b blockFactor]";
const char *prog_args_usage = "-l: enable thread block load balancer (by default false)";

int DELTA = 10000;
extern const int INF;
int start_node = 0;
int block_factor = 0;
extern bool enable_lb;

int process_prog_arg(int argc, char *argv[], int arg_start) {
Expand All @@ -28,6 +29,9 @@ void process_prog_opt(char c, char *optarg) {
start_node = atoi(optarg);
assert(start_node >= 0);
}
if (c == 'b') {
block_factor = atoi(optarg);
}
}

void output(CSRGraphTy &g, const char *output_file) {
Expand Down

0 comments on commit e2fc08e

Please sign in to comment.