Matrix4x4 assignment not working

I am trying to assign a 4x4 matrix in CUDA code inside my intersection program. The ptx file is successfully created but in host code rtProgramCreateFromPTXFile() fails with exception for this program. I have tried removing the matrix assignment part and it seems to work fine but now I have no way of assigning the matrix elements. setCol() and passing float none of these work. I am using CUDA 6 and Optix 3.6.2.

Some actual code would have been helpful.

If you do that as default initialization like this:
rtDeclareVariable(optix::Matrix4x4, mat44, , ) = optix::Matrix4x4(make_flot4(1,0,0,0), …);
that won’t work with CUDA because this is a class and a module global variable.
There is no CUDA kernel running which could do this initialization via a constructor at the time of the declaration.

You must initialize this mat44 variable inside the host application by using the OptiX API calls rtVariableSetMatrix4x4fv() and the like.

Inside a program as local variable, there should be no problem to do things like this:

#define RT_FUNCTION __forceinline__ __device__

RT_FUNCTION optix::Matrix4x4 translate(const float3& translation = make_float3(0.0f))
  optix::Matrix4x4 t; 

  t.setRow(0, make_float4(1.0f, 0.0f, 0.0f, 0.0f));
  t.setRow(1, make_float4(0.0f, 1.0f, 0.0f, 0.0f));
  t.setRow(2, make_float4(0.0f, 0.0f, 1.0f, 0.0f));
  t.setRow(3, make_float4(translation.x, translation.y, translation.z, 1.0f));
  return t;

I was actually creating a pointer and then assigning via constructor inside my intersection program:
Matrix4x4* mat = new Matrix4x4();
I changed it to the way you showed above and it seems to work. Thanks.

Btw, I do not need the matrix in the host code. so i am creating it locally in my intersection program.

Please read the caveats section at the end of the OptiX Programming Guide.
Dynamic allocations (malloc, free, new, delete) are not supported inside OptiX device code.