8 #include "BaseDelivery.hpp" 9 #include "columns/HyPerCol.hpp" 10 #include "layers/HyPerLayer.hpp" 11 #include "utils/MapLookupByType.hpp" 15 BaseDelivery::BaseDelivery(
char const *name, HyPerCol *hc) { initialize(name, hc); }
17 int BaseDelivery::initialize(
char const *name, HyPerCol *hc) {
18 return BaseObject::initialize(name, hc);
21 void BaseDelivery::setObjectType() { mObjectType =
"BaseDelivery"; }
30 if (ioFlag == PARAMS_IO_READ) {
32 this->parent->parameters()->ioParamValueRequired(ioFlag, this->getName(),
"channelCode", &ch);
34 case CHANNEL_EXC: mChannelCode = CHANNEL_EXC;
break;
35 case CHANNEL_INH: mChannelCode = CHANNEL_INH;
break;
36 case CHANNEL_INHB: mChannelCode = CHANNEL_INHB;
break;
37 case CHANNEL_GAP: mChannelCode = CHANNEL_GAP;
break;
38 case CHANNEL_NORM: mChannelCode = CHANNEL_NORM;
break;
39 case CHANNEL_NOUPDATE: mChannelCode = CHANNEL_NOUPDATE;
break;
41 if (parent->getCommunicator()->globalCommRank() == 0) {
43 "%s: channelCode %d is not a valid channel.\n", this->getDescription_c(), ch);
45 MPI_Barrier(this->parent->getCommunicator()->globalCommunicator());
50 else if (ioFlag == PARAMS_IO_WRITE) {
51 int ch = (int)mChannelCode;
52 parent->parameters()->ioParamValueRequired(ioFlag, this->getName(),
"channelCode", &ch);
61 parent->parameters()->ioParamValue(
69 parent->parameters()->ioParamValue(
76 if (parent->getCommunicator()->globalCommRank() == 0) {
79 "%s: receiveGpu is set to true in params, but PetaVision was compiled without GPU " 87 BaseDelivery::communicateInitInfo(std::shared_ptr<CommunicateInitInfoMessage const> message) {
88 if (mConnectionData ==
nullptr) {
89 mConnectionData = mapLookupByType<ConnectionData>(message->mHierarchy, getDescription());
91 mConnectionData ==
nullptr,
92 "%s requires a ConnectionData component.\n",
95 pvAssert(mConnectionData);
97 if (parent->getCommunicator()->globalCommRank() == 0) {
99 "%s must wait until the ConnectionData component has finished its " 100 "communicateInitInfo stage.\n",
103 return Response::POSTPONE;
106 mPreLayer = mConnectionData->
getPre();
107 mPostLayer = mConnectionData->
getPost();
108 pvAssert(mPreLayer !=
nullptr and mPostLayer !=
nullptr);
110 int numChannelsCheck = 0;
111 int channelAsInt = (int)getChannelCode();
112 if (channelAsInt >= 0) {
113 int status = getPostLayer()->requireChannel(channelAsInt, &numChannelsCheck);
114 if (status != PV_SUCCESS) {
115 if (parent->getCommunicator()->globalCommRank() == 0) {
117 "%s: postsynaptic layer \"%s\" failed to add channel %d\n",
119 getPostLayer()->getName(),
122 MPI_Barrier(parent->getCommunicator()->globalCommunicator());
127 mUsingGPUFlag = mReceiveGpu;
128 #endif // PV_USE_CUDA 130 return Response::SUCCESS;
virtual void ioParam_receiveGpu(enum ParamsIOFlag ioFlag)
receiveGpu: If PetaVision was compiled with GPU acceleration and this flag is set to true...
int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
virtual void ioParam_channelCode(enum ParamsIOFlag ioFlag)
channelCode: Specifies which channel in the post layer this connection is attached to ...
bool getInitInfoCommunicatedFlag() const