 
 global void reduce_energy(force_energy_tup *result) {
 	int l = threadIdx.x;
-	shared float energies[warpSize];
-	float e = block_sum<float>(energies, result[l].energy);
+	float e = block_sum<float>(result[l].energy);
 	if ( l == 0 ) {
 		result[0].energy = e;
 	}	

    a.energy += b.energy;
}

template <class T>
device __forceinline__
T block_sum(T* sdata, T mySum) {
	const unsigned int lane = threadIdx.x & 31;
	const unsigned int wid = threadIdx.x>>5;

	mySum = warp_sum(mySum);
	if (lane==0)
        sdata[wid] = mySum;
	__syncthreads();

	if (wid == 0) {
		mySum = (threadIdx.x < blockDim.x >> 5) ? sdata[lane] : zero<T>();
		mySum = warp_sum(mySum);
        if (threadIdx.x == 0 && isNotDiv32(blockDim.x))
            mySum += sdata[blockDim.x >> 5];
	}
	return mySum;
}

    
	//get total energy
	reduce_energy<<<1, nlig_atoms>>>(out);
    cudaThreadSynchronize();
	/* cudaStreamSynchronize(0); */
    abort_on_gpu_err();
    
	force_energy_tup reduced;
