cuda - Automatically adding function prefixes to C++ functions -
i'm porting little c++ codebase callable on graphics card, via cuda. cuda requires functions prepended __host__ __device__
in order callable both on cpu , in gpu kernel code. e.g.,
void foo() {} // callable on cpu, not on gpu __host__ __device__ foo() {} // callable on cpu , on gpu
it's tedious straight-forward task add together __host__ __device__
every function in codebase, i'm wondering: there efficient method prepend qualifiers c/c++ functions?
i happy text-editor technique detected function declarations, or compiler feature. however, unaware of solution involves either.
ideas?
i'm not aware of such compiler feature. i'd wary of broadly applying these directives anyway though, calling conventions , stack management might different (e.g. slower?) normal host conventions when not needed. i'd set own macro , e.g. #define hdfn __host__ __device__
such it'd easy add/change.
that aside, might able dig regex detecting methods , write macro simple...
c++ cuda metaprogramming
No comments:
Post a Comment