 
 #include <cuda_runtime.h>
 
-// Global vars
-pthread_t t_socket_server;
-SocketServer socket_server;
-SocketClient socket_client;
-
 // Convenience function for checking CUDA runtime API results
 // can be wrapped around any runtime API call. No-op in release builds.
 inline cudaError_t checkCuda(cudaError_t result) {

  // wait for SocketServer to come up
  while (socket_server.getPort() == -1) {}

  // connect SocketClient
  socket_client.connectSocket(socket_server.getPort());

  //CUDA setup
  // runtime must be placed into a state enabling to allocate zero-copy buffers.
  checkCuda(cudaSetDeviceFlags(cudaDeviceMapHost));

  // allocate host_kernelWrapper as pinned memory
  checkCuda(cudaHostAlloc((void**) &h_host_device_interface, sizeof(HostDeviceInterface),
            cudaHostAllocWriteCombined | cudaHostAllocMapped));

  // init HostMonitor
  host_monitor = new HostMonitor(h_host_device_interface);
  host_monitor->start_monitoring();

  // wait for HostMonitor monitoring

      }

      case HostDeviceInterface::DONE: {
        socket_client->sendCMD(HostDeviceInterface::DONE);
        host_device_interface->is_result_available = true;
        // block until result was consumed
        while (host_device_interface->is_result_available) {}
