16 assert(undir_A.
symm ==
SH);
22 int nosym[] = {
NS,
NS};
37 v.
sparsify([](
float f){
return f==1.0; });
43 v[
"i"] += A[
"ij"]*v[
"j"];
47 v[
"i"] += (1.+n)*r[
"i"];
48 v.
sparsify([](
float f){
return f==1.0; });
54 v[
"i"] += A[
"ij"]*v[
"j"];
77 printf(
"Found MIS of size %ld\n",s.
nnz_tot);
82 t[
"i"] += A[
"ij"]*s[
"j"];
85 float zero = s[
"i"]*t[
"i"];
89 printf(
"Falure: MIS is not independent!\n");
100 printf(
"Falure: MIS is not maximal, nnz = %d!\n",nnz);
113 char ** itr = std::find(begin, end, option);
114 if (itr != end && ++itr != end){
121 int main(
int argc,
char ** argv){
124 int const in_num = argc;
125 char ** input_str = argv;
127 MPI_Init(&argc, &argv);
128 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
129 MPI_Comm_size(MPI_COMM_WORLD, &np);
132 n = atoi(
getCmdOption(input_str, input_str+in_num,
"-n"));
136 if (
getCmdOption(input_str, input_str+in_num,
"-sp_frac")){
137 sp_frac = atof(
getCmdOption(input_str, input_str+in_num,
"-sp_frac"));
138 if (sp_frac < 0) sp_frac = .1;
142 World dw(argc, argv);
145 printf(
"Running MIS with n=%d, sp_frac=%lf\n",n,sp_frac);
150 printf(
"MIS passed.\n");
152 printf(
"MIS FAILED.\n");
Matrix class which encapsulates a 2D tensor.
dtype get_val()
returns scalar value
bool test_mis(int n, double sp_frac)
Vector class which encapsulates a 1D tensor.
an instance of the CTF library (world) on a MPI communicator
CTF::World * wrld
distributed processor context on which tensor is defined
Scalar class which encapsulates a 0D tensor.
int rank
rank of local processor
void sparsify()
reduce tensor to sparse format, storing only nonzero data, or data above a specified threshold...
Vector< float > mis(Matrix< float > &undir_A)
int64_t nnz_tot
maximum number of local nonzero elements over all procs
void fill_sp_random(dtype rmin, dtype rmax, double frac_sp)
generate roughly frac_sp*dense_tensor_size nonzeros between rmin and rmax, works only for dtype in {f...
an instance of a tensor within a CTF world
char * getCmdOption(char **begin, char **end, const std::string &option)
int main(int argc, char **argv)