 	int shft_wr; //Initialize the shift to the written row of temper.
 	int shft_rd; //Initialize the shift to the read row (opposite of written)
 	int logic_position;
-	int base = THREADBLK + 2;
+	int base = blockDim.x + 2;
 	//int height = THREADBLK/2;
 
     shLeft[tid] = right[gid];

	double t_eq = t_fullstep;

	// Call the kernels until you reach the iteration limit.
    if (cpu == 1)
    {
    	while(t_eq < t_end)
    	{


	if (tid < 2)
	{
        temper[tid] = shLeft[tid];
		temper[tid2] = shRight[tid];
	}
	//Wind it up!

    for (int k = 2; k < blockDim.x; k+=2)
	{
		logic_position = (k/2 & 1);
		shft_wr = base*logic_position;
		//On even iterations write to second row (starts at element 32)
		shft_rd = base*((logic_position+1) & 1);

		if (tid < 2)
		{
			temper[tid + shft_wr] = shLeft[tid+k];
			temper[tid2 + k + shft_wr] = shRight[tid+k];
		}

        if (tid < k)
        {
            if (blockIdx.x > 0)
            {
        		temper[tid2 + shft_wr] = execFunc(temper[tid + shft_rd], temper[tid2+shft_rd], temper[tid1 + shft_rd]);
            }
            else
            {
                if (tid2 == k)
                {
                    temper[tid2 + shft_wr] = execFunc(temper[tid + shft_rd], temper[tid+shft_rd], temper[tid1 + shft_rd]);
                }
                else if (tid2 == (k+1))
                {
                    temper[tid2 + shft_wr] = execFunc(temper[tid2 + shft_rd], temper[tid2+shft_rd], temper[tid1 + shft_rd]);
                }
                else
                {
                    temper[tid2 + shft_wr] = execFunc(temper[tid + shft_rd], temper[tid2+shft_rd], temper[tid1 + shft_rd]);
                }
            }
        }
        __syncthreads();
    }

    if (gid == (height-1))
    {
        temper[tid] = execFunc(temper[tid+base], temper[tid+base], temper[tid1+base]);
    }
    else if (gid == height)
    {
        temper[tid] = execFunc(temper[tid2+base], temper[tid2+base], temper[tid1+base]);
    }
    else
    {
        temper[tid] = execFunc(temper[tid+base], temper[tid2+base], temper[tid1+base]);
    }

    __syncthreads(); // Then make sure each block of threads are synced.

	int itr = 0;

    //-------------------TOP PART------------------------------------------

	//The initial conditions are timeslice 0 so start k at 1.
	for (int k = (blockDim.x-2); k>1; k-=2)
	{
		//Bitwise even odd. On even iterations write to first row.
		logic_position = (k/2 & 1);
		shft_wr = base*logic_position;
		//On even iterations write to second row (starts at element 32)
		shft_rd = base*((logic_position+1) & 1);

		//Each iteration the triangle narrows.  When k = 1, 30 points are
		//computed, k = 2, 28 points.
        if (blockDim.x > 0)
        {
    		if (tid <= k)
    		{
    			temper[tid + shft_wr] = execFunc(temper[tid+shft_rd], temper[tid2+shft_rd], temper[tid1+shft_rd]);
    		}
        }
        else
        {
            if (tid == (k/2-1))
            {
                temper[tid + shft_wr] = execFunc(temper[tid + shft_rd], temper[tid+shft_rd], temper[tid1 + shft_rd]);
            }
            else if (tid == k/2)
            {
                temper[tid + shft_wr] = execFunc(temper[tid2 + shft_rd], temper[tid2+shft_rd], temper[tid1 + shft_rd]);
            }
            else
            {
                temper[tid + shft_wr] = execFunc(temper[tid + shft_rd], temper[tid2+shft_rd], temper[tid1 + shft_rd]);
            }
        }

		//Make sure the threads are synced
		__syncthreads();

		//Really tricky to get unique values with threads.
		if (shft_wr && tid < 4)
		{
			shLeft[tid+itr] = temper[(tid & 1) + (tid/2 * base)]; // Still baroque.
			shRight[tid+itr] = temper[(right_pick[tid] + k) + (tid/2 * base)];
			itr += 4;
		}

		__syncthreads();

	}

	//After the triangle has been computed, the right and left shared arrays are
	//stored in global memory by the global thread ID since (conveniently),
	//they're the same size as a warp!
	right[gid] = shRight[tid];
	left[gid] = shLeft[tid];
}


//Do the split diamond on the CPU?
__host__ void CPU_diamond(REAL right, REAL left, int tpb)
