Cyclops Tensor Framework
parallel arithmetic on multidimensional arrays
ccsdt_map_test.cxx
Go to the documentation of this file.
1 
8 #include <ctf.hpp>
9 
10 using namespace CTF;
11 
12 int ccsdt_map_test(int n,
13  World &dw){
14 
15  int rank, num_pes;
16 
17  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
18  MPI_Comm_size(MPI_COMM_WORLD, &num_pes);
19 
20  //int shapeAS6[] = {AS,AS,NS,AS,AS,NS};
21  int shapeNS6[] = {NS,NS,NS,NS,NS,NS};
22  int nnnnnn[] = {n,n,n,n,n,n};
23  int shapeNS4[] = {NS,NS,NS,NS};
24  int nnnn[] = {n,n,n,n};
25 
26  //* Creates distributed tensors initialized with zeros
27  Tensor<> W(4, nnnn, shapeNS4, dw, "W", 1);
28  Tensor<> T(4, nnnn, shapeNS4, dw, "T", 1);
29  Tensor<> Z(6, nnnnnn, shapeNS6, dw, "Z", 1);
30 
31  Z["hijmno"] += W["hijk"]*T["kmno"];
32 
33  return 1;
34 }
35 
36 char* getCmdOption(char ** begin,
37  char ** end,
38  const std::string & option){
39  char ** itr = std::find(begin, end, option);
40  if (itr != end && ++itr != end){
41  return *itr;
42  }
43  return 0;
44 }
45 
46 
47 int main(int argc, char ** argv){
48  int rank, np, niter, n;
49  int const in_num = argc;
50  char ** input_str = argv;
51 
52  MPI_Init(&argc, &argv);
53  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
54  MPI_Comm_size(MPI_COMM_WORLD, &np);
55 
56  if (getCmdOption(input_str, input_str+in_num, "-n")){
57  n = atoi(getCmdOption(input_str, input_str+in_num, "-n"));
58  if (n < 0) n = 4;
59  } else n = 4;
60 
61  if (getCmdOption(input_str, input_str+in_num, "-niter")){
62  niter = atoi(getCmdOption(input_str, input_str+in_num, "-niter"));
63  if (niter < 0) niter = 3;
64  } else niter = 3;
65 
66 
67 
68  {
69  World dw(argc, argv);
70  int pass = ccsdt_map_test(n, dw);
71  assert(pass);
72  }
73 
74 
75  MPI_Finalize();
76  return 0;
77 }
char * getCmdOption(char **begin, char **end, const std::string &option)
def rank(self)
Definition: core.pyx:312
Definition: common.h:37
an instance of the CTF library (world) on a MPI communicator
Definition: world.h:19
string
Definition: core.pyx:456
int ccsdt_map_test(int n, World &dw)
Definition: apsp.cxx:17
an instance of a tensor within a CTF world
Definition: tensor.h:74
int main(int argc, char **argv)
def np(self)
Definition: core.pyx:315