コード例 #1
0
ファイル: app.cpp プロジェクト: grahambrooks/qcon-ctod
int app::run(int argc, const char* argv[]) {
  std::cout << "QCon Duplicatetext finder" << std::endl;
  
  try {
    std::list<std::string> paths;
    
    for (auto i = 1; i < argc; i++) {
      if (argv[i][strlen(argv[i])] != '/') {
        paths.insert(paths.end(), string(argv[i]) + "/");
      } else {
        paths.insert(paths.end(), string(argv[i]));
      }
    }
    
    find_duplicates(paths);
    
    print_platform_info();
    
  } catch(std::exception& e) {
    std::cerr << "error: " << e.what() << "\n";
    return 1;
  } catch(...) {
    std::cerr << "Exception of unknown type!\n";
    return 1;
  }
  
  return 0;
}
コード例 #2
0
int main() {
  cl_uint num_platforms;
  CHECK_STATUS(clGetPlatformIDs(0, NULL, &num_platforms));

  cl_platform_id* platforms = (cl_platform_id*)malloc(sizeof(cl_platform_id) * num_platforms);
  CHECK_STATUS(clGetPlatformIDs(num_platforms, platforms, NULL));

  printf("\nFound %u OpenCL platform(s)\n\n", num_platforms);
  for (int i = 0; i < num_platforms; ++i) {
    printf("Platform %d\n", i);
    print_platform_info(platforms[i]);
  }
}
コード例 #3
0
ファイル: ocllib.c プロジェクト: sifrrich/ocl-examples
void print_platforms(void) {

  // Get number of platforms.
  cl_uint num_platforms;
  cl_int status;

  status = clGetPlatformIDs(0, NULL, &num_platforms);
  checkError(status, "Query for number of platforms failed");

  fprintf(stderr,"%d Platforms found\n", num_platforms);

  // Get a list of all platform ids.
  cl_platform_id *pids = (cl_platform_id *) alloca(sizeof(cl_platform_id)*num_platforms);
  status = clGetPlatformIDs(num_platforms, pids, NULL);
  checkError(status, "Query for all platform ids failed");

  // For each platform, get name.
  for(unsigned i = 0; i < num_platforms; ++i) {
    fprintf(stderr,"Platform ID %d\n", i);

    print_platform_info(pids[i]);

    //get all device ids
    cl_uint num_devices;
    status = clGetDeviceIDs(pids[i], CL_DEVICE_TYPE_ALL, 0, NULL, &num_devices);
    checkError(status, "Query for number of devices failed");

    cl_device_id *dids = (cl_device_id *) alloca(sizeof(cl_device_id)*num_devices);

    status = clGetDeviceIDs(pids[i], CL_DEVICE_TYPE_ALL, num_devices, dids, NULL);
    checkError(status, "Query for device ids");

    for (unsigned j = 0; j < num_devices; ++j) {
      device_info_string(dids[j], CL_DEVICE_VENDOR, "CL_DEVICE_VENDOR");
      device_info_string(dids[j], CL_DEVICE_NAME, "CL_DEVICE_NAME");
      device_info_string(dids[j], CL_DEVICE_VERSION, "CL_DEVICE_VERSION");
      device_info_string(dids[j], CL_DRIVER_VERSION, "CL_DRIVER_VERSION");
    }
    fprintf(stderr,"===============================================\n");
  }
}
コード例 #4
0
ファイル: util.c プロジェクト: EricTing/geauxdock_cs_v2
cl_device_id
opencl_choose_device (cl_device_type dev_type)
{
#define MAX_PLATFORMS 10
#define MAX_DEVICES 10

    cl_platform_id platforms[MAX_PLATFORMS];
    cl_uint platforms_n = 0;
    cl_device_id devices[MAX_DEVICES];
    cl_uint devices_n = 0;  // devices per platform


    CL_ERR (clGetPlatformIDs (MAX_PLATFORMS, platforms, &platforms_n));
    if (platforms_n < 1) {
        printf ("Error: no platforms found while looking for a platform.\n");
        exit (EXIT_FAILURE);
    }

    cl_uint p;
    for (p = 0; p < platforms_n; ++p) {
        print_platform_info (platforms[p]);
        CL_ERR (clGetDeviceIDs (platforms[p], CL_DEVICE_TYPE_ALL, MAX_DEVICES, devices, &devices_n));
        //CL_ERR (clGetDeviceIDs (platforms[p], dev_type, MAX_DEVICES, devices, &devices_n));

        cl_uint d;
        for (d = 0; d < devices_n; ++d) {
            print_device_info (devices[d]);
            if (dev_type == opencl_device_type (devices[d])) {
                printf ("Choose device %i\n", devices[d]);
                return devices[d];
            }
        }
    }

    printf ("No requested type of device found in the system\n");
    exit (EXIT_FAILURE);
}