27 P.get_local_data(&nloc, &inds, &loc_parts);
31 for (int64_t i=0; i<nloc; i++){
32 loc_parts[i].
dx = drand48();
33 loc_parts[i].
dy = drand48();
34 loc_parts[i].
coeff = .001*drand48();
35 loc_parts[i].
id = 777;
37 P.write(nloc, inds, loc_parts);
43 for (int64_t i=0; i<nf; i++){
44 loc_frcs[i].
fx = drand48();
45 loc_frcs[i].
fy = drand48();
47 F.
write(nf, finds, loc_frcs);
58 uacc(F2[
"ij"],P[
"i"]);
61 P.read(nloc, inds, loc_parts_new);
66 for (int64_t i=0; i<nloc; i++){
67 if (fabs(loc_parts[i].dx - loc_parts_new[i].dx)<1.E-6 &&
68 fabs(loc_parts[i].dy - loc_parts_new[i].dy)<1.E-6) pass = 0;
71 MPI_Allreduce(MPI_IN_PLACE, &pass, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD);
72 if (!pass && dw.
rank == 0){
73 printf(
"Test incorrect: application of uacc did not modify some value.\n");
81 P.read(nloc, inds, loc_parts_new);
85 for (int64_t i=0; i<nloc; i++){
86 if (fabs(loc_parts[i].dx - loc_parts_new[i].dx)>1.E-6 ||
87 fabs(loc_parts[i].dy - loc_parts_new[i].dy)>1.E-6) pass = 0;
91 delete [] loc_parts_new;
92 MPI_Allreduce(MPI_IN_PLACE, &pass, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD);
96 printf(
"{ P[\"i\"] = uacc(F[\"ij\"]) } passed\n");
98 printf(
"{ P[\"i\"] = uacc(F[\"ij\"]) } failed\n");
112 char ** itr = std::find(begin, end, option);
113 if (itr != end && ++itr != end){
120 int main(
int argc,
char ** argv){
122 int const in_num = argc;
123 char ** input_str = argv;
125 MPI_Init(&argc, &argv);
126 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
127 MPI_Comm_size(MPI_COMM_WORLD, &np);
130 n = atoi(
getCmdOption(input_str, input_str+in_num,
"-n"));
136 World dw(MPI_COMM_WORLD, argc, argv);
139 printf(
"Computing force_integration A_ijkl = f(A_ijkl)\n");
Set class defined by a datatype and a min/max function (if it is partially ordered i...
Matrix class which encapsulates a 2D tensor.
Vector class which encapsulates a 1D tensor.
int main(int argc, char **argv)
an instance of the CTF library (world) on a MPI communicator
int rank
rank of local processor
int force_integration(int n, World &dw)
Group is a Monoid with operator '-' defined special case (parent) of a ring.
char * getCmdOption(char **begin, char **end, const std::string &option)
void get_local_data(int64_t *npair, int64_t **global_idx, dtype **data, bool nonzeros_only=false, bool unpack_sym=false) const
Gives the global indices and values associated with the local data.
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...