我有一个程序,由用户使用C++类配置,并且应该使用相同的类来配置只能使用C99(Open CL语言)子集的程序.
所以我的问题是:有没有办法将C++编译成C-Code?
开源会很棒!
我想找出变量的类型(变量由Template参数给出,所以我不知道它是什么).
#include <iostream>
#include <typeinfo>
int main()
{
double test;
std::cout << typeid(test).name() << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
但是代码只发出:$./ test
d
但我需要双倍代替.
关键是,我不知道期望哪种类型,但我必须在一个子程序中编写它,这个子程序有待编译.所以d是个坏主意.
是否有可能在OpenCL内核中使用自定义的C++类?它应该像这样工作:
#include "element.cpp"
__kernel void do_something(__global element* input, __global element* output);
{
int index = get_global_id(0);
output[index] = input[index].update(index);
}
Run Code Online (Sandbox Code Playgroud)
这很有趣,因为您可以指定之后必须在element :: update(int no)中完成的工作.
我没有得到它的工作.这就是OpenCL-Compiler告诉我的:
未知类型名称'class'
在CUDA中这是有效的.如果OpenCL内核中的对象方法不起作用,还有其他想法吗?
感谢您的提示!
如何在GCC中使用SSE2?我想使用双精度值。
我搜索某事 像这样:http : //vrm-vrm.blogspot.com/2009/10/gcc-intrinsics.html 仅适用于双精度值。