本文整理汇总了C++中InterColComm::publisherStore方法的典型用法代码示例。如果您正苦于以下问题:C++ InterColComm::publisherStore方法的具体用法?C++ InterColComm::publisherStore怎么用?C++ InterColComm::publisherStore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InterColComm
的用法示例。
在下文中一共展示了InterColComm::publisherStore方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: customexit
int customexit(HyPerCol * hc, int argc, char ** argv) {
pvadata_t correctvalue = 0.5f;
pvadata_t tolerance = 1.0e-7f;
if (hc->columnId()==0) {
pvInfo().printf("Checking whether input layer has all values equal to %f ...\n", correctvalue);
}
HyPerLayer * inputlayer = hc->getLayerFromName("input");
assert(inputlayer);
PVLayerLoc const * loc = inputlayer->getLayerLoc();
assert(loc->nf==1);
const int numNeurons = inputlayer->getNumNeurons();
assert(numNeurons>0);
int status = PV_SUCCESS;
int numExtended = inputlayer->getNumExtended();
InterColComm * icComm = hc->icCommunicator();
pvadata_t * layerData = (pvadata_t *) icComm->publisherStore(inputlayer->getLayerId())->buffer(LOCAL);
int rootproc = 0;
if (icComm->commRank()==rootproc) {
pvadata_t * databuffer = (pvadata_t *) malloc(numExtended*sizeof(pvadata_t));
assert(databuffer);
for (int proc=0; proc<icComm->commSize(); proc++) {
if (proc==rootproc) {
memcpy(databuffer, layerData, numExtended*sizeof(pvadata_t));
}
else {
MPI_Recv(databuffer, numExtended*sizeof(pvadata_t),MPI_BYTE,proc,15,icComm->communicator(), MPI_STATUS_IGNORE);
}
// At this point, databuffer on rank 0 should contain the extended input layer on rank proc
for (int k=0; k<numNeurons; k++) {
int kExt = kIndexExtended(k,loc->nx,loc->ny,loc->nf,loc->halo.lt,loc->halo.rt,loc->halo.dn,loc->halo.up);
pvadata_t value = databuffer[kExt];
if (fabs(value-correctvalue)>=tolerance) {
pvErrorNoExit().printf("Rank %d, restricted index %d, extended index %d, value is %f instead of %f\n",
proc, k, kExt, value, correctvalue);
status = PV_FAILURE;
}
}
}
free(databuffer);
if (status == PV_SUCCESS) {
pvInfo().printf("%s succeeded.\n", argv[0]);
}
else {
pvError().printf("%s failed.\n", argv[0]);
}
}
else {
MPI_Send(layerData,numExtended*sizeof(pvadata_t),MPI_BYTE,rootproc,15,icComm->communicator());
}
MPI_Barrier(icComm->communicator());
return status;
}