 #include <stdio.h>
 #include "../testharness/testharness.h"
 
-#define BLOCK 512
-#define BUFFER_SIZE 16
+#define BLOCK 416
+#define BUFFER_SIZE 256
+#define TRANSFER_SIZE 16
+#define BUFFER_MOD 255
 #define _2XBUFFER_SIZE (BUFFER_SIZE * 2)
 #define MAX_MOMENTUM 0xF
 #define MOMENTUM_INIT 0xF0000000

			// prepare for moving right
			switch (role) {
			case LEFT:
				*here = *(cur_left_incoming--);
				break;
			case RIGHT:
				WriteParticle(&going_right, cur_right_outgoing);
				++cur_right_outgoing;
				break;
			case BEGINNING:
				if (going_left.color)

	__shared__ unsigned int right_outgoing [BUFFER_SIZE];
	__shared__ unsigned int isNotComplete;
	__shared__ unsigned int wasComplete;
	__shared__ unsigned int cur_L_incoming_written, cur_L_incoming_read;
	__shared__ unsigned int cur_L_outgoing_written, cur_L_outgoing_read;
	__shared__ unsigned int cur_R_incoming_written, cur_R_incoming_read;
	__shared__ unsigned int cur_R_outgoing_written, cur_R_outgoing_read;
	__shared__ unsigned int global_L_buffer_read, global_R_buffer_read;


	/* define registers */
	const int absThreadID = blockIdx.x * blockDim.x + threadIdx.x;

	if (threadIdx.x == 0) {
		cur_L_incoming_written = cur_L_incoming_read = cur_L_outgoing_written = cur_L_outgoing_read =
			cur_R_incoming_written = cur_R_incoming_read = cur_R_outgoing_written = cur_R_outgoing_read =
			global_L_buffer_read = global_R_buffer_read = 0;
	}
	unsigned int *const global_left_incoming_buffer = transblock_buffers + (blockIdx.x-1) * _2XBUFFER_SIZE;
	unsigned int *const global_left_outgoing_buffer = transblock_buffers + (blockIdx.x-1) * _2XBUFFER_SIZE + BUFFER_SIZE;
	unsigned int *const global_right_outgoing_buffer = transblock_buffers + blockIdx.x * _2XBUFFER_SIZE;
	unsigned int *const global_right_incoming_buffer = transblock_buffers + blockIdx.x * _2XBUFFER_SIZE + BUFFER_SIZE;
	unsigned int *const global_left_incoming_counter = buffer_count + (blockIdx.x-1) * 2;
	unsigned int *const global_left_outgoing_counter = buffer_count + (blockIdx.x-1) * 2 + 1;
	unsigned int *const global_right_outgoing_counter = buffer_count + blockIdx.x * 2;
	unsigned int *const global_right_incoming_counter = buffer_count + blockIdx.x * 2 + 1;
	
	struct particle going_left, going_right;

