I am a beginner for MPI coding. I want to have structs across multiple processes.
I have a struct for the count min sketch:
typedef struct CM_type{
long long count;
int depth;
int width;
int ** counts;
unsigned int *hasha, *hashb;
} CM_type;
I wrote a function for initialization of this count min sketch.
std::vector<CM_type> CM_Init(int width, int depth, int seed)
{
int j;
prng_type * prng;
prng=prng_Init(-abs(seed),2);
#pragma omp parallel shared (width, depth, prng) private(j)
{
//CM_type cm_loc;
std::vector<CM_type> cm_loc;
//std::vector<CM_type> cm_loc;
cm_loc.depth=depth;
cm_loc.width=width;
cm_loc.count=0;
cm_loc.counts=(int **)calloc(sizeof(int *),cm_loc.width);
cm_loc.counts=(int *)calloc(sizeof(int), cm_loc.depth*cm_loc.width);
//cm->total = 0;
cm_loc.hasha=(unsigned int *)calloc(sizeof(unsigned int),cm_loc.depth);
cm_loc.hashb=(unsigned int *)calloc(sizeof(unsigned int),cm_loc.depth);
if (cm_loc.counts && cm_loc.hasha && cm_loc.hashb && cm_loc.counts[0])
{
for (j=0;j<depth;j++)
{
#pragma omp critical
{
cm_loc.hasha[j]=prng_int(prng) & MOD;
cm_loc.hashb[j]=prng_int(prng) & MOD;
// pick the hash functions
cm_loc.counts[j]=(int *) cm_loc.counts[0]+(j*cm_loc.width);
}
}
}
//else cm_loc = NULL;
return cm_loc[0];
}
}
My objective is to create local count min sketches across multiple processes and then initialize the local sketches independently. When I am running this code I am getting an error like this:
error: 'class std::vector<CM_type>' has no member named 'depth'
cm_loc.depth=depth;
^~~~~
error: 'class std::vector<CM_type>' has no member named 'width'
cm_loc.width=width;
and so on. For all the structure members I am getting this error. I can give you any more information if required. Kindly help. Thank you.