Skip to content

Commit c66fedf

Browse files
a kernel need to be an instance of a functor
- remove `PMACC_TYPEKERNEL` - use `PMACC_KERNEL` - create the instance of a functor inside the user code
1 parent bc995bf commit c66fedf

File tree

35 files changed

+68
-75
lines changed

35 files changed

+68
-75
lines changed

examples/SingleParticleCurrent/include/particles/ParticlesInitOneParticle.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class ParticlesInitOneParticle
130130
std::cout << "localSuperCell: " << localSuperCell << std::endl;
131131
std::cout << "cellInSuperCell: " << cellInSuperCell << std::endl;
132132

133-
PMACC_TYPEKERNEL(kernelAddOneParticle)
133+
PMACC_KERNEL(kernelAddOneParticle{})
134134
(1, 1)
135135
(parClass.getDeviceParticlesBox(),
136136
localSuperCell, cellInSuperCell);

examples/SingleParticleRadiationWithLaser/include/particles/ParticlesInitOneParticle.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class ParticlesInitOneParticle
131131
localSuperCell = localSuperCell + cellDescription.getGuardingSuperCells();
132132

133133

134-
PMACC_TYPEKERNEL(kernelAddOneParticle)
134+
PMACC_KERNEL(kernelAddOneParticle{})
135135
(1, 1)
136136
(parClass.getDeviceParticlesBox(),
137137
localSuperCell, cellInSuperCell);

examples/SingleParticleTest/include/particles/ParticlesInitOneParticle.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class ParticlesInitOneParticle
127127
localSuperCell = localSuperCell + cellDescription.getGuardingSuperCells();
128128

129129

130-
PMACC_TYPEKERNEL(kernelAddOneParticle)
130+
PMACC_KERNEL(kernelAddOneParticle{})
131131
(1, 1)
132132
(parClass.getDeviceParticlesBox(),
133133
localSuperCell, cellInSuperCell);

