 
 
 unsigned char* grow_region_gpu_shared(unsigned char* data){
-  return NULL;
+  unsigned char* region = (unsigned char*)calloc(sizeof(unsigned char), DATA_DIM*DATA_DIM*DATA_DIM);
+  int* finished = (int*)malloc(sizeof(int));
+    finished[0] = 0;
+
+  int3 seed = {.x=50, .y=300, .z=300};
+  region[seed.z *DATA_DIM*DATA_DIM + seed.y*DATA_DIM + seed.x] = 2;
+
+  unsigned char *data_device;
+  unsigned char *region_device;
+  int *finished_device;
+  cudaMalloc( (void**)&data_device, DATA_DIM*DATA_DIM*DATA_DIM*sizeof(unsigned char));
+  cudaMalloc( (void**)&region_device, DATA_DIM*DATA_DIM*DATA_DIM*sizeof(unsigned char));
+  cudaMalloc( (void**)&finished_device, sizeof(int));
+  cudaMemcpy( data_device, data, DATA_DIM*DATA_DIM*DATA_DIM*sizeof(unsigned char), cudaMemcpyHostToDevice);
+  cudaMemcpy( region_device, region, DATA_DIM*DATA_DIM*DATA_DIM*sizeof(unsigned char), cudaMemcpyHostToDevice);
+  //cudaMemcpy( finished_device, finished, sizeof(int), cudaMemcpyHostToDevice);
+
+  dim3 dimBlock( 8, 8, 8 );
+  dim3 dimGrid( 64, 64, 64 );
+
+  while(finished[0] == 0){
+    finished[0] = 1;
+    cudaMemcpy( finished_device, finished, sizeof(int), cudaMemcpyHostToDevice);
+    region_grow_kernel<<<dimGrid, dimBlock>>>(data_device, region_device, finished_device);
+    cudaMemcpy( finished, finished_device, sizeof(int), cudaMemcpyDeviceToHost);
+  }
+  cudaMemcpy( region, region_device, DATA_DIM*DATA_DIM*DATA_DIM*sizeof(unsigned char), cudaMemcpyDeviceToHost);
+  cudaFree(data_device);
+  cudaFree(region_device);
+  cudaFree(finished_device);
+  return region;
 }
 
 



__global__ void region_grow_kernel_shared(unsigned char* data, unsigned char* region, int* finished){

}



  cudaMemcpy3D(&copyDataParams);
  cudaMemcpy3D(&copyRegionParams);

  cudaBindTextureToArray(data_texture, data_array, channelDesc);
  cudaBindTextureToArray(region_texture, region_array, channelDesc);



