1

I want to intercept at PTX level of opencl programs on NVIDIA GPU.

I imagine the routine would probably look like this.

First, I write an opencl program (both host and device code), using NVIDIA compiler to produce respective ptx code. Then I write what I want to do by modifying the PTX code (please don't ask why I didn't do this on the device C code - I have some reasons for it). But problem is, after being modified, how do I compile this PTX code to binary code?

2
  • Use the CUDA toolchain and CUDA driver API. I don't believe there is a way to deal with assembly code or inline assembler instruction with OpenCL. Commented Jul 9, 2012 at 7:02
  • This works for CUDA wili.cc/blog/ptx.html. Might work for OpenCL too Commented Jul 31, 2012 at 10:34

1 Answer 1

1

You can use ptxas, which is included in the CUDA toolkit. It compiles .ptx into .cubin, which can then be loaded with the driver API.

Sign up to request clarification or add additional context in comments.

1 Comment

I don't think there's a way to re-inject the PTX into OpenCL. You could use the CUDA Driver API and cuModuleLoadData. If you really need to do this low level of PTX manipulation, I recommend you just use CUDA (and possibly the CUDA Compiler SDK (libNVVM).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.