使用#include装载OpenCL代码 [英] Using #include to load OpenCL code

查看:154
本文介绍了使用#include装载OpenCL代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很久以前,我已经看到了这样做,使用hlsl / glsl着色器代码 - 在源代码文件中使用 #include 将代码粘贴到 char * ,以便在运行时不会发生文件IO。

I've seen this done long ago with hlsl/glsl shader code -- using an #include on the source code file that pastes the code into a char* so that no file IO happens at runtime.

如果我把它表示为伪代码,有点像这样:

If I were to represent it as pseudo-code, it would look a little like this:

#define CLSourceToString(filename) " #include "filename" "
const char* kernel = CLSourceToString("kernel.cl");

当然, #define isn'

推荐答案

查看项目符号物理引擎使用OpenCL的如何执行此操作内核

See the bullet physics engines use of OpenCL for how to do this to a kernel.

在C ++ / C源中

In C++ / C source

#define MSTRINGIFY(A) #A
char* stringifiedSourceCL = 
#include "VectorAddKernels.cl"

/ p>

In the OpenCL source

MSTRINGIFY(
   __kernel void VectorAdd(__global float8* c)
   {
    // snipped out OpenCL code...
    return;
   }
);

这篇关于使用#include装载OpenCL代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