Hi!
Here is my problem:
I’m trying to port my molecular dynamics program to OpenCL but I’m having a strange problem. The API clBuildProgram() crashes and gives a ‘segmentation fault’ when called in the program. Here is my OpenCL source:
__kernel void UffComputeNonBondCl(
__global float4 *ForceIncrementList,
__global float *PotentialIncrementList,
__global float4 *DispList,
__global struct ATOM_PAIR *PairList,
__global short *VDWIndexList,
__global struct VDW_TEMPLATE *VDWCstList,
__global float *ChargeList,
float4 Lattice,
float cutoff2,
float cutoff3_inv,
unsigned long Parallelism
)
{
int i = get_global_id(0);
if ( i>= Parallelism ) return;
float4 Force;
float4 r12 = DispList[ PairList[i].a ] - DispList[ PairList[i].b ];
float4 o1 = r12 > ( Lattice * 0.5 );
float4 o2 = r12 < ( Lattice * -0.5 );
r12 -= 0.5 * Lattice * o1 - 0.5 * Lattice * o2;
float r12mod = length( r12 );
float rmod_2 = r12mod * r12mod;
if ( rmod_2 > cutoff2 ) return;
float xl = VDWCstList[ VDWIndexList[i] ].xl;
float D = VDWCstList[ VDWIndexList[i] ].D;
float r0_2 = xl * xl;
float r0_6 = r0_2 * r0_2 * r0_2;
float rmod_6 = rmod_2 * rmod_2 * rmod_2;
float rmod_8 = rmod_6 * rmod_2;
float rr6 = r0_6 / rmod_6;
ForceIncrementList[ i ] = r12 * ( 0.0050226 * D * rr6 / rmod_2 * ( 1 - rr6 ) - 0.138985262 * ChargeList[PairList[i].a] * ChargeList[PairList[i].b] * r12 * ( 1 / ( r12mod * rmod_2 ) - cutoff3_inv ) );
}
I’ve found that if I comment the last line ForceIncrementList[ i ] = r12 * ( 0.0050226 * D * rr6 / rmod_2 * ( 1 - rr6 ) - 0.138985262 * ChargeList[PairList[i].a] * ChargeList[PairList[i].b] * r12 * ( 1 / ( r12mod * rmod_2 ) - cutoff3_inv ) ); then the API won’t fail. And I tried to rewrite the line in other forms and find that assign values to ForceIncrementList will cause the crash ( not during run-time, but during compilation… ).
I’m using a 64-bit Ubuntu 10.04 server, and I’ve installed the latest version of the driver, SDK and ToolKit. My Graphics Card is GF9600GT.
Could anyone tell me the reason of the problem? Thank you very much.