views:

163

answers:

5

I'm looking at options for GPGPU work. Say I write OpenCL kernel code or GLSL shader code and embed that in my executable. There's nothing to stop somebody grep-ing the binary and stealing my hard work. I could obscure or encrypt the strings and decrypt them just-in-time, but somebody can always go in with a debugger and intercept that just before the source gets passed to the driver. Do either of these standards cater for the needs of commercial developers (more interested in OpenCL here), and support some kind of driver/vendor-independent byte-code? (I can't find any mention of this, so I'm not hopeful, but thought I'd ask anyway). Thanks.

EDIT: Well, I appreciate everybody taking the time to read and reply, but I was hoping for more of an informed yes/no response about the technology, rather than a discussion about copyright and lawyers. I think some of these comments are somewhat missing the point. I realize that a determined person can unpick anything given the time, but that doesn't mean it has to be made easy. Following these comments it's a wonder that anybody bothers with any kind of software licensing at all. Every commercial software vendor might as well just post their entire source listing online, and rely on lawyers instead. As for whether someone's work is worthy of protection or not, speak for yourself. The fact that somebody else can write better code is irrelevant, software represents a very large investment of time and energy.

+4  A: 

So how different is that from being able to debug any of the other algorithms in your source?

No there is no architecture independent byte code because the JIT is optimized for each card.

Martin Beckett
whoops, meant to put that giant comment on the main ticket, not this post. In either case, +1.
glowcoder
+1  A: 

standards supporting some kind of driver/vendor-independent byte-code?

This is possible with Microsoft's DirectCompute computing API. HLSL kernel code can be compiled into a blob that will be much more hard to reverse engineered. The blob is a vendor independent bytecode, yet still possible to disassemble with tools of DirectX SDK, but you will get some kind of low level assembly (IHV's drivers JIT translate it into an optimized form that match specific GPU ISA).

As other people said, there's no silver bullet. I thing it's best to rely on Copyrights.

Stringer Bell
Note that CUDA is compiled into a byte-code too, called PTX.
Stringer Bell
This is the kind of information I was looking for, thanks! Unfortunately, DirectCompute and CUDA would tie me to Windows and NVidia, and I have to support Mac/Linux and ATI cards as well. Cheers though.
mr grumpy
Sure, I understand. I think it's still possible to check version of OpenCL dll in your application so that it blocks execution if it happens that it has been replaced by another dll (that could intercept calls). I know some softwares that rely on this mechanism for preventing interception of OpenGL calls.
Stringer Bell
Of course reverse engineering a standard byte code wouldn't be any harder than extracting the compressed/encrypted cl code from your app.
Martin Beckett
+1  A: 

OpenCL does allow you to precompile code (clCreateProgramWithBinary, clGetProgramInfo CL_PROGRAM_BINARIES), but it will be specific to a particular architecture. There's no OpenCL standard machine. So if you're precompiling with the nvidia driver you get PTX code, and there's no guarantee it works across driver versions even for the same compute device.

I would not recommend going out of your way to make your program less portable in such a manner.

Yann Vernier
Okay, thanks. Shame, a brand new standard and they didn't take the time to define something that was driver/arch independent.
mr grumpy
It makes sense if you see this precompiled code more as a means to avoid recompile times (arch dependent binaries allow the compiler to optimize/compile closer to the target then independent ones, thus reducing their load time. considering how vastly the target architectures of opencl differ, a arch independent compiler couldn't really do any optimizations besides the most basic ones). For IP protection I would rather suggest going with compressed and/or encrypted source code (most opencl kernels/programs are small enough that having them in only compiled form can only do that much anyways)
Grizzly
A: 

I would just XOR it with a one time pad, then store the one time pad somewhere else in your code. Yeah it could be easily reverse engineered, but it is Google (insert your favorite text searching engine) proof.

Chad Brewbaker
A: 

Another (additional) option to consider is using a C obfuscator to make your source code hard to read, understand and modify. Maybe it is a good idea to use that in combination with a simple encryption scheme (OTP XOR).

dietr