如何加载文本文件的行、行的长度和读取行的数量,以正确的方式投射它们并将它们传递给 GPU?
意义:
输入文本文件:
Line1
Line2
..
LineN
应用程序.cl
#define UP_LIMIT 256
typedef struct {
uint bar; // amount of read lines
} foomatic;
typedef struct {
uint len; // length of line
uchar s[UP_LIMIT]; // line
} foo;
__kernel foobar(__global foo * kernel_in, __global foomatic kernel_in2){
// do something
}
主文件
#define LLEN 256
typedef struct {
cl_uint bar; // amount of read lines
} foomatic;
typedef struct {
cl_uint len; // length of line
cl_uchar s[LLEN]; // line
} foo;
int main(){
// load from file
// count lines of file
foo * input = new foo[N]; // N is the amount of lines of source text file
// cast line to cl_uchar
// pass lines, their lengths and number of lines to ocl kernel
delete [] input;
}