Boost logo

Boost :

Subject: Re: [boost] [compute] kernels as strings impairs readability and maintainability
From: Antony Polukhin (antoshkka_at_[hidden])
Date: 2014-12-25 05:58:15

2014-12-24 23:15 GMT+04:00 Pavan Yalamanchili <pavan_at_[hidden]>:

> I am a bit late to the party, but we faced the same problem with our
> library, ArrayFire.
> The solution we came up with is the following.
> - The kernels are written as .cl files and are part of the repository.
> - During the build process, the kernels in .cl files are converted to
> strings in *new* .hpp files.
> - The auto-generated kernel headers are the files that are included when
> trying to compile the said kernel.

There is a possible hack for that case! You'll need two helper header files
`import.pp` and `end_import.pp`. Something like the following could work
(not tested).

/// import.pp
#define TO_STRING(...) \

/// end_import.pp
#undef TO_STRING
#undef IMPORT_AS

Now you'll need to write kernels like this:

#ifdef IMPORT_AS
    char IMPORT_AS[] = TO_STRING(

// Code goes here

#ifdef IMPORT_AS
    ); // not sure that this will work

That's it. Now if you need that kernel as a string, you just write the

#define IMPORT_AS variable_name
#include "import.pp"
#include ""
#include "end_import.pp"

Best regards,
Antony Polukhin

Boost list run by bdawes at, gregod at, cpdaniel at, john at