occa icon indicating copy to clipboard operation
occa copied to clipboard

Use compiler-defined macros in the preprocessor

Open camierjs opened this issue 7 years ago • 6 comments

Would it be possible to keep these directives down to the kernel? just asking

camierjs avatar Feb 27 '18 16:02 camierjs

There only directives that will live through the preprocessing stage are:

#pragma occa @...

as attributes, or regular pragmas

#pragma ...

Is that what you're looking for?

dmed256 avatar Feb 27 '18 18:02 dmed256

hum, I was more thinking of http://en.cppreference.com/w/c/preprocessor/conditional

camierjs avatar Feb 27 '18 19:02 camierjs

Oh, the preprocessor handles them since they are in the source code. Is there a reason to keep them around?

dmed256 avatar Feb 27 '18 20:02 dmed256

Well, even if they are in the OKL source code, if I do something like: #ifdef __NVCC__ {CUDA debug stuff} #else {other host debug} #endif then the parser only selects the {other host debug} statements.

camierjs avatar Feb 27 '18 20:02 camierjs

Oh, I'm planning on picking up the compiler defines. I have a TODO in the preprocessor constructor to remind me

https://github.com/libocca/occa/blob/master/parser_sandbox/src/preprocessor.cpp#L46

dmed256 avatar Feb 27 '18 22:02 dmed256

In f9f433f968d1602bfc7eca9d9926a8f5651139d5

#pragma occa @tile(16, @Inner, @outer)
for (int i = 0; i < N; ++i) {
}

for (int i = 0; i < N; ++i; @tile(16, @inner, @outer)) {
}

Still missing compiler-dependent defines, like __NVCC__

dmed256 avatar Jun 02 '18 22:06 dmed256