 		done = false;
 	}
 
-	__device__ __host__ int getValue(int val) {
+	__device__ int getValue(int val) {
 
 		command = GET_VALUE;
 		param1 = val;
+		//__threadfence_system();
 
 		// wait for socket communication
 		while (true) {

	}

	static void *thread(void *context) {
		KernelWrapper *_this = ((KernelWrapper *) context);

		while (!_this->done) {
			if ((!_this->has_task) && (_this->active_thread_id >= 0)
					&& (_this->command != UNDEFINED)) {
				_this->has_task = true;

class KernelWrapper {
private:
	pthread_t t_monitor;
	//pthread_mutex_t mutex_result_available;
	//pthread_mutex_t mutex_has_task;
	//pthread_cond_t new_command_cv;
	volatile int param1;
	volatile bool result_available;
	volatile int result_int;
	//string resultString;

public:
	volatile MESSAGE_TYPE command;
	volatile bool has_task;
	volatile int active_thread_id;
	volatile bool done;

	KernelWrapper() {
		init();
