19 if (strlen(a.
name) >= strlen(b.
name))
return a;
23 void mpi_cadd(
void *
a,
void *
b,
int * len, MPI_Datatype * d){
24 for (
int i=0; i<*len; i++){
33 int shapeN4[] = {
NS,
NS,
NS,NS};
34 int sizeN4[] = {n+1,n,n+2,n+3};
51 A.get_local_data(&nvals, &inds, &vals);
54 for (int64_t i=0; i<nvals; i++){
55 int str_len = drand48()*250;
56 std::fill(vals[i].name, vals[i].name+str_len,
'a');
57 vals[i].
name[str_len]=
'\0';
60 A.write(nvals, inds, vals);
73 A.get_local_data(&nloc, &indices, &loc_data);
77 for (int64_t i=0; i<nloc; i++){
78 if ((
int)strlen(loc_data[i].name) != loc_data[i].len_name) pass = 0;
81 MPI_Allreduce(MPI_IN_PLACE, &pass, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD);
85 printf(
"{ A[\"ijkl\"] = comp_len(A[\"ijkl\"]) } passed\n");
87 printf(
"{ A[\"ijkl\"] = comp_len(A[\"ijkl\"]) } failed\n");
105 char ** itr = std::find(begin, end, option);
106 if (itr != end && ++itr != end){
113 int main(
int argc,
char ** argv){
115 int const in_num = argc;
116 char ** input_str = argv;
118 MPI_Init(&argc, &argv);
119 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
120 MPI_Comm_size(MPI_COMM_WORLD, &np);
123 n = atoi(
getCmdOption(input_str, input_str+in_num,
"-n"));
129 World dw(MPI_COMM_WORLD, argc, argv);
132 printf(
"Computing user-defined endomorphism on a tensor over a monoid, A_ijkl = f(A_ijkl)\n");
char * getCmdOption(char **begin, char **end, const std::string &option)
int main(int argc, char **argv)
int endomorphism_cust(int n, World &dw)
an instance of the CTF library (world) on a MPI communicator
int rank
rank of local processor
cust_type cadd(cust_type a, cust_type b)
void mpi_cadd(void *a, void *b, int *len, MPI_Datatype *d)
A Monoid is a Set equipped with a binary addition operator '+' or a custom function addition must hav...
an instance of a tensor within a CTF world