       break;
 
     case  8:
-      cudaFuncSetCacheConfig (k_jacobianReduceHessianGradient<8,true>, cudaFuncCachePreferShared);
+      cudaFuncSetCacheConfig (k_jacobianReduceHessianGradient<8,false>, cudaFuncCachePreferL1);
       k_jacobianReduceHessianGradient<8, false><<< dimGrid, dimBlock >>>(jacobian_input_device,
                                                                          residual_input_device,
                                                                          visibility_input_device,

  return ((x&(x-1))==0);
}

void reduce(int size, int threads, int blocks,
            float* jacobian_input_device,
            char* visibility_input_device,
            float* residual_input_device,
            float* gradient_output,
            float* hessian_output)
{
  dim3 dimBlock(threads, 1, 1);
  dim3 dimGrid(blocks, 1, 1);

  {
    switch (threads)
    {

    case 512:
      throw std::runtime_error(" 512 threads exceed the 48kB of available shared memory per block!");
      //      cudaFuncSetCacheConfig (k_jacobianReduceHessianGradient<512,true>, cudaFuncCachePreferShared);
      //      k_jacobianReduceHessianGradient<512, true><<< dimGrid, dimBlock >>>(jacobian_input_device,
      //                                                                          residual_input_device,
      //                                                                          visibility_input_device,
      //                                                                          gradient_output,
      //                                                                          hessian_output,
      //                                                                          size);
      break;

    case 256:
      cudaFuncSetCacheConfig (k_jacobianReduceHessianGradient<256,true>, cudaFuncCachePreferL1);
      k_jacobianReduceHessianGradient<256, true><<< dimGrid, dimBlock >>>(jacobian_input_device,
                                                                          residual_input_device,
                                                                          visibility_input_device,
