I am trying to build a parser for CUDA code. Specifically, I am attempting to extend an ANSI C parser to include CUDA code. I’m wondering:
(1) Am I reinventing the wheel; i.e., does an open source parser already exist?
(2) Specifically, how do I go about parsing the dimBlock an dimGrid assignments? The following isn’t standard C, certainly:
[font=“Courier New”]dim3 dimBlock(block_size);[/font]
It’s not a function declaration (despite the [font=“Courier New”]dim3[/font] type), but it doesn’t work the same a function call (because of the [font=“Courier New”]dim3[/font] type). Thanks!
-Chris
I am trying to build a parser for CUDA code. Specifically, I am attempting to extend an ANSI C parser to include CUDA code. I’m wondering:
(1) Am I reinventing the wheel; i.e., does an open source parser already exist?
(2) Specifically, how do I go about parsing the dimBlock an dimGrid assignments? The following isn’t standard C, certainly:
[font=“Courier New”]dim3 dimBlock(block_size);[/font]
It’s not a function declaration (despite the [font=“Courier New”]dim3[/font] type), but it doesn’t work the same a function call (because of the [font=“Courier New”]dim3[/font] type). Thanks!
-Chris
Hi, Chris!
Ad 1) Don’t know
Ad 2) dim3 is a type and dimBlock is the name of the variable of type dim3 and the whole expression is a definition with a call to the constructor.
This is an excerpt from vecot_types.h
typedef struct dim3 dim3;
/*DEVICE_BUILTIN*/
struct dim3
{
unsigned int x, y, z;
#if defined(__cplusplus)
dim3(unsigned int x = 1, unsigned int y = 1, unsigned int z = 1) : x(x), y(y), z(z) {}
dim3(uint3 v) : x(v.x), y(v.y), z(v.z) {}
operator uint3(void) { uint3 t; t.x = x; t.y = y; t.z = z; return t; }
#endif /* __cplusplus */
};
Regards
Navier
Ah–that clears things up. Thanks!
-Chris
I am trying to build a parser for CUDA code. Specifically, I am attempting to extend an ANSI C parser to include CUDA code. I’m wondering:
(1) Am I reinventing the wheel; i.e., does an open source parser already exist?
NVIDIA forked the Open64 compiler for something (I assume as a C-parsing front-end which emits PTX in the backend), and under the terms of the GPL, NVIDIA has to release the source code:
ftp://download.nvidia.com/CUDAOpen64/nvopencc-2.2-src.tar.gz
Probably worth a look to see what’s in there, though a full-blown compiler might be too much for your needs.