PTX Errors

May 10, 2014 at 7:55 PM
If managedCuda tells me it can't create a binary is there any way to tell what the problem was in the PTX?
Coordinator
May 10, 2014 at 8:20 PM
Well you can output the error-log-buffer and check if it contains something useful (it usually does if the ptx code is erroneous). For example like:
CudaContext ctx = new CudaContext();
CudaJitOptionCollection options = new CudaJitOptionCollection();
CudaJOErrorLogBuffer err = new CudaJOErrorLogBuffer(1024);
options.Add(err);
try
{
    ctx.LoadModulePTX("test.ptx", options);
}
catch 
{
    options.UpdateValues();
    MessageBox.Show(err.Value);                
}
May 10, 2014 at 9:28 PM
Edited May 10, 2014 at 10:13 PM
Hee hee! I'm on ManageCuda 5.0.4728.41769. Do I need to upgrade to do that?

Okay, I did it like so:
        try
        {
            //load kernel and JIT compile it with given options 
            vectorAddKernel = ctx.LoadKernelPTX(ASCIIEncoding.ASCII.GetBytes(this.PTX), this.KernelName, ops, vals);
        }
        catch
        {
            throw new Exception(Encoding.UTF8.GetString((byte[])vals[5], 0, bufferSize));
        }

That's perfect! Thank you!
Coordinator
May 10, 2014 at 10:11 PM
In the older version it was like this:
CudaContext ctx = new CudaContext();
byte[] buffer = new byte[1024];

try
{
    CUmodule k = ctx.LoadModulePTX("test.ptx", new CUJITOption[] { CUJITOption.ErrorLogBufferSizeBytes, CUJITOption.ErrorLogBuffer }, new object[] { (uint)1024, buffer });
}
catch 
{
    MessageBox.Show(ASCIIEncoding.ASCII.GetString(buffer).Replace("\0", string.Empty));
}
Marked as answer by Darren996 on 5/10/2014 at 2:34 PM
May 10, 2014 at 10:35 PM
One day I hope to buy you a car. What would you like? :D
Coordinator
May 10, 2014 at 11:28 PM
Anything between Benz Patent-Motorwagen Nr. 1 and Tesla Model S will do it ;-)
May 11, 2014 at 12:48 AM
Got it!