0

我正在尝试开始使用 OpenCL,但遇到了 OpenCL 编译器在空白方面的奇怪行为,并且似乎找不到任何关于此的文档。

C 风格的单行注释 ( // foo) 立即导致无意义的构建错误:At end of source: error: expected a "}". 多行注释 ( /* bar */) 似乎工作正常。

换行符似乎在不添加可能导致错误的空格的情况下被剥离。由于以下原因,此示例将无法编译:

__kernel
void TestKernel() {}

line 1: error: identifier "__kernelvoid" is undefined

这可能完全取决于我的机器和/或配置,但有人可以确认这些事情不应该是这样吗?

我正在通过 .net/C# 中的 Cloo 使用 OpenCL。驱动来自 AMDOpenCL 2.0 AMD-APP (1642.5)

4

1 回答 1

0

I think I figured it out. I was doing this:

var program = new ComputeProgram(context, File.ReadAllLines(filename));

File.ReadAllLines() returns an array of strings without the line-break characters which is the root of the errors I was getting.

Using File.ReadAllTest() instead fixed all the problems:

var program = new ComputeProgram(context, File.ReadAllText(filename));

But in my opinion some of the blame goes to either Cloo or the OpenCL API for accepting a string array but just concatenating it together..

于 2015-04-10T21:20:08.500 回答