hughperkins / cltorch

An OpenCL backend for torch.
Other
289 stars 26 forks source link

kernel definition fails #80

Closed AnnaMag closed 7 years ago

AnnaMag commented 7 years ago

Running torch from iTorch.

The kernel definition from the example: k:run({nElements=3, input=x, output=y}) gives:

[string "x = torch.ClTensor({3,5,2})..."]:6: OpenCL error, code: -49 at /Users/amk/torch-cl/opencl/cltorch/src/lib/THClKernels.cpp:57 stack traceback: [C]: in function 'run' [string "x = torch.ClTensor({3,5,2})..."]:6: in main chunk [C]: in function 'xpcall' /Users/amk/torch-cl/install/share/lua/5.1/itorch/main.lua:209: in function </Users/amk/torch-cl/install/share/lua/5.1/itorch/main.lua:173> /Users/amk/torch-cl/install/share/lua/5.1/lzmq/poller.lua:75: in function 'poll' ...rs/amk/torch-cl/install/share/lua/5.1/lzmq/impl/loop.lua:307: in function 'poll' ...rs/amk/torch-cl/install/share/lua/5.1/lzmq/impl/loop.lua:325: in function 'sleep_ex' ...rs/amk/torch-cl/install/share/lua/5.1/lzmq/impl/loop.lua:370: in function 'start' /Users/amk/torch-cl/install/share/lua/5.1/itorch/main.lua:381: in main chunk [C]: in function 'require' (command line):1: in main chunk [C]: at 0x010680fd10

The tests passed through with a fair bit of warnings, but no errors. Big kudos for making torch available for Intel users!!!

hughperkins commented 7 years ago

well... that errorcode, looking it up in /usr/include/CL/cl.h is:

#define CL_INVALID_ARG_INDEX                        -49

It runs on my own machine:

ubuntu@peach:~/git/cltorch$ luajit /tmp/test.lua
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
Using NVIDIA Corporation , OpenCL platform: NVIDIA CUDA
Using OpenCL device: GeForce 940M
k   torch.ClKernel
Original source
===============
   int linearId = get_global_id(0);
   if(linearId < nElements) {
     output_data[linearId] = input_data[linearId] + 3.0f;
   }

Generated source
================
typedef struct THClTensorInfoCl {
  unsigned int sizes[25];
  unsigned int strides[25];
  int offset;
  int dims;
} TensorInfoCl;

kernel void user_kernel(
    global struct THClTensorInfoCl *input_info, global const float * input_data,
    int nElements,
    global struct THClTensorInfoCl *output_info, global  float * output_data
) {
   int linearId = get_global_id(0);
   if(linearId < nElements) {
     output_data[linearId] = input_data[linearId] + 3.0f;
   }

}

x before
     3
 5
 2
[torch.ClTensor of size 3]

y before
     6
 4
 2
[torch.ClTensor of size 3]

y after
     6
 8
 5
[torch.ClTensor of size 3]

Can you provide:

AnnaMag commented 7 years ago

Apologies-not sure what happened before. It seems to pass through now.

hughperkins commented 7 years ago

Cool :-)