|
21 | 21 |
|
22 | 22 | #pragma once |
23 | 23 |
|
24 | | -#include "pmacc_types.hpp" |
| 24 | +#include "simulation_defines.hpp" |
25 | 25 | #include "memory/buffers/GridBuffer.hpp" |
26 | 26 | #include "mappings/simulation/GridController.hpp" |
27 | 27 |
|
@@ -61,13 +61,19 @@ namespace picongpu |
61 | 61 | ) : |
62 | 62 | SimulationFieldHelper<MappingDesc>( cellDescription ), |
63 | 63 | fieldTmp( nullptr ), |
| 64 | + fieldTmpRecv( nullptr ), |
64 | 65 | m_slotId( slotId ) |
65 | 66 | { |
66 | | - m_commTag = |
| 67 | + m_commTagScatter = |
67 | 68 | ++PMacc::traits::detail::GetUniqueTypeId< uint8_t >::counter + |
68 | 69 | SPECIES_FIRSTTAG; |
| 70 | + m_commTagGather = ++PMacc::traits::detail::GetUniqueTypeId< uint8_t >::counter + |
| 71 | + SPECIES_FIRSTTAG; |
| 72 | + |
| 73 | + fieldTmp = new GridBuffer <ValueType, simDim >( cellDescription.getGridLayout( ) ); |
69 | 74 |
|
70 | | - fieldTmp = new GridBuffer<ValueType, simDim > ( cellDescription.getGridLayout( ) ); |
| 75 | + if( fieldTmpSupportGatherCommunication ) |
| 76 | + fieldTmpRecv = new GridBuffer< ValueType, simDim >( fieldTmp->getDeviceBuffer(), cellDescription.getGridLayout( ) ); |
71 | 77 |
|
72 | 78 | /** \todo The exchange has to be resetted and set again regarding the |
73 | 79 | * temporary "Fill-"Functor we want to use. |
@@ -165,9 +171,21 @@ namespace picongpu |
165 | 171 | }; |
166 | 172 |
|
167 | 173 | } |
168 | | - // std::cout << "ex " << i << " x=" << guardingCells[0] << " y=" << guardingCells[1] << " z=" << guardingCells[2] << std::endl; |
169 | | - fieldTmp->addExchangeBuffer( i, guardingCells, m_commTag ); |
| 174 | + |
| 175 | + fieldTmp->addExchangeBuffer( i, guardingCells, m_commTagScatter ); |
| 176 | + |
| 177 | + if( fieldTmpRecv ) |
| 178 | + { |
| 179 | + /* guarding cells depend on direction |
| 180 | + * for negative direction use originGuard else endGuard (relative direction ZERO is ignored) |
| 181 | + * don't switch end and origin because this is a read buffer and not send buffer |
| 182 | + */ |
| 183 | + for ( uint32_t d = 0; d < simDim; ++d ) |
| 184 | + guardingCells[d] = ( relativMask[d] == -1 ? originGuard[d] : endGuard[d] ); |
| 185 | + fieldTmpRecv->addExchange( GUARD, i, guardingCells, m_commTagGather ); |
| 186 | + } |
170 | 187 | } |
| 188 | + |
171 | 189 | } |
172 | 190 |
|
173 | 191 | FieldTmp::~FieldTmp( ) |
@@ -224,16 +242,29 @@ namespace picongpu |
224 | 242 | EventTask FieldTmp::asyncCommunication( EventTask serialEvent ) |
225 | 243 | { |
226 | 244 | EventTask ret; |
227 | | - __startTransaction( serialEvent ); |
| 245 | + __startTransaction( serialEvent + m_gatherEv + m_scatterEv ); |
228 | 246 | FieldFactory::getInstance( ).createTaskFieldReceiveAndInsert( *this ); |
229 | 247 | ret = __endTransaction( ); |
230 | 248 |
|
231 | | - __startTransaction( serialEvent ); |
| 249 | + __startTransaction( serialEvent + m_gatherEv + m_scatterEv); |
232 | 250 | FieldFactory::getInstance( ).createTaskFieldSend( *this ); |
233 | 251 | ret += __endTransaction( ); |
| 252 | + m_scatterEv = ret; |
234 | 253 | return ret; |
235 | 254 | } |
236 | 255 |
|
| 256 | + EventTask FieldTmp::asyncCommunicationGather( EventTask serialEvent ) |
| 257 | + { |
| 258 | + PMACC_VERIFY_MSG( |
| 259 | + fieldTmpSupportGatherCommunication == true, |
| 260 | + "fieldTmpSupportGatherCommunication in memory.param must be set to true" |
| 261 | + ); |
| 262 | + |
| 263 | + if( fieldTmpRecv != nullptr ) |
| 264 | + m_gatherEv = fieldTmpRecv->asyncCommunication( serialEvent + m_scatterEv + m_gatherEv ); |
| 265 | + return m_gatherEv; |
| 266 | + } |
| 267 | + |
237 | 268 | void FieldTmp::bashField( uint32_t exchangeType ) |
238 | 269 | { |
239 | 270 | ExchangeMapping<GUARD, MappingDesc> mapper( this->cellDescription, exchangeType ); |
@@ -315,10 +346,4 @@ namespace picongpu |
315 | 346 | return "FieldTmp"; |
316 | 347 | } |
317 | 348 |
|
318 | | - uint32_t |
319 | | - FieldTmp::getCommTag( ) |
320 | | - { |
321 | | - return m_commTag; |
322 | | - } |
323 | | - |
324 | 349 | } // namespace picongpu |
0 commit comments