本文整理汇总了C++中InterColComm类的典型用法代码示例。如果您正苦于以下问题:C++ InterColComm类的具体用法?C++ InterColComm怎么用?C++ InterColComm使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InterColComm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getTargetLayer
/**
* @time
* @l
*/
int DatastoreDelayTestProbe::outputState(double timed) {
HyPerLayer * l = getTargetLayer();
InterColComm * icComm = l->getParent()->icCommunicator();
const int rcvProc = 0;
if( icComm->commRank() != rcvProc ) {
return PV_SUCCESS;
}
int status = PV_SUCCESS;
int numDelayLevels = l->getParent()->getLayer(0)->getNumDelayLevels();
pvdata_t correctValue = numDelayLevels*(numDelayLevels+1)/2;
if( timed >= numDelayLevels+2 ) {
pvdata_t * V = l->getV();
for( int k=0; k<l->getNumNeuronsAllBatches(); k++ ) {
if( V[k] != correctValue ) {
fprintf(outputstream->fp, "Layer \"%s\": timef = %f, neuron %d: value is %f instead of %d\n", l->getName(), timed, k, V[k], (int) correctValue);
status = PV_FAILURE;
}
}
if( status == PV_SUCCESS) {
fprintf(outputstream->fp, "Layer \"%s\": timef = %f, all neurons have correct value %d\n", l->getName(), timed, (int) correctValue);
}
}
assert(status == PV_SUCCESS);
return PV_SUCCESS;
}
示例2: getTargetLayer
int ArborTestProbe::outputState(double timed)
{
int status = StatsProbe::outputState(timed);
InterColComm * icComm = getTargetLayer()->getParent()->icCommunicator();
const int rcvProc = 0;
if( icComm->commRank() != rcvProc ) {
return 0;
}
for(int b = 0; b < getParent()->getNBatch(); b++){
if(timed==1.0f){
assert((avg[b]>0.2499)&&(avg[b]<0.2501));
}
else if(timed==2.0f){
assert((avg[b]>0.4999)&&(avg[b]<0.5001));
}
else if(timed==3.0f){
assert((avg[b]>0.7499)&&(avg[b]<0.7501));
}
else if(timed>3.0f){
assert((fMin[b]>0.9999)&&(fMin[b]<1.001));
assert((fMax[b]>0.9999)&&(fMax[b]<1.001));
assert((avg[b]>0.9999)&&(avg[b]<1.001));
}
}
return status;
}
示例3: outputState
int KernelProbe::outputState(double timed) {
InterColComm * icComm = parent->icCommunicator();
const int rank = icComm->commRank();
if( rank != 0 ) return PV_SUCCESS;
assert(getTargetConn()!=NULL);
int nxp = getTargetHyPerConn()->xPatchSize();
int nyp = getTargetHyPerConn()->yPatchSize();
int nfp = getTargetHyPerConn()->fPatchSize();
int patchSize = nxp*nyp*nfp;
const pvwdata_t * wdata = getTargetHyPerConn()->get_wDataStart(arborID)+patchSize*kernelIndex;
const pvwdata_t * dwdata = outputPlasticIncr ?
getTargetHyPerConn()->get_dwDataStart(arborID)+patchSize*kernelIndex : NULL;
fprintf(outputstream->fp, "Time %f, Conn \"%s\", nxp=%d, nyp=%d, nfp=%d\n",
timed, getTargetConn()->getName(),nxp, nyp, nfp);
for(int f=0; f<nfp; f++) {
for(int y=0; y<nyp; y++) {
for(int x=0; x<nxp; x++) {
int k = kIndex(x,y,f,nxp,nyp,nfp);
fprintf(outputstream->fp, " x=%d, y=%d, f=%d (index %d):", x, y, f, k);
if(getOutputWeights()) {
fprintf(outputstream->fp, " weight=%f", (float)wdata[k]);
}
if(getOutputPlasticIncr()) {
fprintf(outputstream->fp, " dw=%f", (float)dwdata[k]);
}
fprintf(outputstream->fp,"\n");
}
}
}
return PV_SUCCESS;
}
示例4: getParent
PlasticConnTestProbe::~PlasticConnTestProbe() {
InterColComm * icComm = getParent()->icCommunicator();
if( icComm->commRank() == 0) {
if( !errorPresent ) {
outputStream->printf("No errors detected\n");
}
}
}
示例5: initialize
int MapReduceKernelConn::initialize(const char * name, HyPerCol * hc) {
int status = HyPerConn::initialize(name, hc);
// if (status==PV_SUCCESS) status = setMovieLayerName();
InterColComm *icComm = parent->icCommunicator();
int rootproc = 0;
int file_count = 0;
PV_Stream * dWeightstream = pvp_open_read_file(this->dWeightsListName,
icComm);
if ((dWeightstream == NULL) && (icComm->commRank() == rootproc)) {
fprintf(stderr,
"MapReduceKernelConn::initialize: Cannot open list of dWeight files \"%s\". Exiting.\n",
this->dWeightsListName); // CHECK THIS! // CHECK THIS! this->dWeightsListName was filename but filename is no more
exit(EXIT_FAILURE);
} // dWeightstream == NULL
if (icComm->commRank() == rootproc) {
for (file_count = 0; file_count < num_dWeightFiles; file_count++) {
/*
for (int i_char = 0; i_char < PV_PATH_MAX; i_char++) {
dWeightsList[file_count][i_char] = 0;
}
*/
char * fgetsstatus = fgets(dWeightsList[file_count], PV_PATH_MAX, dWeightstream->fp);
if (fgetsstatus == NULL) {
bool endoffile = feof(dWeightstream->fp) != 0;
if (endoffile) {
fprintf(stderr,
"MapReduceKernelConn::initialize: "
"File of weight files \"%s\" reached end of file before all %d weight files were read. "
"Exiting.\n", dWeightstream->name, num_dWeightFiles); // CHECK THIS! dWeightstream->name was filename but filename is no more
exit(EXIT_FAILURE);
}
else {
int error = ferror(dWeightstream->fp);
assert(error);
fprintf(stderr,
"MapReduceKernelConn::initialize: File of weight files error reading:%s. Exiting.\n", strerror(error));
exit(error);
}
}
else {
// Remove linefeed from end of string
dWeightsList[file_count][PV_PATH_MAX - 1] = '\0';
int len = strlen(dWeightsList[file_count]);
if (len > 1) {
if (dWeightsList[file_count][len - 1] == '\n') {
dWeightsList[file_count][len - 1] = '\0';
}
}
} // fgetsstatus == NULL
} // file_count
this->dWeightsFilename = strdup(dWeightsList[dWeightFileIndex]);
std::cout << "dWeightFile[" << dWeightFileIndex << "] = "
<< dWeightsList[dWeightFileIndex] << std::endl;
} // commRank() == rootproc
return status;
}
示例6: jitter
/**
* - Update the image buffers
* - If the time is a multiple of biasChangetime then the position of the bias (biasX, biasY) changes.
* - With probability persistenceProb the offset position (offsetX, offsetY) remains unchanged.
* - Otherwise, with probability (1-persistenceProb) the offset position performs a random walk
* around the bias position (biasX, biasY).
*
* - If the time is a multiple of displayPeriod then load the next image.
* - If nf=1 then the image is converted to grayscale during the call to read(filename, offsetX, offsetY).
* If nf>1 then the image is loaded with color information preserved.
* - Return true if buffers have changed
*/
bool Movie::updateImage(double time, double dt)
{
if( jitterFlag ) {
jitter();
} // jitterFlag
InterColComm * icComm = getParent()->icCommunicator();
//TODO: Fix movie layer to take with batches. This is commented out for compile
//if(!flipOnTimescaleError && (parent->getTimeScale() > 0 && parent->getTimeScale() < parent->getTimeScaleMin())){
// if (parent->icCommunicator()->commRank()==0) {
// std::cout << "timeScale of " << parent->getTimeScale() << " is less than timeScaleMin of " << parent->getTimeScaleMin() << ", Movie is keeping the same frame\n";
// }
//}
//else{
//Only do this if it's not the first update timestep
//The timestep number is (time - startTime)/(width of timestep), with allowance for roundoff.
//But if we're using adaptive timesteps, the dt passed as a function argument is not the correct (width of timestep).
if(fabs(time - (parent->getStartTime() + parent->getDeltaTime())) > (parent->getDeltaTime()/2)){
int status = getFrame(time, dt);
assert(status == PV_SUCCESS);
}
//nextDisplayTime removed, now using nextUpdateTime in HyPerLayer
//while (time >= nextDisplayTime) {
// nextDisplayTime += displayPeriod;
//}
//Set frame number (member variable in Image)
//Write to timestamp file here when updated
if( icComm->commRank()==0 ) {
//Only write if the parameter is set
if(timestampFile){
std::ostringstream outStrStream;
outStrStream.precision(15);
int kb0 = getLayerLoc()->kb0;
for(int b = 0; b < parent->getNBatch(); b++){
outStrStream << time << "," << b+kb0 << "," << frameNumbers[b] << "," << framePath[b] << "\n";
}
size_t len = outStrStream.str().length();
int status = PV_fwrite(outStrStream.str().c_str(), sizeof(char), len, timestampFile)==len ? PV_SUCCESS : PV_FAILURE;
if (status != PV_SUCCESS) {
fprintf(stderr, "%s \"%s\" error: Movie::updateState failed to write to timestamp file.\n", getKeyword(), name);
exit(EXIT_FAILURE);
}
//Flush buffer
fflush(timestampFile->fp);
}
}
//} // randomMovie
return true;
}
示例7: readCombinedWeightFiles
int InitWeights::readCombinedWeightFiles(PVPatch *** patches, pvwdata_t ** dataStart,int numPatches, const char * fileOfWeightFiles, double * timef) {
InterColComm *icComm = callingConn->getParent()->icCommunicator();
int numArbors = callingConn->numberOfAxonalArborLists();
const PVLayerLoc *preLoc = callingConn->preSynapticLayer()->getLayerLoc();
double timed;
int rootproc = 0;
int max_weight_files = 1; // arbitrary limit...
int num_weight_files = weightParams->getNumWeightFiles();
int file_count=0;
PV_Stream * weightstream = pvp_open_read_file(fileOfWeightFiles, icComm);
if ((weightstream == NULL) && (icComm->commRank() == rootproc) ){
pvError().printf("Cannot open file of weight files \"%s\". Exiting.\n", fileOfWeightFiles);
}
char weightsfilename[PV_PATH_MAX];
while( file_count < num_weight_files ) {
if( icComm->commRank() == rootproc ) {
char * fgetsstatus = fgets(weightsfilename, PV_PATH_MAX, weightstream->fp);
if( fgetsstatus == NULL ) {
bool endoffile = feof(weightstream->fp)!=0;
if( endoffile ) {
pvError().printf("File of weight files \"%s\" reached end of file before all %d weight files were read. Exiting.\n", fileOfWeightFiles, num_weight_files);
}
else {
int error = ferror(weightstream->fp);
assert(error);
pvError().printf("File of weight files: error %d while reading. Exiting.\n", error);
}
}
else {
// Remove linefeed from end of string
weightsfilename[PV_PATH_MAX-1] = '\0';
int len = strlen(weightsfilename);
if (len > 1) {
if (weightsfilename[len-1] == '\n') {
weightsfilename[len-1] = '\0';
}
}
}
} // commRank() == rootproc
int filetype, datatype;
int numParams = NUM_BIN_PARAMS+NUM_WGT_EXTRA_PARAMS;
int params[NUM_BIN_PARAMS+NUM_WGT_EXTRA_PARAMS];
pvp_read_header(weightsfilename, icComm, &timed, &filetype, &datatype, params, &numParams);
const int nxp = callingConn->xPatchSize();
const int nyp = callingConn->yPatchSize();
const int nfp = callingConn->fPatchSize();
int status = PV::readWeights(patches, dataStart, numArbors, numPatches, nxp, nyp, nfp, weightsfilename, icComm, &timed, preLoc);
if (status != PV_SUCCESS) {
pvError().printf("PV::InitWeights::readWeights: problem reading arbor file %s, SHUTTING DOWN\n", weightsfilename);
}
file_count += 1;
} // file_count < num_weight_files
return PV_SUCCESS;
}
示例8: readListOfArborFiles
int InitWeights::readListOfArborFiles(PVPatch *** patches, pvwdata_t ** dataStart, int numPatches, const char * listOfArborsFilename, double * timef) {
int arbor=0;
InterColComm *icComm = callingConn->getParent()->icCommunicator();
int numArbors = callingConn->numberOfAxonalArborLists();
const PVLayerLoc *preLoc = callingConn->preSynapticLayer()->getLayerLoc();
double timed;
PV_Stream * arborstream = pvp_open_read_file(listOfArborsFilename, icComm);
int rootproc = 0;
char arborfilename[PV_PATH_MAX];
while( arbor < callingConn->numberOfAxonalArborLists() ) {
if( icComm->commRank() == rootproc ) {
char * fgetsstatus = fgets(arborfilename, PV_PATH_MAX, arborstream->fp);
if( fgetsstatus == NULL ) {
bool endoffile = feof(arborstream->fp)!=0;
if( endoffile ) {
fprintf(stderr, "File of arbor files \"%s\" reached end of file before all %d arbors were read. Exiting.\n", listOfArborsFilename, numArbors);
exit(EXIT_FAILURE);
}
else {
int error = ferror(arborstream->fp);
assert(error);
fprintf(stderr, "File of arbor files: error %d while reading. Exiting.\n", error);
exit(error);
}
}
else {
// Remove linefeed from end of string
arborfilename[PV_PATH_MAX-1] = '\0';
int len = strlen(arborfilename);
if (len > 1) {
if (arborfilename[len-1] == '\n') {
arborfilename[len-1] = '\0';
}
}
}
} // commRank() == rootproc
int filetype, datatype;
int numParams = NUM_BIN_PARAMS+NUM_WGT_EXTRA_PARAMS;
int params[NUM_BIN_PARAMS+NUM_WGT_EXTRA_PARAMS];
pvp_read_header(arborfilename, icComm, &timed, &filetype, &datatype, params, &numParams);
int thisfilearbors = params[INDEX_NBANDS];
const int nxp = callingConn->xPatchSize();
const int nyp = callingConn->yPatchSize();
const int nfp = callingConn->fPatchSize();
int status = PV::readWeights(patches ? &patches[arbor] : NULL, &dataStart[arbor], numArbors-arbor, numPatches, nxp, nyp, nfp, arborfilename, icComm, &timed, preLoc);
if (status != PV_SUCCESS) {
fprintf(stderr, "PV::InitWeights::readWeights: problem reading arbor file %s, SHUTTING DOWN\n", arborfilename);
exit(EXIT_FAILURE);
}
arbor += thisfilearbors;
} // while
pvp_close_file(arborstream, icComm);
return PV_SUCCESS;
}
示例9: checkpointWrite
int LCALIFLayer::checkpointWrite(const char * cpDir) {
int status = LIFGap::checkpointWrite(cpDir);
InterColComm * icComm = parent->icCommunicator();
char basepath[PV_PATH_MAX];
char filename[PV_PATH_MAX];
int lenbase = snprintf(basepath, PV_PATH_MAX, "%s/%s", cpDir, name);
if (lenbase+strlen("_integratedSpikeCount.pvp") >= PV_PATH_MAX) { // currently _integratedSpikeCount.pvp is the longest suffix needed
if (icComm->commRank()==0) {
fprintf(stderr, "LCALIFLayer::checkpointWrite error in layer \"%s\". Base pathname \"%s/%s_\" too long.\n", name, cpDir, name);
}
abort();
}
double timed = (double) parent->simulationTime();
int chars_needed = snprintf(filename, PV_PATH_MAX, "%s_integratedSpikeCount.pvp", basepath);
assert(chars_needed < PV_PATH_MAX);
writeBufferFile(filename, icComm, timed, &integratedSpikeCount, 1, /*extended*/false, getLayerLoc());
chars_needed = snprintf(filename, PV_PATH_MAX, "%s_Vadpt.pvp", basepath);
assert(chars_needed < PV_PATH_MAX);
writeBufferFile(filename, icComm, timed, &Vadpt, 1, /*extended*/false, getLayerLoc());
chars_needed = snprintf(filename, PV_PATH_MAX, "%s_Vattained.pvp", basepath);
assert(chars_needed < PV_PATH_MAX);
writeBufferFile(filename, icComm, timed, &Vattained, 1, /*extended*/false, getLayerLoc());
chars_needed = snprintf(filename, PV_PATH_MAX, "%s_Vmeminf.pvp", basepath);
assert(chars_needed < PV_PATH_MAX);
writeBufferFile(filename, icComm, timed, &Vmeminf, 1, /*extended*/false, getLayerLoc());
chars_needed = snprintf(filename, PV_PATH_MAX, "%s_G_Norm.pvp", basepath);
assert(chars_needed < PV_PATH_MAX);
writeBufferFile(filename, icComm, timed, &G_Norm, 1, /*extended*/false, getLayerLoc());
chars_needed = snprintf(filename, PV_PATH_MAX, "%s_GSynExcEffective.pvp", basepath);
assert(chars_needed < PV_PATH_MAX);
writeBufferFile(filename, icComm, timed, &GSynExcEffective, 1, /*extended*/false, getLayerLoc());
chars_needed = snprintf(filename, PV_PATH_MAX, "%s_GSynInhEffective.pvp", basepath);
assert(chars_needed < PV_PATH_MAX);
writeBufferFile(filename, icComm, timed, &GSynInhEffective, 1, /*extended*/false, getLayerLoc());
chars_needed = snprintf(filename, PV_PATH_MAX, "%s_excitatoryNoise.pvp", basepath);
assert(chars_needed < PV_PATH_MAX);
writeBufferFile(filename, icComm, timed, &excitatoryNoise, 1, /*extended*/false, getLayerLoc());
chars_needed = snprintf(filename, PV_PATH_MAX, "%s_inhibitoryNoise.pvp", basepath);
assert(chars_needed < PV_PATH_MAX);
writeBufferFile(filename, icComm, timed, &inhibitoryNoise, 1, /*extended*/false, getLayerLoc());
chars_needed = snprintf(filename, PV_PATH_MAX, "%s_inhibNoiseB.pvp", basepath);
assert(chars_needed < PV_PATH_MAX);
writeBufferFile(filename, icComm, timed, &inhibNoiseB, 1, /*extended*/false, getLayerLoc());
return status;
}
示例10: outputState
/**
* @time
* @l
*/
int GradientCheckProbe::outputState(double timed)
{
#ifdef PV_USE_MPI
InterColComm * icComm = parent->icCommunicator();
MPI_Comm comm = icComm->globalCommunicator();
int rank = icComm->globalCommRank();
#endif // PV_USE_MPI
std::cout << name << " probeOutputState on timestep " << timed << "\n";
return PV_SUCCESS;
}
示例11: getLayerLoc
int ANNWeightedErrorLayer::allocateDataStructures()
{
int status = HyPerLayer::allocateDataStructures();
int nf = getLayerLoc()->nf;
errWeights = (float *) calloc(nf, sizeof(float *));
for(int i_weight = 0; i_weight < nf; i_weight++){
errWeights[i_weight] = 1.0f;
}
PV_Stream * pvstream = NULL;
InterColComm *icComm = getParent()->icCommunicator();
char errWeight_string[PV_PATH_MAX];
if (getParent()->icCommunicator()->commRank()==0) {
PV_Stream * errWeights_stream = pvp_open_read_file(errWeightsFileName, icComm);
for(int i_weight = 0; i_weight < nf; i_weight++){
char * fgetsstatus = fgets(errWeight_string, PV_PATH_MAX, errWeights_stream->fp);
if( fgetsstatus == NULL ) {
bool endoffile = feof(errWeights_stream->fp)!=0;
if( endoffile ) {
fprintf(stderr, "File of errWeights \"%s\" reached end of file before all %d errWeights were read. Exiting.\n", errWeightsFileName, nf);
exit(EXIT_FAILURE);
}
else {
int error = ferror(errWeights_stream->fp);
assert(error);
fprintf(stderr, "File of errWeights: error %d while reading. Exiting.\n", error);
exit(error);
}
}
else {
// Remove linefeed from end of string
errWeight_string[PV_PATH_MAX-1] = '\0';
int len = strlen(errWeight_string);
if (len > 1) {
if (errWeight_string[len-1] == '\n') {
errWeight_string[len-1] = '\0';
}
}
} // fgetstatus
// set errWeight = chance / relative fraction
float errWeight_tmp = atof(errWeight_string);
fprintf(stderr, "errWeight %i = %f\n", i_weight, errWeight_tmp);
errWeights[i_weight] = (1.0/nf) / errWeight_tmp;
} // i_weight
} // commRank() == rootproc
#ifdef PV_USE_MPI
//broadcast errWeights
MPI_Bcast(errWeights, nf, MPI_FLOAT, 0, icComm->communicator());
#endif // PV_USE_MPI
}
示例12: getParent
// advance by n_skip lines through file of filenames, always advancing at least one line
const char * Movie::getNextFileName(int n_skip, int batchIdx) {
InterColComm * icComm = getParent()->icCommunicator();
assert(icComm->commRank() == 0);
const char* outFilename = NULL;
int numskip = n_skip < 1 ? 1 : n_skip;
for (int i_skip = 0; i_skip < numskip; i_skip++){
outFilename = advanceFileName(batchIdx);
}
if (echoFramePathnameFlag){
printf("%f, %d: %s\n", parent->simulationTime(), batchIdx, outFilename);
}
return outFilename;
}
示例13: getTargetHyPerConn
/**
* @timef
*/
int PlasticConnTestProbe::outputState(double timed) {
HyPerConn * c = getTargetHyPerConn();
InterColComm * icComm = c->getParent()->icCommunicator();
const int rcvProc = 0;
if( icComm->commRank() != rcvProc ) {
return PV_SUCCESS;
}
assert(getTargetConn()!=NULL);
outputStream->printf(" Time %f, connection \"%s\":\n", timed, getTargetName());
const pvwdata_t * w = c->get_wDataHead(getArbor(), getKernelIndex());
const pvdata_t * dw = c->get_dwDataHead(getArbor(), getKernelIndex());
if( getOutputPlasticIncr() && dw == NULL ) {
pvError().printf("PlasticConnTestProbe \"%s\": connection \"%s\" has dKernelData(%d,%d) set to null.\n", getName(), getTargetName(), getKernelIndex(), getArbor());
}
int nxp = c->xPatchSize();
int nyp = c->yPatchSize();
int nfp = c->fPatchSize();
int status = PV_SUCCESS;
for( int k=0; k<nxp*nyp*nfp; k++ ) {
int x=kxPos(k,nxp,nyp,nfp);
int wx = (nxp-1)/2 - x; // assumes connection is one-to-one
if(getOutputWeights()) {
pvdata_t wCorrect = timed*wx;
pvdata_t wObserved = w[k];
if( fabs( ((double) (wObserved - wCorrect))/timed ) > 1e-4 ) {
int y=kyPos(k,nxp,nyp,nfp);
int f=featureIndex(k,nxp,nyp,nfp);
outputStream->printf(" index %d (x=%d, y=%d, f=%d: w = %f, should be %f\n", k, x, y, f, wObserved, wCorrect);
}
}
if(timed > 0 && getOutputPlasticIncr() && dw != NULL) {
pvdata_t dwCorrect = wx;
pvdata_t dwObserved = dw[k];
if( dwObserved != dwCorrect ) {
int y=kyPos(k,nxp,nyp,nfp);
int f=featureIndex(k,nxp,nyp,nfp);
outputStream->printf(" index %d (x=%d, y=%d, f=%d: dw = %f, should be %f\n", k, x, y, f, dwObserved, dwCorrect);
}
}
}
assert(status==PV_SUCCESS);
if( status == PV_SUCCESS ) {
if (getOutputWeights()) { outputStream->printf(" All weights are correct.\n"); }
if (getOutputPlasticIncr()) { outputStream->printf(" All plastic increments are correct.\n"); }
}
if(getOutputPatchIndices()) {
patchIndices(c);
}
return PV_SUCCESS;
}
示例14: getLayerLoc
int GatePoolTestLayer::updateState(double timef, double dt) {
//Do update state of ANN Layer first
ANNLayer::updateState(timef, dt);
//Grab layer size
const PVLayerLoc* loc = getLayerLoc();
int nx = loc->nx;
int ny = loc->ny;
int nxGlobal = loc->nxGlobal;
int nyGlobal = loc->nyGlobal;
int nf = loc->nf;
int kx0 = loc->kx0;
int ky0 = loc->ky0;
bool isCorrect = true;
//Grab the activity layer of current layer
for(int b = 0; b < loc->nbatch; b++) {
const pvdata_t * A = getActivity() + b * getNumExtended();
//We only care about restricted space, but iY and iX are extended
for(int iY = loc->halo.up; iY < ny + loc->halo.up; iY++) {
for(int iX = loc->halo.lt; iX < nx + loc->halo.lt; iX++) {
for(int iFeature = 0; iFeature < nf; iFeature++) {
int ext_idx = kIndex(iX, iY, iFeature, nx+loc->halo.lt+loc->halo.rt, ny+loc->halo.dn+loc->halo.up, nf);
float actualvalue = A[ext_idx];
int xval = (iX + kx0 - loc->halo.lt)/2;
int yval = (iY + ky0 - loc->halo.up)/2;
assert(xval >= 0 && xval < loc->nxGlobal);
assert(yval >= 0 && yval < loc->nxGlobal);
float expectedvalue;
expectedvalue = iFeature * 64 + yval * 16 + xval * 2 + 4.5;
expectedvalue*=4;
if(fabs(actualvalue - expectedvalue) >= 1e-4) {
pvErrorNoExit() << "Connection " << name << " Mismatch at (" << iX << "," << iY << ") : actual value: " << actualvalue << " Expected value: " << expectedvalue << ". Discrepancy is a whopping " << actualvalue - expectedvalue << "! Horrors!" << "\n";
isCorrect = false;
}
}
}
}
}
if(!isCorrect) {
InterColComm * icComm = parent->icCommunicator();
MPI_Barrier(icComm->communicator()); // If there is an error, make sure that MPI doesn't kill the run before process 0 reports the error.
exit(-1);
}
return PV_SUCCESS;
}
示例15: getParent
bool DisparityMovie::updateImage(double timef, double dt){
InterColComm * icComm = getParent()->icCommunicator();
assert(!readPvpFile);
if(fabs(timef - (parent->getStartTime() + parent->getDeltaTime())) > (parent->getDeltaTime()/2)){
//If disparity is over numDisparity, read new image and reset index
if(disparityIndex >= numDisparity - 1){
if (filename != NULL) free(filename);
filename = strdup(getNextFileName(skipFrameIndex));
disparityIndex = 0;
frameCount++;
}
else{
disparityIndex++;
}
}
assert(filename != NULL);
//Set frame number (member variable in Image)
int newOffsetX;
if((frameCount + frameOffset) % 2 == 0){
newOffsetX = this->offsets[0];
}
else{
newOffsetX = this->offsets[0] + (disparityIndex * dPixelDisparity);
}
int status = readImage(filename, newOffsetX, this->offsets[1], this->offsetAnchor);
if( status != PV_SUCCESS ) {
fprintf(stderr, "Movie %s: Error reading file \"%s\"\n", name, filename);
abort();
}
//Write to timestamp file here when updated
if( icComm->commRank()==0 ) {
//Only write if the parameter is set
if(timestampFile){
std::ostringstream outStrStream;
outStrStream.precision(15);
outStrStream << frameNumber << "," << timef << "," << filename << "\n";
size_t len = outStrStream.str().length();
int status = PV_fwrite(outStrStream.str().c_str(), sizeof(char), len, timestampFile)==len ? PV_SUCCESS : PV_FAILURE;
if (status != PV_SUCCESS) {
fprintf(stderr, "%s \"%s\" error: Movie::updateState failed to write to timestamp file.\n", parent->parameters()->groupKeywordFromName(name), name);
exit(EXIT_FAILURE);
}
//Flush buffer
fflush(timestampFile->fp);
}
}
return true;
}