11 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
12 MPI_Comm_size(MPI_COMM_WORLD, &num_pes);
15 int len4[] = {n,n,n,n};
17 int NNN[] = {
NS,
NS,NS};
18 int NNNN[] = {
NS,
NS,
NS,NS};
19 int ANNN[] = {
AS,
NS,
NS,NS};
20 int SNNN[] = {
SH,
NS,
NS,NS};
45 for (i=0; i<size; i++){
46 values[i] = drand48();
48 T.
write(size, indices, values);
52 for (i=0; i<size; i++){
53 values[i] = drand48();
55 V.
write(size, indices, values);
59 Z_NS[
"afin"] = T[
"aeim"]*V[
"efmn"];
61 W_ans[
"abij"] = Z_NS[
"afin"]*T[
"fbnj"];
65 Z_AS[
"afin"] = T[
"aeim"]*V[
"efmn"];
66 Z_SH[
"afin"] = T[
"aeim"]*V[
"efmn"];
67 Z_D[
"ain"] = T[
"aeim"]*V[
"eamn"];
68 W[
"abij"] = Z_AS[
"afin"]*T[
"fbnj"];
69 W[
"abij"] += Z_SH[
"afin"]*T[
"fbnj"];
70 W[
"abij"] += Z_D[
"ain"]*T[
"abnj"];
83 double nrm = sqrt((
double)((W[
"abij"]-W_ans[
"abij"])*(W[
"abij"]-W_ans[
"abij"])));
85 int pass = (nrm <=1.E-10);
88 MPI_Reduce(MPI_IN_PLACE, &pass, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD);
89 if (pass) printf(
"{ C[\"(ij)ab\"] = A[\"(ik)al\"]*B[\"(kj)lb\"] } passed\n");
90 else printf(
"{ C[\"(ij)ab\"] = A[\"(ik)al\"]*B[\"(kj)lb\"] } failed\n");
92 MPI_Reduce(&pass, MPI_IN_PLACE, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD);
100 char ** itr = std::find(begin, end, option);
101 if (itr != end && ++itr != end){
108 int main(
int argc,
char ** argv){
110 int const in_num = argc;
111 char ** input_str = argv;
113 MPI_Init(&argc, &argv);
114 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
115 MPI_Comm_size(MPI_COMM_WORLD, &np);
118 n = atoi(
getCmdOption(input_str, input_str+in_num,
"-n"));
123 World dw(MPI_COMM_WORLD, argc, argv);
125 printf(
"Computing W^(ab)_ij=sum_(efmn)T^(ae)_im*V^(ef)_mn*T^(fb)_nj\n");
int fast_diagram(int const n, World &ctf)
char * getCmdOption(char **begin, char **end, const std::string &option)
an instance of the CTF library (world) on a MPI communicator
void read_local(int64_t *npair, int64_t **global_idx, dtype **data, bool unpack_sym=false) const
Using get_local_data(), which returns an array that must be freed with delete [], is more efficient...
int main(int argc, char **argv)
an instance of a tensor within a CTF world
void write(int64_t npair, int64_t const *global_idx, dtype const *data)
writes in values associated with any set of indices The sparse data is defined in coordinate format...