Bitonic<T>::Bitonic(std::string source_dir, CL *cli )
{
    this->cli = cli;
    /*
    this->cl_dstkey = dstkey;
    this->cl_dstval = dstval;
    this->cl_srckey = srckey;
    this->cl_srcval = srcval;
    */
    loadKernels(source_dir);
}
cl_int btocl_build_load_kernels(const char* options) {

  size_t log_size;
  char* program_log;
  cl_int err;

  BTOCL_RUNTIME* rt = btocl_getruntime();

  //printf("creating program\n\n");
  err = createProgramFromBuffers(rt->context,&rt->program,rt);
  if (err < 0) {
    printf("Error: Couldn't create OpenCL program\n");
    //return err;
	exit(0);
  }
  
  // Program created, free proagram buffers
   freeProgramBuffers(rt);

  //printf(".....building program\n");
  err = clBuildProgram(rt->program,1,&rt->device,options,NULL,NULL);
  if (err != CL_SUCCESS) {
    printf("Couldn't build program\n");
    clGetProgramBuildInfo(rt->program,rt->device,CL_PROGRAM_BUILD_LOG,0,NULL,&log_size);
    program_log=  (char*)calloc(log_size+1,sizeof(char));
    clGetProgramBuildInfo(rt->program,rt->device,CL_PROGRAM_BUILD_LOG,log_size,program_log,NULL);
    printf("Program Log:\n%s\n",program_log);
    free(program_log);
    exit(1);
  }
  //printf("success...program built\n");
  
  
  err = loadKernels(rt);
  if (err != CL_SUCCESS) {
    printf("Problem while loading kernel\n");
    return err;
  }
  
  printf("OCL initialization successful\n");
  return CL_SUCCESS;
  
}
Beispiel #3
0
int main(int argc, char const *argv[])
{
	//Local variables
	SpiceDouble et_0;
	SpiceDouble et_end;
	SpiceDouble *t = NULL;
	SpiceDouble **pos_hci = NULL;
	SpiceDouble **pos_iau = NULL;
	SpiceDouble **pos_hee = NULL;
	SpiceDouble *lon_iau = NULL;
	SpiceDouble *lat_iau = NULL;
	SpiceDouble *lon_hci = NULL;
	SpiceDouble *lat_hci = NULL;
	SpiceDouble *distance = NULL;
	SpiceInt n;
	SpiceInt i;
	char START_DATE[50]; 
	char STOP_DATE[50]; 
	char text_filename[50];
	char nc_filename[50];


	//Load specific kernels : leap years, planets and satellites objects, planetary constants and specific heliospheric frame (to use HCI frame) 
	if (!loadKernels(KERNELS))
	{
		printf("[ERROR] \"%s\" kernel list : no such file\n", KERNELS);
		exit(EXIT_FAILURE);
	}

	//Configure boundaries
	strcpy(START_DATE, argv[4]);
	strcpy(STOP_DATE, argv[5]);
	n = getBoundaries(START_DATE, &et_0, STOP_DATE, &et_end);
	if (n <= 0)
	{
		printf("[ERROR] Enable to get a date interval to compute Earth ephemeris.\n");

		exit(EXIT_FAILURE);
	}

	//Memory allocation
	t = (SpiceDouble*) malloc(n*sizeof(SpiceDouble));
	pos_hci = (SpiceDouble**) malloc(n*sizeof(SpiceDouble*));
	pos_iau = (SpiceDouble**) malloc(n*sizeof(SpiceDouble*));
	pos_hee = (SpiceDouble**) malloc(n*sizeof(SpiceDouble*));
	distance = (SpiceDouble*) malloc(n*sizeof(SpiceDouble));
	lon_hci = (SpiceDouble*) malloc(n*sizeof(SpiceDouble));
	lat_hci = (SpiceDouble*) malloc(n*sizeof(SpiceDouble));
	lon_iau = (SpiceDouble*) malloc(n*sizeof(SpiceDouble));
	lat_iau = (SpiceDouble*) malloc(n*sizeof(SpiceDouble));

	if ((t == NULL) || (pos_hci == NULL) || (distance == NULL) || (lon_hci == NULL) || (lat_hci == NULL) || (lon_iau == NULL) || (lat_iau == NULL) )  
	{
		printf("[ERROR] Memory allocation has failed. Not enough memory.\n");

		exit(EXIT_FAILURE);
	}
	else
	{
		for (i = 0; i < n; i++)
		{
			
			pos_hci[i] = NULL;
			pos_hci[i] = (SpiceDouble*) malloc(3*sizeof(SpiceDouble));
			pos_iau[i] = NULL;
			pos_iau[i] = (SpiceDouble*) malloc(3*sizeof(SpiceDouble));
			pos_hee[i] = NULL;
			pos_hee[i] = (SpiceDouble*) malloc(3*sizeof(SpiceDouble));

			if ((pos_hci[i] == NULL) || (pos_iau[i] == NULL) || (pos_hee[i] == NULL))
			{
				printf("[ERROR] Position : Memory allocation has failed.\n");
			}
		}
	}
	
	//Compute n positions of the celestial body wanted starting from et_0 epoch with a STEP step
	getPositions(TARGET, et_0, STEP, n, FRAME1, ABCORR, OBSERVER, t, pos_hci);
	getPositions(TARGET, et_0, STEP, n, FRAME2, ABCORR, OBSERVER, t, pos_iau);
	getPositions(TARGET, et_0, STEP, n, FRAME3, ABCORR, OBSERVER, t, pos_hee);

	//Compute longitudes and latitudes
	getLonLat(pos_hci, lon_hci, lat_hci, n);
	getLonLat(pos_iau, lon_iau, lat_iau, n);

	//Compute n distances of the celestial body wanted relatively with the Sun
	getDistance(n, pos_hci, distance);

	//Print celestial body positions for the time interval
	//printPositions(t, pos);

	//Get files name
	//getFilesName(BODY_NAME, START_DATE, ".txt", text_filename);
	getFilesName(BODY_NAME, START_DATE, ".nc", nc_filename);

	//Write celestial body positions into "earth.txt" file
	//createTextFile(text_filename, n, t, pos_hci, pos_iau, pos_hee, lon_hci, lat_hci, lon_iau, lat_iau, distance);

	//Write celestial body positions into "earth.nc" file
	createNc(nc_filename, n, t, pos_hci, pos_iau, pos_hee, lon_hci, lat_hci, lon_iau, lat_iau, distance);

	//Free memory
	free(t);
	free(distance);
	for (i = 0; i < n; i++)
	{
		free(pos_hci[i]);
		pos_hci[i] = NULL;
		free(pos_iau[i]);
		pos_iau[i] = NULL;
		free(pos_hee[i]);
		pos_hee[i] = NULL;
	}
	free(pos_hci);
	pos_hci = NULL;
	free(pos_iau);
	pos_iau = NULL;
	free(pos_hee);
	pos_hee = NULL;

	free(lon_hci);
	lon_hci = NULL;

	free(lat_hci);
	lat_hci = NULL;

	free(lon_iau);
	lon_iau = NULL;

	free(lat_iau);
	lat_iau = NULL;

	return 0;
}