int main(int argc, char * argv[])
{
   PV_Init* initObj = new PV_Init(&argc, &argv, false/*allowUnrecognizedArguments*/);
   PV_Arguments * arguments = initObj->getArguments();
   if (arguments->getParamsFile()==NULL) {
      int rank = 0;
      MPI_Comm_rank(MPI_COMM_WORLD, &rank);
      if (rank==0) {
         fprintf(stderr, "%s does not take a -p argument; the necessary param file is hardcoded.\n", argv[0]);
      }
      MPI_Barrier(MPI_COMM_WORLD);
      exit(EXIT_FAILURE);
   }

   arguments->setParamsFile("input/test_gauss2d.params");
   const char * pre_layer_name = "test_gauss2d pre";
   const char * post_layer_name = "test_gauss2d post";
   const char * pre2_layer_name = "test_gauss2d pre 2";
   const char * post2_layer_name = "test_gauss2d post 2";

   initObj->initialize();
   PV::HyPerCol * hc = new PV::HyPerCol("test_gauss2d column", initObj);
   PV::Example * pre = new PV::Example(pre_layer_name, hc);
   assert(pre);
   PV::Example * post = new PV::Example(post_layer_name, hc);
   assert(post);

   
   PV::HyPerConn * cHyPer = new HyPerConn("test_gauss2d hyperconn", hc);

   PV::HyPerConn * cKernel = new HyPerConn("test_gauss2d kernelconn", hc);

   PV::Example * pre2 = new PV::Example(pre2_layer_name, hc);
   assert(pre2);
   PV::Example * post2 = new PV::Example(post2_layer_name, hc);
   assert(post2);

   PV::HyPerConn * cHyPer1to2 =
         new HyPerConn("test_gauss2d hyperconn 1 to 2", hc);
   assert(cHyPer1to2);

   PV::HyPerConn * cKernel1to2 =
         new HyPerConn("test_gauss2d kernelconn 1 to 2", hc);
   assert(cKernel1to2);

   PV::HyPerConn * cHyPer2to1 =
         new HyPerConn("test_gauss2d hyperconn 2 to 1", hc);
   assert(cHyPer2to1);

   PV::HyPerConn * cKernel2to1 =
         new HyPerConn("test_gauss2d kernelconn 2 to 1", hc);
   assert(cKernel2to1);
   
   int status = 0;

   for (int l=0; l<hc->numberOfLayers(); l++) {
      status = hc->getLayer(l)->communicateInitInfo();
      assert(status==PV_SUCCESS);
   }
   for (int c=0; c<hc->numberOfConnections(); c++) {
      status = hc->getConnection(c)->communicateInitInfo();
      assert(status==PV_SUCCESS);
   }
   for (int l=0; l<hc->numberOfLayers(); l++) {
      status = hc->getLayer(l)->allocateDataStructures();
      assert(status==PV_SUCCESS);
   }
   for( int c=0; c<hc->numberOfConnections(); c++ ) {
      BaseConnection * baseConn = hc->getConnection(c);
      HyPerConn * conn = dynamic_cast<HyPerConn *>(baseConn);
      conn->allocateDataStructures();
      conn->writeWeights(0, true);
   }

   const int axonID = 0;
   int num_pre_extended = pre->clayer->numExtended;
   assert(num_pre_extended == cHyPer->getNumWeightPatches());

   for (int kPre = 0; kPre < num_pre_extended; kPre++) {
     //printf("testing testing 1 2 3...\n");
     status = check_kernel_vs_hyper(cHyPer, cKernel, kPre, axonID);
     assert(status==0);
     status = check_kernel_vs_hyper(cHyPer1to2, cKernel1to2, kPre, axonID);
     assert(status==0);
     status = check_kernel_vs_hyper(cHyPer2to1, cKernel2to1, kPre, axonID);
     assert(status==0);
   }

   delete hc;
   delete initObj;
   return 0;
}
Example #2
0
int main(int argc, char * argv[])
{
   PV_Init * initObj = new PV_Init(&argc, &argv, false/*allowUnrecognizedArguments*/);
   PV::HyPerCol * hc = new PV::HyPerCol("test_cocirc column", initObj);
   
   const char * preLayerName = "test_cocirc pre";
   const char * postLayerName = "test_cocirc post";
   
   PV::Example * pre = new PV::Example(preLayerName, hc);
   assert(pre);
   PV::Example * post = new PV::Example(postLayerName, hc);
   assert(post);
   PV::HyPerConn * cHyPer = new HyPerConn("test_cocirc hyperconn", hc);
   assert(cHyPer);
   PV::HyPerConn * cCocirc = new HyPerConn("test_cocirc cocircconn", hc);
   assert(cCocirc);
   
   PV::Example * pre2 = new PV::Example("test_cocirc pre 2", hc);
   assert(pre2);
   PV::Example * post2 = new PV::Example("test_cocirc post 2", hc);
   assert(post2);
   PV::HyPerConn * cHyPer1to2 = new HyPerConn("test_cocirc hyperconn 1 to 2", hc);
   assert(cHyPer1to2);
   PV::HyPerConn * cCocirc1to2 = new HyPerConn("test_cocirc cocircconn 1 to 2", hc);
   assert(cCocirc1to2);
   PV::HyPerConn * cHyPer2to1 = new HyPerConn("test_cocirc hyperconn 2 to 1", hc);
   assert(cHyPer2to1);
   PV::HyPerConn * cCocirc2to1 = new HyPerConn("test_cocirc cocircconn 2 to 1", hc);
   assert(cCocirc2to1);

   hc->ensureDirExists(hc->getOutputPath());
   
   for (int l=0; l<hc->numberOfLayers(); l++) {
      HyPerLayer * layer = hc->getLayer(l);
      int status = layer->communicateInitInfo();
      assert(status==PV_SUCCESS);
      layer->setInitInfoCommunicatedFlag();
   }   
   for (int c=0; c<hc->numberOfConnections(); c++) {
      BaseConnection * conn = hc->getConnection(c);
      int status = conn->communicateInitInfo();
      assert(status==PV_SUCCESS);
      conn->setInitInfoCommunicatedFlag();
   }
   
   for (int l=0; l<hc->numberOfLayers(); l++) {
      HyPerLayer * layer = hc->getLayer(l);
      int status = layer->allocateDataStructures();
      assert(status==PV_SUCCESS);
      layer->setDataStructuresAllocatedFlag();
   }
   
   for (int c=0; c<hc->numberOfConnections(); c++) {
      BaseConnection * conn = hc->getConnection(c);
      int status = conn->allocateDataStructures();
      assert(status==PV_SUCCESS);
      conn->setDataStructuresAllocatedFlag();
   }

   const int axonID = 0;
   int num_pre_extended = pre->clayer->numExtended;
   assert(num_pre_extended == cHyPer->getNumWeightPatches());

   int status = 0;
   for (int kPre = 0; kPre < num_pre_extended; kPre++) {
      status = check_cocirc_vs_hyper(cHyPer, cCocirc, kPre, axonID);
      assert(status==0);
      status = check_cocirc_vs_hyper(cHyPer1to2, cCocirc1to2, kPre, axonID);
      assert(status==0);
      status = check_cocirc_vs_hyper(cHyPer2to1, cCocirc2to1, kPre, axonID);
      assert(status==0);
   }

   delete hc;
   delete initObj;
   return 0;
}