Skip to content

Commit add0f9b

Browse files
committed
Merge pull request ComputationalRadiationPhysics#859 from psychocoderHPC/topic-splitConstVectorDefinitionAndInstance
split `ConstVector` definition and instantiation
2 parents 039819d + c019ff4 commit add0f9b

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

src/libPMacc/include/math/ConstVector.hpp

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,14 @@
3333
#define PMACC_USING_STATIC_CONST_VECTOR_NAMESPACE(id) using namespace PMACC_JOIN(pmacc_static_const_vector_host,id)
3434
#endif
3535

36-
/** @see PMACC_CONST_VECTOR documentation, only unique "id" is added
36+
/** define a const vector
37+
*
38+
* create type definition `Name_t`
39+
* @see PMACC_CONST_VECTOR documentation, only unique "id" is added
3740
*
3841
* @param id unique precompiler id to create unique namespaces
3942
*/
40-
#define PMACC_STATIC_CONST_VECTOR_DIM(id,Name,Type,Dim,count,...) \
43+
#define PMACC_STATIC_CONST_VECTOR_DIM_DEF(id,Name,Type,Dim,count,...) \
4144
namespace PMACC_JOIN(pmacc_static_const_storage,id) \
4245
{ \
4346
namespace PMACC_JOIN(pmacc_static_const_vector_device,id) \
@@ -64,7 +67,7 @@ namespace PMACC_JOIN(pmacc_static_const_storage,id) \
6467
} \
6568
HDINLINE const type& operator[](const int idx) const \
6669
{ \
67-
/*access const C array with the name of array*/ \
70+
/*access const C array with the name of array*/ \
6871
return PMACC_JOIN(Name,_data)[idx]; \
6972
} \
7073
}; \
@@ -75,6 +78,14 @@ namespace PMACC_JOIN(pmacc_static_const_storage,id) \
7578
PMacc::math::StandartAccessor, \
7679
PMacc::math::StandartNavigator, \
7780
ConstArrayStorage > PMACC_JOIN(Name,_t); \
81+
} /* namespace pmacc_static_const_storage + id */ \
82+
using namespace PMACC_JOIN(pmacc_static_const_storage,id)
83+
84+
/** create a instance of type `Name_t` with the name `Name`
85+
*/
86+
#define PMACC_STATIC_CONST_VECTOR_DIM_INSTANCE(id,Name,Type,Dim,count,...) \
87+
namespace PMACC_JOIN(pmacc_static_const_storage,id) \
88+
{ \
7889
namespace PMACC_JOIN(pmacc_static_const_vector_device,id) \
7990
{ \
8091
/* create const instance on device */ \
@@ -85,10 +96,26 @@ namespace PMACC_JOIN(pmacc_static_const_storage,id) \
8596
/* create const instance on host*/ \
8697
const PMACC_JOIN(Name,_t) Name; \
8798
} /* namespace pmacc_static_const_vector_host + id */ \
88-
} /* namespace pmacc_static_const_storage + id */ \
89-
using namespace PMACC_JOIN(pmacc_static_const_storage,id)
99+
} /* namespace pmacc_static_const_storage + id */
100+
101+
/** @see PMACC_CONST_VECTOR documentation, only unique "id" is added
102+
*
103+
* @param id unique precompiler id to create unique namespaces
104+
*/
105+
#define PMACC_STATIC_CONST_VECTOR_DIM(id,Name,Type,Dim,count,...) \
106+
PMACC_STATIC_CONST_VECTOR_DIM_DEF(id,Name,Type,Dim,count,__VA_ARGS__); \
107+
PMACC_STATIC_CONST_VECTOR_DIM_INSTANCE(id,Name,Type,Dim,count,__VA_ARGS__)
90108

91109

110+
/** define a const vector
111+
*
112+
* for description @see PMACC_CONST_VECTOR
113+
*
114+
* create type definition `name_t`
115+
*/
116+
#define PMACC_CONST_VECTOR_DEF(type,dim,name,...) \
117+
PMACC_STATIC_CONST_VECTOR_DIM_DEF(__COUNTER__,name,type,dim,PMACC_COUNT_ARGS(__VA_ARGS__),__VA_ARGS__)
118+
92119
/** Create global constant math::Vector with compile time values which can be
93120
* used on device and host
94121
*
@@ -107,4 +134,3 @@ using namespace PMACC_JOIN(pmacc_static_const_storage,id)
107134
*/
108135
#define PMACC_CONST_VECTOR(type,dim,name,...) \
109136
PMACC_STATIC_CONST_VECTOR_DIM(__COUNTER__,name,type,dim,PMACC_COUNT_ARGS(__VA_ARGS__),__VA_ARGS__)
110-

0 commit comments

Comments
 (0)