src/libPMacc/examples/gameOfLife2D/include/Evolution.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ namespace gol
8383
buffWrite(blockCell + threadIndex) = isLife;
8484
}
8585
};
86-
86+
8787
struct randomInit
8888
{
8989
template<class BoxWriteOnly, class Mapping>
@@ -136,7 +136,7 @@ namespace gol
136136
GridController<DIM2>& gc = Environment<DIM2>::get().GridController();
137137
uint32_t seed = gc.getGlobalSize() + gc.getGlobalRank();
138138

139-
PMACC_TYPEKERNEL(kernel::randomInit)
139+
PMACC_KERNEL(kernel::randomInit{})
140140
(mapper.getGridDim(), MappingDesc::SuperCellSize::toRT())
141141
(
142142
writeBox,
@@ -149,7 +149,7 @@ namespace gol
149149
void run(const DBox& readBox, const DBox & writeBox)
150150
{
151151
AreaMapping < Area, MappingDesc > mapper(mapping);
152-
PMACC_TYPEKERNEL(kernel::evolution)
152+
PMACC_KERNEL(kernel::evolution{})
153153
(mapper.getGridDim(), MappingDesc::SuperCellSize::toRT())
154154
(readBox,
155155
writeBox,

src/libPMacc/include/cuSTL/algorithm/kernel/Foreach.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ namespace kernel
6666
auto blockDim = BlockDim::toRT(); \
6767
detail::SphericMapper<Zone::dim, BlockDim> mapper; \
6868
using namespace PMacc; \
69-
PMACC_TYPEKERNEL(detail::kernelForeach)(mapper.cudaGridDim(p_zone.size), blockDim) \
69+
PMACC_KERNEL(detail::kernelForeach{})(mapper.cudaGridDim(p_zone.size), blockDim) \
7070
/* c0_shifted, c1_shifted, ... */ \
7171
(mapper, BOOST_PP_ENUM(N, SHIFTED_CURSOR, _), lambda::make_Functor(functor)); \
7272
}

src/libPMacc/include/cuSTL/algorithm/kernel/ForeachBlock.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ BOOST_PP_REPEAT_FROM_TO(1, BOOST_PP_INC(FOREACH_KERNEL_MAX_PARAMS), KERNEL_FOREA
9494
auto blockDim = ThreadBlock::toRT(); \
9595
detail::SphericMapper<Zone::dim, BlockDim> mapper; \
9696
using namespace PMacc; \
97-
PMACC_TYPEKERNEL(detail::kernelForeachBlock)(mapper.cudaGridDim(p_zone.size), blockDim) \
97+
PMACC_KERNEL(detail::kernelForeachBlock{})(mapper.cudaGridDim(p_zone.size), blockDim) \
9898
/* c0_shifted, c1_shifted, ... */ \
9999
(mapper, BOOST_PP_ENUM(N, SHIFTED_CURSOR, _), lambda::make_Functor(functor)); \
100100
}

src/libPMacc/include/cuSTL/algorithm/kernel/run-time/Foreach.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ math::Size_t<DIM3> getBestCudaBlockDim(const math::Size_t<dim> gridDim)
142142
); \
143143
kernel::detail::SphericMapper<Zone::dim> mapper; \
144144
using namespace PMacc; \
145-
PMACC_TYPEKERNEL(kernel::detail::kernelForeach)(mapper.cudaGridDim(p_zone.size, this->_blockDim), blockDim) \
145+
PMACC_KERNEL(kernel::detail::kernelForeach{})(mapper.cudaGridDim(p_zone.size, this->_blockDim), blockDim) \
146146
/* c0_shifted, ..., cN_shifted */ \
147147
(mapper, BOOST_PP_ENUM(N, SHIFTED_CURSOR, _), lambda::make_Functor(functor)); \
148148
}

src/libPMacc/include/eventSystem/events/kernelEvents.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,5 @@ namespace exec
279279
*/
280280
#define PMACC_KERNEL( ... ) PMacc::exec::kernel( __VA_ARGS__, __FILE__, static_cast< size_t >( __LINE__ ) )
281281

282-
/** create a kernel object out of a functor type name
283-
*
284-
* this macro add the current filename and line number to the kernel object
285-
*
286-
* @param ... type of the kernel functor
287-
*/
288-
#define PMACC_TYPEKERNEL( ... ) PMacc::exec::kernel( __VA_ARGS__{}, __FILE__, static_cast< size_t >( __LINE__ ) )
289282

290283
#include "eventSystem/events/kernelEvents.tpp"

src/libPMacc/include/nvidia/reduce/Reduce.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ namespace kernel
6262
Type* s_mem=(Type*)s_mem_extern;
6363

6464

65-
65+
6666
bool isActive = (tid < src_count);
6767

6868
if(isActive)
@@ -91,7 +91,7 @@ namespace kernel
9191
/* New chunks is half number of chunks rounded up for uneven counts
9292
* --> local_tid=0 will reduce the single element for an odd number of values at the end */
9393
chunk_count = (chunk_count + 1) / 2;
94-
94+
9595
isActive = (tid < src_count) && !(localId != 0 && localId >= active_threads);
9696
if(isActive)
9797
func(s_mem[localId], s_mem[localId + chunk_count]);
@@ -154,7 +154,7 @@ namespace kernel
154154

155155
uint32_t blocks = threads / 2 / blockcount;
156156
if (blocks == 0) blocks = 1;
157-
PMACC_TYPEKERNEL(kernel::reduce < Type >)(blocks, blockcount, blockcount * sizeof (Type))(src, n, dest, func,
157+
PMACC_KERNEL(kernel::reduce < Type >{})(blocks, blockcount, blockcount * sizeof (Type))(src, n, dest, func,
158158
PMacc::nvidia::functors::Assign());
159159
n = blocks;
160160
blockcount = optimalThreadsPerBlock(n, sizeof (Type));
@@ -171,13 +171,13 @@ namespace kernel
171171
uint32_t problemSize = n - (blockOffset * blockcount);
172172
Type* srcPtr = dest + (blockOffset * blockcount);
173173

174-
PMACC_TYPEKERNEL(kernel::reduce < Type >)(useBlocks, blockcount, blockcount * sizeof (Type))(srcPtr, problemSize, dest, func, func);
174+
PMACC_KERNEL(kernel::reduce < Type >{})(useBlocks, blockcount, blockcount * sizeof (Type))(srcPtr, problemSize, dest, func, func);
175175
blocks = blockOffset*blockcount;
176176
}
177177
else
178178
{
179179

180-
PMACC_TYPEKERNEL(kernel::reduce < Type >)(blocks, blockcount, blockcount * sizeof (Type))(dest, n, dest, func,
180+
PMACC_KERNEL(kernel::reduce < Type >{})(blocks, blockcount, blockcount * sizeof (Type))(dest, n, dest, func,
181181
PMacc::nvidia::functors::Assign());
182182
}
183183

src/libPMacc/include/particles/IdProvider.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ namespace PMacc {
102102
IdProvider<T_dim>::State IdProvider<T_dim>::getState()
103103
{
104104
HostDeviceBuffer<uint64_cu, 1> nextIdBuf(DataSpace<1>(1));
105-
PMACC_TYPEKERNEL(idDetail::getNextId)(1, 1)(nextIdBuf.getDeviceBuffer().getDataBox());
105+
PMACC_KERNEL(idDetail::getNextId{})(1, 1)(nextIdBuf.getDeviceBuffer().getDataBox());
106106
nextIdBuf.deviceToHost();
107107
State state;
108108
state.nextId = static_cast<uint64_t>(nextIdBuf.getHostBuffer().getDataBox()(0));
@@ -174,14 +174,14 @@ namespace PMacc {
174174
template<unsigned T_dim>
175175
void IdProvider<T_dim>::setNextId(uint64_t nextId)
176176
{
177-
PMACC_TYPEKERNEL(idDetail::setNextId)(1, 1)(nextId);
177+
PMACC_KERNEL(idDetail::setNextId{})(1, 1)(nextId);
178178
}
179179

180180
template<unsigned T_dim>
181181
uint64_t IdProvider<T_dim>::getNewIdHost()
182182
{
183183
HostDeviceBuffer<uint64_cu, 1> newIdBuf(DataSpace<1>(1));
184-
PMACC_TYPEKERNEL(idDetail::getNewId)(1, 1)(newIdBuf.getDeviceBuffer().getDataBox(), GetNewId());
184+
PMACC_KERNEL(idDetail::getNewId{})(1, 1)(newIdBuf.getDeviceBuffer().getDataBox(), GetNewId());
185185
newIdBuf.deviceToHost();
186186
return static_cast<uint64_t>(newIdBuf.getHostBuffer().getDataBox()(0));
187187
}

0 commit comments

Comments
 (0)