   }
   context->internal = internal;
 
-  long long unsigned int vecLength = compiletime_info.vecLength;
   long long unsigned int vecLengthPipe = compiletime_info.vecLengthPipe;
   long long unsigned int matLength = compiletime_info.matLength;
 

  cudaSetDevice(device); // TODO Put device number in XGPU(Internal?)Context
  checkCudaError();

  if(context->array_h) {
    // Register caller-allocated host memory with CUDA.
    // This requires that the caller allocated the memory properly vis-a-vis
    // the requirements of cudaHostRegister!
    cudaHostRegister(context->array_h, vecLength*sizeof(ComplexInput), 0);
    internal->unregister_array_h = context->array_h;
    internal->free_array_h = NULL;
  } else {
    // allocate host memory
    cudaMallocHost(&(context->array_h), vecLength*sizeof(ComplexInput));
    internal->free_array_h = context->array_h;
    internal->unregister_array_h = NULL;
    checkCudaError();
  }

  if(context->matrix_h) {
    // Register caller-allocated host memory with CUDA.
    // This requires that the caller allocated the memory properly vis-a-vis
    // the requirements of cudaHostRegister!
    cudaHostRegister(context->matrix_h, matLength*sizeof(Complex), 0);
    internal->unregister_matrix_h = context->matrix_h;
    internal->free_matrix_h = NULL;
  } else {
    // allocate host memory
    cudaMallocHost(&(context->matrix_h), matLength*sizeof(Complex));
    internal->free_matrix_h = context->matrix_h;
    internal->unregister_matrix_h = NULL;
    checkCudaError();
  }

  //allocate memory on device
  cudaMalloc((void **) &(internal->array_d[0]), vecLengthPipe*sizeof(ComplexInput));

static int writeMatrix = 1;
// this must be enabled for this option to work though, slightly hurts performance
//#define WRITE_OPTION 

// System page size (used for rounding size passed to cudaHostRegister)
static long page_size = sysconf(_SC_PAGE_SIZE);

typedef struct XGPUInternalContextStruct {
  //memory pointers on the device
