     /* per_ligand_atom_energy<<<natoms,1>>>(dinfo, slope, v); */
 #endif
 	//get total energy
-	thrust::device_ptr<float> dptr(energies);
-    float e = thrust::reduce(dptr, dptr + natoms);
+	reduce_energy<<<1, natoms>>>(dinfo, natoms);
+	cudaError err2 = cudaGetLastError();
+	if (cudaSuccess != err2)
+	{
+		fprintf(stderr, "cudaCheckError() failed at %s:%i : %s\n",
+				__FILE__, __LINE__, cudaGetErrorString(err2));
+		exit(-1);
+	}
+	cudaThreadSynchronize();
+	float e;
+	cudaMemcpy(&e, &dinfo->energies[0],sizeof(float),cudaMemcpyDeviceToHost);
+	return e;
+	// thrust::device_ptr<float> dptr(energies);
+    // float e = thrust::reduce(dptr, dptr + natoms);
 
     /* static int iter = 0; */
     /* printf("%d, %f\n", iter++, e); */
-	return e;
-}
+	// return e;
+}

	}
}

//host side of single point_calculation, energies and coords should already be initialized
float single_point_calc(GPUNonCacheInfo *dinfo, float *energies,
                        float slope, unsigned natoms,

#include "gpu_util.h"

#define THREADS_PER_BLOCK 1024
#define warpSize 32

global
void evaluate_splines(float **splines, float r, float fraction,
