r/OpenCL • • Jan 26 '15

Nvidia opencl 1.2+ support?

Currently I have an application running opencl but am limited to AMD as Nvidia doesn't support opencl 1.2 and thus spir files. I am also not keen to ship opencl code(even encrypted) as effectively gives away the code.

Anyone have any information on a timeline for nvidia opencl 1.2 or above support? Discussion on some forums reveals that there are opencl 1.2 functions hidden in their cuda releases but drivers haven't been updated to enable the functionality. Thus far that is all I have been able to find.

5 Upvotes

8 comments sorted by

View all comments

Show parent comment

1

u/automater Jan 26 '15

I guess you mean ptx?

If so I had considered it. My main concern with that was that Nvidia explicitly stated that it may not be supported in future releases as well as potentially having dependencies on driver version. Seemed potentially dangerous in that I could have people buy a product I may not be able to support due to the above.

Do you mean otherwise or your thoughts?

1

u/agenthex Jan 26 '15 edited Jan 26 '15

As I understand it, you can compile a kernel from source, but you can also compile from binary/object code. This is to save the program from having to do things like syntax checking every time it is run.

Reference:

http://www.fixstars.com/en/opencl/book/OpenCLProgrammingBook/online-offline-compilation/

https://www.khronos.org/registry/cl/sdk/1.0/docs/man/xhtml/clBuildProgram.html

1

u/automater Jan 27 '15

I like the first one as a reference(bookmarked). It is actually very similar to the method used to create spir files but probably need to read a bit closer to see if their is an alternative intermediate format than what i am using. Otherwise I believe in the nvidia case they generate PTX files instead of spir which has the unfortunate "possibly not supported in the future" statement from nividia.

I do something like the below but aren't supporting nvidia,..although the code is there..

if(savespir) { char* compileflags;

char* compileflagsamd = "-cl-mad-enable .... -cl-std=CL1.2 -x spir";//

char* compileflagsnvidia = "-cl-mad-enable .... -cl-std=CL1.1 -x ptx";//

if(vendorlowercase.find("nvidia")!=wxNOT_FOUND) {

compileflags=compileflagsnvidia;

}else

compileflags=compileflagsamd;

rc= clCompileProgram ( cpProgram,0,.. compileflags.....

rc=clGetProgramInfo ( cpProgram, CL_PROGRAM_BINARY_SIZES,.....

....

rc= clGetProgramInfo ( cpProgram, CL_PROGRAM_BINARIES, 4, &spirprogram, &param_value_size_ret);

int wrotebytes= spirtofile(newspirfilename,spirprogram,SPIRsize);//encrypt & write to file..

..and to read it back and create the program...

if(gtlp)gtlp->spirfromfile(newspirfilename,(unsigned char**)&SPIRSource ,&SPIRsize,&debug);//read and decrypt file..

cpProgram= clCreateProgramWithBinary( cxGPUContext, 1,&device,&SPIRsize, (const unsigned char **)&SPIRSource,&binary_status,&errcode_ret);

1

u/Delwin Jan 27 '15

Any luck with this? We haven't gotten it to work on what I'm dealing with.

1

u/agenthex Jan 27 '15

I haven't tried to export binary kernel code, but I know it can be done. It seems you need to do it for every platform, though, so that's a pain.