-
Notifications
You must be signed in to change notification settings - Fork 10
/
util.cuh
54 lines (43 loc) · 1.4 KB
/
util.cuh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef BC_UTIL
#define BC_UTIL
#include <iostream>
#include <cstdlib>
#include <cuda.h>
#include <cmath>
#include <getopt.h>
#include "parse.h"
// This will output the proper CUDA error strings in the event that a CUDA host call returns an error
#ifndef checkCudaErrors
#define checkCudaErrors(err) __checkCudaErrors (err, __FILE__, __LINE__)
// These are the inline versions for all of the SDK helper functions
inline void __checkCudaErrors(cudaError_t err, const char *file, const int line)
{
if (cudaSuccess != err)
{
std::cerr << "CUDA Error = " << err << ": " << cudaGetErrorString(err) << " from file " << file << ", line " << line << std::endl;
exit(EXIT_FAILURE);
}
}
#endif
//Command line parsing
class program_options
{
public:
program_options() : infile(NULL), verify(false), printBCscores(false), scorefile(NULL), device(-1), approx(false), k(256) {}
char *infile;
bool verify;
bool printBCscores;
char *scorefile;
int device;
bool approx;
int k;
};
program_options parse_arguments(int argc, char *argv[]);
//Timing routines
void start_clock(cudaEvent_t &start, cudaEvent_t &end);
float end_clock(cudaEvent_t &start, cudaEvent_t &end);
//Device routines
void choose_device(int &max_threads_per_block, int &number_of_SMs, program_options op);
//Verification routines
void verify(graph g, const std::vector<float> bc_cpu, const std::vector<float> bc_gpu);
#endif