     if(global_thread_id < num_query_points) {
       AccumulateTileContribution_(
         num_dimensions, bandwidth, query_point_local_mem,
-        num_reference_points_in_this_tile, & local_sum);
+        num_reference_points_in_this_tile,
+        reference_point_shared_mem, & local_sum);
     }
 
     // Synchronize all threads within this block before loading new

      reference_on_device, reference_on_host,
      num_reference_bytes, cudaMemcpyHostToDevice);

    int num_threads_per_block = 512;
    int num_blocks = (num_query_points + num_threads_per_block - 1) /
                     num_threads_per_block;


                           num_reference_points_in_this_tile;

    if(reference_point_id < ending_rpoint_id) {
      LoadReferencePoint_(
        num_dimensions, reference, reference_point_id,
        reference_point_shared_mem);
    }
    __syncthreads();

