15 int lens_u[] = {n,n,n};
26 bool pass = v.
norm2() < 1.e-7*n*n*.1*n;
29 MPI_File_delete(
"checkpoint_sparse_tensor.txt", info);
33 printf(
"{ sparse_checkpointing using dense data representation with qtf=%d } failed\n",qtf);
35 printf(
"{ sparse_checkpointing using dense data representation with qtf=%d } passed\n",qtf);
47 char ** itr = std::find(begin, end, option);
48 if (itr != end && ++itr != end){
55 int main(
int argc,
char ** argv){
57 int const in_num = argc;
58 char ** input_str = argv;
60 MPI_Init(&argc, &argv);
61 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
62 MPI_Comm_size(MPI_COMM_WORLD, &np);
65 n = atoi(
getCmdOption(input_str, input_str+in_num,
"-n"));
70 qtf = atoi(
getCmdOption(input_str, input_str+in_num,
"-qtf"));
71 if (qtf < 0) qtf =
NS;
77 World dw(MPI_COMM_WORLD, argc, argv);
79 printf(
"Checking sparse_checkpoint calculation n = %d, p = %d, qtf = %d:\n",n,np,qtf);
char * getCmdOption(char **begin, char **end, const std::string &option)
an instance of the CTF library (world) on a MPI communicator
dtype norm2()
computes the frobenius norm of the tensor (needs sqrt()!)
void read_sparse_from_file(const char *fpath, bool with_vals=true)
read sparse tensor from file, entries of tensor must be stored one per line, as i_1 ...
int rank
rank of local processor
int main(int argc, char **argv)
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...
int sparse_checkpoint(int n, World &dw, int qtf=NS)
void write_sparse_to_file(const char *fpath, bool with_vals=true)
write sparse tensor to file, entries of tensor will be stored one per line, as i_1 ...
an instance of a tensor within a CTF world