Exemplo n.º 1
0
    /// Returns the supported image formats for the context.
    ///
    /// \see_opencl_ref{clGetSupportedImageFormats}
    static std::vector<image_format> get_supported_formats(const context &context,
                                                           cl_mem_flags flags)
    {
        cl_uint count = 0;
        clGetSupportedImageFormats(context,
                                   flags,
                                   CL_MEM_OBJECT_IMAGE2D,
                                   0,
                                   0,
                                   &count);

        std::vector<cl_image_format> cl_formats(count);
        clGetSupportedImageFormats(context,
                                   flags,
                                   CL_MEM_OBJECT_IMAGE2D,
                                   count,
                                   &cl_formats[0],
                                   0);

        std::vector<image_format> formats;
        for(size_t i = 0; i < count; i++){
            formats.push_back(image_format(cl_formats[i]));
        }

        return formats;
    }
Exemplo n.º 2
0
 std::vector<cl_image_format> getSupportedImageFormats(cl_context context, cl_mem_flags flags, cl_mem_object_type image_type)
 {
   cl_uint num_elements;
   CL_CHECKED_CALL(clGetSupportedImageFormats(context, flags, image_type, 0, nullptr, &num_elements));
   std::vector<cl_image_format> formats(num_elements);
   CL_CHECKED_CALL(clGetSupportedImageFormats(context, flags, image_type, formats.size(), &formats[0], nullptr));
   return move(formats);
 }
Exemplo n.º 3
0
bool Context::createContext(bool glInterop)
{
    if(_initialized)
        return false;

    QMutexLocker locker(&_lock);

    _glInterop= glInterop;

    QVector<cl_context_properties> props;
    if(_glInterop) {
        // Add OpenGL properties
        #ifdef __MACOSX
            // Apple (untested)
            props << CL_CGL_SHAREGROUP_KHR;
            props << reinterpret_cast<cl_context_properties>(CGLGetShareGroup(CGLGetCurrentContext()));
            props << CL_CONTEXT_PLATFORM;
            props << reinterpret_cast<cl_context_properties>(devMgr().platform());
        #elif _WIN32
            // Windows (untested)
            props << CL_GL_CONTEXT_KHR
            props << reinterpret_cast<cl_context_properties>(wglGetCurrentContext());
            props << CL_WGL_HDC_KHR
            props << reinterpret_cast<cl_context_properties>(wglGetCurrentDC());
        #else
            // Linux/GLX
            props << CL_GL_CONTEXT_KHR;
            props << (cl_context_properties)glXGetCurrentContext();
            props << CL_GLX_DISPLAY_KHR;
            props << (cl_context_properties)glXGetCurrentDisplay();
            props << (cl_context_properties)(devMgr().platform());
        #endif
        props << 0; // Can't use nullptr here
    }

    // Create OpenCL context
    cl_int err;
    const auto propsPtr= props.count() ? props.data() : nullptr;
    const auto devs= devMgr().devices(); // Get selected devices from the dev manager
    _context= clCreateContext(propsPtr, devs.count(), devs.data(), nullptr, nullptr, &err);
    if(checkCLError(err, "clCreateContext"))
        return false;   

    // Get list of supported formats
    cl_uint formatCount;
    err= clGetSupportedImageFormats(_context, CL_MEM_READ_WRITE, CL_MEM_OBJECT_IMAGE2D,
                                    0, nullptr, &formatCount);
    if(checkCLError(err, "clGetSupportedImageFormats") or formatCount<=0)
        return false;
    _imgFormats.resize(formatCount);
    err= clGetSupportedImageFormats(_context, CL_MEM_READ_WRITE, CL_MEM_OBJECT_IMAGE2D,
                                    formatCount, _imgFormats.data(), nullptr);
    if(checkCLError(err, "clGetSupportedImageFormats"))
        return false;

    return true;
}
Exemplo n.º 4
0
// Queries the supported image formats for the device and prints
// them to the screen
 void printSupportedImageFormats()
{
    cl_uint numFormats;
    cl_int status;

    status = clGetSupportedImageFormats(context, 0, CL_MEM_OBJECT_IMAGE2D,
        0, NULL, &numFormats);
    cl_errChk(status, "getting supported image formats", true);

    cl_image_format* imageFormats = NULL;
    imageFormats = (cl_image_format*)alloc(sizeof(cl_image_format)*numFormats);

    status = clGetSupportedImageFormats(context, 0, CL_MEM_OBJECT_IMAGE2D,
        numFormats, imageFormats, NULL);

    printf("There are %d supported image formats\n", numFormats);

    cl_uint orders[]={CL_R,  CL_A, CL_INTENSITY, CL_LUMINANCE, CL_RG,
        CL_RA, CL_RGB, CL_RGBA, CL_ARGB, CL_BGRA};
    char  *orderstr[]={"CL_R", "CL_A","CL_INTENSITY", "CL_LUMINANCE", "CL_RG",
        "CL_RA", "CL_RGB", "CL_RGBA", "CL_ARGB", "CL_BGRA"};

    cl_uint types[]={
        CL_SNORM_INT8 , CL_SNORM_INT16, CL_UNORM_INT8, CL_UNORM_INT16,
        CL_UNORM_SHORT_565, CL_UNORM_SHORT_555, CL_UNORM_INT_101010,CL_SIGNED_INT8,
        CL_SIGNED_INT16,  CL_SIGNED_INT32, CL_UNSIGNED_INT8, CL_UNSIGNED_INT16,
        CL_UNSIGNED_INT32, CL_HALF_FLOAT, CL_FLOAT};

    char * typesstr[]={
        "CL_SNORM_INT8" ,"CL_SNORM_INT16","CL_UNORM_INT8","CL_UNORM_INT16",
        "CL_UNORM_SHORT_565","CL_UNORM_SHORT_555","CL_UNORM_INT_101010",
        "CL_SIGNED_INT8","CL_SIGNED_INT16","CL_SIGNED_INT32","CL_UNSIGNED_INT8",
        "CL_UNSIGNED_INT16","CL_UNSIGNED_INT32","CL_HALF_FLOAT","CL_FLOAT"};

    printf("Supported Formats:\n");
    for(int i = 0; i < (int)numFormats; i++) {
        printf("\tFormat %d: ", i);

        for(int j = 0; j < (int)(sizeof(orders)/sizeof(cl_int)); j++) {
            if(imageFormats[i].image_channel_order == orders[j]) {
                printf("%s, ", orderstr[j]);
            }
        }
        for(int j = 0; j < (int)(sizeof(types)/sizeof(cl_int)); j++) {
            if(imageFormats[i].image_channel_data_type == types[j]) {
                printf("%s, ", typesstr[j]);
            }
        }
        printf("\n");
    }

    free(imageFormats);
}
Exemplo n.º 5
0
/**
  Code obtained from https://github.com/marwan-abdellah/GPU-Computing-SDK-4.2.9/blob/master/OpenCL/src/oclDeviceQuery/oclDeviceQuery.cpp
 */
void vglClPrintSupportedImageFormats()
{
    // Determine and show image format support 
    cl_uint uiNumSupportedFormats = 0;

    // 2D
    clGetSupportedImageFormats(cl.context, CL_MEM_READ_ONLY, 
                               CL_MEM_OBJECT_IMAGE2D,
                               0, NULL, &uiNumSupportedFormats);
    cl_image_format* ImageFormats = new cl_image_format[uiNumSupportedFormats];
    clGetSupportedImageFormats(cl.context, CL_MEM_READ_ONLY, 
                               CL_MEM_OBJECT_IMAGE2D,   
                               uiNumSupportedFormats, ImageFormats, NULL);
    printf("  ---------------------------------\n");
    printf("  2D Image Formats Supported (%u)\n", uiNumSupportedFormats); 
    printf("  ---------------------------------\n");
    printf("  %-6s%-16s%-22s\n\n", "#", "Channel Order", "Channel Type"); 
    for(unsigned int i = 0; i < uiNumSupportedFormats; i++) 
    {  
        printf("  %-6u%-16s%-22s\n", (i + 1),
        oclImageFormatString(ImageFormats[i].image_channel_order), 
        oclImageFormatString(ImageFormats[i].image_channel_data_type));
    }
    printf("\n"); 
    delete [] ImageFormats;

    // 3D
    clGetSupportedImageFormats(cl.context, CL_MEM_READ_ONLY, 
                               CL_MEM_OBJECT_IMAGE3D,   
                               0, NULL, &uiNumSupportedFormats);
    ImageFormats = new cl_image_format[uiNumSupportedFormats];
    clGetSupportedImageFormats(cl.context, CL_MEM_READ_ONLY, 
                               CL_MEM_OBJECT_IMAGE3D,   
                               uiNumSupportedFormats, ImageFormats, NULL);
    printf("  ---------------------------------\n");
    printf("  3D Image Formats Supported (%u)\n", uiNumSupportedFormats); 
    printf("  ---------------------------------\n");
    printf("  %-6s%-16s%-22s\n\n", "#", "Channel Order", "Channel Type"); 
    for(unsigned int i = 0; i < uiNumSupportedFormats; i++) 
    {  
        printf("  %-6u%-16s%-22s\n", (i + 1),
        oclImageFormatString(ImageFormats[i].image_channel_order), 
        oclImageFormatString(ImageFormats[i].image_channel_data_type));
    }
    printf("\n"); 
    delete [] ImageFormats;
}
Exemplo n.º 6
0
void GetSupportedImageFormats(cl_context _context, cl_mem_object_type _type)
{
  const unsigned int entries = 500;
  cl_image_format* formats = new cl_image_format[entries];

  cl_uint _written = 0;

  // OpenCL constant to catch error IDs
  cl_int ciErr1;
  // Get list of supported image formats for READ_ONLY access
  ciErr1 = clGetSupportedImageFormats( _context, CL_MEM_READ_ONLY, _type, entries, formats, &_written);
  CHECK_OCL_ERR(ciErr1);

  MITK_INFO << "Supported Image Formats, Image: CL_MEM_READ_ONLY \n";

  for (unsigned int i=0; i<_written; i++)
  {
    MITK_INFO<< "ChannelType: " << GetImageTypeAsString(formats[i].image_channel_data_type) << "| ChannelOrder: "<< GetImageTypeAsString(formats[i].image_channel_order) <<"\n";
  }

  _written = 0;

  // Get list of supported image formats for READ_WRITE access
  ciErr1 = clGetSupportedImageFormats( _context, CL_MEM_READ_WRITE, _type, entries, formats, &_written);
  CHECK_OCL_ERR(ciErr1);

  MITK_INFO << "Supported Image Formats, Image: CL_MEM_READ_WRITE (found: " << _written <<") \n";

  for (unsigned int i=0; i<_written; i++)
  {
    MITK_INFO<< "ChannelType: " << GetImageTypeAsString(formats[i].image_channel_data_type) << "| ChannelOrder: "<< GetImageTypeAsString(formats[i].image_channel_order) <<"\n";
  }

  _written = 0;

  // Get list of supported image formats for WRITE_ONLY access
  ciErr1 = clGetSupportedImageFormats( _context, CL_MEM_WRITE_ONLY, _type, entries, formats, &_written);
  CHECK_OCL_ERR(ciErr1);

  MITK_INFO << "Supported Image Formats, Image: CL_MEM_WRITE_ONLY (found: " << _written <<") \n";

  for (unsigned int i=0; i<_written; i++)
  {
    MITK_INFO<< "ChannelType: " << GetImageTypeAsString(formats[i].image_channel_data_type) << "| ChannelOrder: "<< GetImageTypeAsString(formats[i].image_channel_order) <<"\n";
  }
}
Exemplo n.º 7
0
cl_int WINAPI wine_clGetSupportedImageFormats(cl_context context, cl_mem_flags flags, cl_mem_object_type image_type, cl_uint num_entries,
                                              cl_image_format * image_formats, cl_uint * num_image_formats)
{
    cl_int ret;
    TRACE("\n");
    ret = clGetSupportedImageFormats(context, flags, image_type, num_entries, image_formats, num_image_formats);
    return ret;
}
Exemplo n.º 8
0
int
main(void)
{
  cl_int err;
  cl_platform_id platform[1];
  cl_uint nplatforms;
  cl_device_id devices[MAX_DEVICES];
  cl_uint ndevices;
  cl_image_format *img_formats;
  cl_uint num_entries;
  
  err = clGetPlatformIDs (1, platform, &nplatforms);	
  if (err != CL_SUCCESS)
    return EXIT_FAILURE;

  err = clGetDeviceIDs (platform[0], CL_DEVICE_TYPE_ALL, MAX_DEVICES,
                        devices, &ndevices);
  if (err != CL_SUCCESS)
	return EXIT_FAILURE;

  TEST_ASSERT(ndevices >= 2);

  cl_context context = clCreateContext (NULL, ndevices, devices, NULL, NULL, 
                                        &err);

  if (err != CL_SUCCESS)
    return EXIT_FAILURE;
  
  clGetSupportedImageFormats (context, 0, CL_MEM_OBJECT_IMAGE2D, 0, 
                              NULL, &num_entries);
  
  img_formats = (cl_image_format*)malloc (sizeof(cl_image_format)*num_entries);

  clGetSupportedImageFormats (context, 0, CL_MEM_OBJECT_IMAGE2D, 
                                      num_entries, img_formats, NULL);

  if (err != CL_SUCCESS || num_entries == 0) 
    return EXIT_FAILURE;
  

  return EXIT_SUCCESS;
}
Exemplo n.º 9
0
Nullable<HeapVector<WebCLImageDescriptor>> WebCLContext::getSupportedImageFormats(unsigned memFlags, ExceptionState& es)
{
    HeapVector<WebCLImageDescriptor> supportedImageDescriptor;
    if (isReleased()) {
        es.throwWebCLException(WebCLException::InvalidContext, WebCLException::invalidContextMessage);
        return supportedImageDescriptor;
    }

    if (!WebCLInputChecker::isValidMemoryObjectFlag(memFlags)) {
        es.throwWebCLException(WebCLException::InvalidValue, WebCLException::invalidValueMessage);
        return supportedImageDescriptor;
    }

    cl_uint numberOfSupportedImageFormats = 0;
    cl_int err = clGetSupportedImageFormats(m_clContext, memFlags, CL_MEM_OBJECT_IMAGE2D, 0, 0, &numberOfSupportedImageFormats);

    if (err != CL_SUCCESS) {
        es.throwWebCLException(WebCLException::InvalidImageSize, WebCLException::invalidImageSizeMessage);
        return supportedImageDescriptor;
    }

    Vector<cl_image_format> supportedImages;
    supportedImages.reserveCapacity(numberOfSupportedImageFormats);
    supportedImages.resize(numberOfSupportedImageFormats);

    err = clGetSupportedImageFormats(m_clContext, memFlags, CL_MEM_OBJECT_IMAGE2D, numberOfSupportedImageFormats, supportedImages.data(), 0);
    if (err != CL_SUCCESS) {
        WebCLException::throwException(err, es);
    } else {
        for (size_t i = 0; i < static_cast<unsigned>(numberOfSupportedImageFormats); ++i) {
            if (WebCLInputChecker::isValidChannelOrder(supportedImages[i].image_channel_order) && WebCLInputChecker::isValidChannelType(supportedImages[i].image_channel_data_type)) {
                WebCLImageDescriptor des;
                des.setChannelOrder(supportedImages[i].image_channel_order);
                des.setChannelType(supportedImages[i].image_channel_data_type);
                supportedImageDescriptor.append(des);
            }
        }
    }

    return supportedImageDescriptor;
}
Exemplo n.º 10
0
static QList<QCLImageFormat> qt_cl_supportedImageFormats
    (cl_context ctx, cl_mem_flags flags, cl_mem_object_type image_type)
{
    cl_uint count = 0;
    QList<QCLImageFormat> list;
    if (clGetSupportedImageFormats
            (ctx, flags, image_type,
             0, 0, &count) != CL_SUCCESS || !count)
        return list;
    QVarLengthArray<cl_image_format> buf(count);
    if (clGetSupportedImageFormats
            (ctx, flags, image_type,
             count, buf.data(), 0) != CL_SUCCESS)
        return list;
    for (cl_uint index = 0; index < count; ++index) {
        list.append(QCLImageFormat
            (QCLImageFormat::ChannelOrder(buf[index].image_channel_order),
             QCLImageFormat::ChannelType(buf[index].image_channel_data_type)));
    }
    return list;
}
Exemplo n.º 11
0
void list_supported_image_formats ()
{
  OpenCLDevice d = OpenCLDevice::getDevices ().front ();
  cl_image_format formats[100];
  cl_uint returned;
  clGetSupportedImageFormats (d.getContext (), CL_MEM_READ_ONLY, CL_MEM_OBJECT_IMAGE2D, 100, formats, &returned);
  std::cout << returned << "\n";
  for (unsigned int i = 0; i < returned; ++i)
    {
      std::cout << "Format: " << getImageChannelOrder(formats[i].image_channel_order) << " , " << getImageChannelFormat(formats[i].image_channel_data_type) << "\n";
    }
}
Exemplo n.º 12
0
sge::opencl::memory_object::image::format_sequence
sge::opencl::context::object::supported_volume_image_formats(
	cl_mem_flags const mem_flags) const
{
	cl_uint num_entries;

	cl_int error_code =
		clGetSupportedImageFormats(
			context_,
			mem_flags,
			CL_MEM_OBJECT_IMAGE3D,
			0,
			nullptr,
			&num_entries);

	opencl::impl::handle_error(
		error_code,
		FCPPT_TEXT("clGetSupportedImageFormats(number of formats)"));

	sge::opencl::memory_object::image::format_sequence result(
		static_cast<opencl::memory_object::image::format_sequence::size_type>(
			num_entries));

	error_code =
		clGetSupportedImageFormats(
			context_,
			mem_flags,
			CL_MEM_OBJECT_IMAGE3D,
			num_entries,
			result.data(),
			nullptr);

	opencl::impl::handle_error(
		error_code,
		FCPPT_TEXT("clGetSupportedImageFormats(format list)"));

	return result;
}
Exemplo n.º 13
0
void mitk::OclImageFormats::CollectAvailableFormats()
{
    if( this->m_GpuContext == NULL)
    {
        mitkThrow() << "No GPU context was set! Use SetGPUContext() before calling this method!";
    }
    //todo what happens here?
    const unsigned int entries = 100;
    cl_image_format* formats = new cl_image_format[entries];

    cl_uint written = 0;
    cl_int clErr = 0;

    // GET formats for R/W, 2D
    clErr = clGetSupportedImageFormats( m_GpuContext, CL_MEM_READ_WRITE, CL_MEM_OBJECT_IMAGE2D, entries, formats, &written);
    CHECK_OCL_ERR( clErr );

    this->SortFormats( formats, written, 1 );

    // GET formats for R/-, 2D
    written = 0;
    clErr = clGetSupportedImageFormats( m_GpuContext, CL_MEM_READ_ONLY, CL_MEM_OBJECT_IMAGE2D, entries, formats, &written);
    CHECK_OCL_ERR( clErr );

    this->SortFormats( formats, written, 2 );

    // GET formats for -/W, 2D
    written = 0;
    clErr = clGetSupportedImageFormats( m_GpuContext, CL_MEM_WRITE_ONLY, CL_MEM_OBJECT_IMAGE2D, entries, formats, &written);
    CHECK_OCL_ERR( clErr );

    this->SortFormats( formats, written, 4 );
    //-----------------------


    // GET formats for R/W, 3D
    written = 0;
    clErr = clGetSupportedImageFormats( m_GpuContext, CL_MEM_READ_WRITE, CL_MEM_OBJECT_IMAGE3D, entries, formats, &written);
    CHECK_OCL_ERR( clErr );

    this->SortFormats( formats, written, 1, 3 );

    // GET formats for R/-, 3D
    written = 0;
    clErr = clGetSupportedImageFormats( m_GpuContext, CL_MEM_READ_ONLY, CL_MEM_OBJECT_IMAGE3D, entries, formats, &written);
    CHECK_OCL_ERR( clErr );

    this->SortFormats( formats, written, 2, 3 );

    // GET formats for -/W, 3D
    written = 0;
    clErr = clGetSupportedImageFormats( m_GpuContext, CL_MEM_WRITE_ONLY, CL_MEM_OBJECT_IMAGE3D, entries, formats, &written);
    CHECK_OCL_ERR( clErr );

    this->SortFormats( formats, written, 4, 3 );
}
Exemplo n.º 14
0
////////////////////////////////////////////////////////////////////////////////
// Program main
////////////////////////////////////////////////////////////////////////////////
int main(int argc, const char** argv) {

  const char *my_name = "[oclAvcDisc]";

  int bPassed = 1;
  char filename[500], cBuffer[1024], sProfileString[2048];
  FILE *log_ofs=NULL;
  time_t g_the_time;

  /* OpenCL variables */
  cl_int ciErrNum;
  cl_platform_id clSelectedPlatformID = NULL; 
  cl_uint ciDeviceCount;
  cl_device_id *devices;

  sprintf(filename, "oclAvcDisc.txt");
  if( (log_ofs=fopen(filename, "a"))== NULL )  {
    fprintf(stderr, "[oclAvcDisc] Error, could not open file %s\n", filename);
    exit(1);
  }

  g_the_time = time(NULL);

  _write_log(log_ofs, "%s oclDeviceQuery.exe Starting...\n", my_name); 

  /* Get OpenCL platform ID for NVIDIA if avaiable, otherwise default */
  _write_log(log_ofs, "%s OpenCL SW Info:\n", my_name);
  ciErrNum = oclGetPlatformID (&clSelectedPlatformID);
  oclCheckError(ciErrNum, CL_SUCCESS);

  /* Get OpenCL platform name and version */
  ciErrNum = clGetPlatformInfo (clSelectedPlatformID, CL_PLATFORM_NAME, sizeof(cBuffer), cBuffer, NULL);
  if (ciErrNum == CL_SUCCESS) {
    _write_log(log_ofs, "%s CL_PLATFORM_NAME: \t%s\n", my_name, cBuffer);
  } else {
    _write_log(log_ofs, "%s Error %i in clGetPlatformInfo Call !!!\n\n", my_name, ciErrNum);
    bPassed = 0;
  }

  ciErrNum = clGetPlatformInfo (clSelectedPlatformID, CL_PLATFORM_VERSION, sizeof(cBuffer), cBuffer, NULL);
  if (ciErrNum == CL_SUCCESS) {
    _write_log(log_ofs, "%s CL_PLATFORM_VERSION: \t%s\n", my_name, cBuffer);
  } else {
    _write_log(" Error %i in clGetPlatformInfo Call !!!\n\n", ciErrNum);
    bPassed = 0;
  }

  // Get and log OpenCL device info 
  _write_log(log_ofs, "%s OpenCL Device Info:\n\n", my_name);
  ciErrNum = clGetDeviceIDs (clSelectedPlatformID, CL_DEVICE_TYPE_ALL, 0, NULL, &ciDeviceCount);

  // check for 0 devices found or errors... 
  if (ciDeviceCount == 0) {
    _write_log(log_ofs, "%s No devices found supporting OpenCL (return code %i)\n\n", my_name, ciErrNum);
    bPassed = false;
  } else if (ciErrNum != CL_SUCCESS) {
    _write_log(log_ofs, "%s Error %i in clGetDeviceIDs call !!!\n\n", my_name, ciErrNum);
    bPassed = false;
  } else {
    // Get and log the OpenCL device ID's
     char cTemp[2];
    _write_log(log_ofs, "%s %u devices found supporting OpenCL:\n\n", my_name , ciDeviceCount);
    sprintf(cTemp, "%u", ciDeviceCount);
    if ((devices = (cl_device_id*)malloc(sizeof(cl_device_id) * ciDeviceCount)) == NULL) {
      _write_log(log_ofs, "%s Failed to allocate memory for devices !!!\n\n", my_name);
      bPassed = false;
    }
    ciErrNum = clGetDeviceIDs (clSelectedPlatformID, CL_DEVICE_TYPE_ALL, ciDeviceCount, devices, &ciDeviceCount);
    if (ciErrNum == CL_SUCCESS) {
      //Create a context for the devices
      cl_context cxGPUContext = clCreateContext(0, ciDeviceCount, devices, NULL, NULL, &ciErrNum);
      if (ciErrNum != CL_SUCCESS) {
        _write_log(log_ofs, "%s Error %i in clCreateContext call !!!\n\n", my_name, ciErrNum);
        bPassed = false;
      } else {
        // show info for each device in the context
        for(unsigned int i = 0; i < ciDeviceCount; ++i ) {  
          _write_log(log_ofs, "%s ---------------------------------\n", my_name);
          clGetDeviceInfo(devices[i], CL_DEVICE_NAME, sizeof(cBuffer), &cBuffer, NULL);
          _write_log(log_ofs, "%s Device %s\n", my_name, cBuffer);
          _write_log(log_ofs, "%s ---------------------------------\n", my_name);
          oclPrintDevInfo(LOGBOTH, devices[i]);
        }
        // Determine and show image format support 
        cl_uint uiNumSupportedFormats = 0;

        // 2D
        clGetSupportedImageFormats(cxGPUContext, CL_MEM_READ_ONLY, CL_MEM_OBJECT_IMAGE2D, NULL, NULL, &uiNumSupportedFormats);
        cl_image_format *ImageFormats = NULL;
        ImageFormats = (cl_image_format*)malloc(uiNumSupportedFormats*sizeof(cl_image_format));
        if(ImageFormats==NULL) {
          _write_log(log_ofs, "%s Error, could not alloc ImageFormats\n", my_name);
          exit(2);
        }

        clGetSupportedImageFormats(cxGPUContext, CL_MEM_READ_ONLY, CL_MEM_OBJECT_IMAGE2D, uiNumSupportedFormats, ImageFormats, NULL);
        _write_log(log_ofs, "%s  ---------------------------------\n", my_name);
        _write_log(log_ofs, "%s  2D Image Formats Supported (%u)\n", my_name, uiNumSupportedFormats); 
        _write_log(log_ofs, "%s  ---------------------------------\n", my_name);
        _write_log(log_ofs, "%s  %-6s%-16s%-22s\n\n", my_name, "#", "Channel Order", "Channel Type"); 
        for(unsigned int i = 0; i < uiNumSupportedFormats; i++) {  
           _write_log(log_ofs, "%s  %-6u%-16s%-22s\n", my_name, (i + 1), 
               oclImageFormatString(ImageFormats[i].image_channel_order), 
               oclImageFormatString(ImageFormats[i].image_channel_data_type));
        }
        _write_log(log_ofs, "%s\n", my_name); 
        free(ImageFormats); ImageFormats = NULL;

        // 3D
        clGetSupportedImageFormats(cxGPUContext, CL_MEM_READ_ONLY, CL_MEM_OBJECT_IMAGE3D, NULL, NULL, &uiNumSupportedFormats);
        ImageFormats = (cl_image_format*)malloc(uiNumSupportedFormats*sizeof(cl_image_format));
        if(ImageFormats==NULL) {
          _write_log(log_ofs, "%s Error, could not alloc ImageFormats\n", my_name);
          exit(3);
        }
        clGetSupportedImageFormats(cxGPUContext, CL_MEM_READ_ONLY, CL_MEM_OBJECT_IMAGE3D, uiNumSupportedFormats, ImageFormats, NULL);
        _write_log(log_ofs, "%s  ---------------------------------\n", my_name);
        _write_log(log_ofs, "%s  3D Image Formats Supported (%u)\n", my_name, uiNumSupportedFormats); 
        _write_log(log_ofs, "%s  ---------------------------------\n", my_name);
        _write_log(log_ofs, "%s  %-6s%-16s%-22s\n\n", my_name, "#", "Channel Order", "Channel Type"); 
        for(unsigned int i = 0; i < uiNumSupportedFormats; i++) {  
          _write_log(log_ofs, "%s  %-6u%-16s%-22s\n", my_name, (i + 1),
              oclImageFormatString(ImageFormats[i].image_channel_order), 
              oclImageFormatString(ImageFormats[i].image_channel_data_type));
        }
        write_log(log_ofs, "%s\n", my_name); 
        free(ImageFormats); ImageFormats=NULL;
      }
    } else {
      write_log(log_ofs, "%s Error %i in clGetDeviceIDs call !!!\n\n", my_name, ciErrNum);
      bPassed = 0;
    }
  }

  // finish
  _write_log(log_ofs, "%s %s\n\n", my_name, bPassed==1 ? "PASSED" : "FAILED"); 
  fflush(log_ofs);
  fclose(log_ofs);
  return(0);
}
Exemplo n.º 15
0
vx_status vxTargetInit(vx_target_t *target)
{
    vx_status status = VX_ERROR_NO_RESOURCES;
    cl_int err = 0;
    vx_context context = target->base.context;
    cl_uint p, d, k;
    char *vx_incs = getenv("VX_CL_INCLUDE_DIR");
    char *cl_dirs = getenv("VX_CL_SOURCE_DIR");
    char cl_args[1024];

    snprintf(cl_args, sizeof(cl_args), "-D VX_CL_KERNEL -I %s -I %s %s %s", (vx_incs?vx_incs:"C:\\Users\\Eric\\Desktop\\VS_OpenVX2\\example_multinode_graph\\cl_code"), cl_dirs,
//#if !defined(__APPLE__)
//        "-D CL_USE_LUMINANCE",
//#else
        "",
//#endif
#if defined(VX_INCLUDE_DIR)
    "-I "VX_INCLUDE_DIR" "
#else
    " "
#endif
    );

    if (cl_dirs == NULL) {
#ifdef VX_CL_SOURCE_DIR
        const char *sdir = VX_CL_SOURCE_DIR;
        int len = strlen(sdir);
        cl_dirs = malloc(len);
        strncpy(cl_dirs, sdir, len);
#else
        return status;
#endif
    }

    strncpy(target->name, name, VX_MAX_TARGET_NAME);
    target->priority = VX_TARGET_PRIORITY_OPENCL;

    context->num_platforms = CL_MAX_PLATFORMS;
    err = clGetPlatformIDs(CL_MAX_PLATFORMS, context->platforms, NULL);
    if (err != CL_SUCCESS)
        goto exit;

    for (p = 0; p < context->num_platforms; p++) {
        err = clGetDeviceIDs(context->platforms[p], CL_DEVICE_TYPE_ALL,
            0, NULL, &context->num_devices[p]);
        err = clGetDeviceIDs(context->platforms[p], CL_DEVICE_TYPE_ALL,
            context->num_devices[p] > CL_MAX_DEVICES ? CL_MAX_DEVICES : context->num_devices[p],
            context->devices[p], NULL);
        if (err == CL_SUCCESS) {
            cl_context_properties props[] = {
                (cl_context_properties)CL_CONTEXT_PLATFORM,
                (cl_context_properties)context->platforms[p],
                (cl_context_properties)0,
            };
            for (d = 0; d < context->num_devices[p]; d++) {
                char deviceName[64];
                cl_bool compiler = CL_FALSE;
                cl_bool available = CL_FALSE;
                cl_bool image_support = CL_FALSE;
                err = clGetDeviceInfo(context->devices[p][d], CL_DEVICE_NAME, sizeof(deviceName), deviceName, NULL);
                CL_ERROR_MSG(err, "clGetDeviceInfo");
                err = clGetDeviceInfo(context->devices[p][d], CL_DEVICE_COMPILER_AVAILABLE, sizeof(cl_bool), &compiler, NULL);
                CL_ERROR_MSG(err, "clGetDeviceInfo");
                err = clGetDeviceInfo(context->devices[p][d], CL_DEVICE_AVAILABLE, sizeof(cl_bool), &available, NULL);
                CL_ERROR_MSG(err, "clGetDeviceInfo");
                err = clGetDeviceInfo(context->devices[p][d], CL_DEVICE_IMAGE_SUPPORT, sizeof(cl_bool), &image_support, NULL);
                CL_ERROR_MSG(err, "clGetDeviceInfo");
                VX_PRINT(VX_ZONE_INFO, "Device %s (compiler=%s) (available=%s) (images=%s)\n", deviceName, (compiler?"TRUE":"FALSE"), (available?"TRUE":"FALSE"), (image_support?"TRUE":"FALSE"));
            }
            context->global[p] = clCreateContext(props,
                                                 context->num_devices[p],
                                                 context->devices[p],
                                                 vxcl_platform_notifier,
                                                 target,
                                                 &err);
            if (err != CL_SUCCESS)
                break;

            /* check for supported formats */
            if (err == CL_SUCCESS) {
                cl_uint f,num_entries = 0u;
                cl_image_format *formats = NULL;
                cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR;
                cl_mem_object_type type = CL_MEM_OBJECT_IMAGE2D;

                err = clGetSupportedImageFormats(context->global[p], flags, type, 0, NULL, &num_entries);
                formats = (cl_image_format *)malloc(num_entries * sizeof(cl_image_format));
                err = clGetSupportedImageFormats(context->global[p], flags, type, num_entries, formats, NULL);
                for (f = 0; f < num_entries; f++) {
                    char order[256];
                    char datat[256];
    #define CASE_STRINGERIZE2(value, string) case value: strcpy(string, #value); break
                    switch(formats[f].image_channel_order) {
                        CASE_STRINGERIZE2(CL_R, order);
                        CASE_STRINGERIZE2(CL_A, order);
                        CASE_STRINGERIZE2(CL_RG, order);
                        CASE_STRINGERIZE2(CL_RA, order);
                        CASE_STRINGERIZE2(CL_RGB, order);
                        CASE_STRINGERIZE2(CL_RGBA, order);
                        CASE_STRINGERIZE2(CL_BGRA, order);
                        CASE_STRINGERIZE2(CL_ARGB, order);
                        CASE_STRINGERIZE2(CL_INTENSITY, order);
                        CASE_STRINGERIZE2(CL_LUMINANCE, order);
                        CASE_STRINGERIZE2(CL_Rx, order);
                        CASE_STRINGERIZE2(CL_RGx, order);
                        CASE_STRINGERIZE2(CL_RGBx, order);
    #if defined(CL_VERSION_1_2) && defined(cl_khr_gl_depth_images)
                        CASE_STRINGERIZE2(CL_DEPTH, order);
                        CASE_STRINGERIZE2(CL_DEPTH_STENCIL, order);
    #if defined(__APPLE__)
                        CASE_STRINGERIZE2(CL_1RGB_APPLE, order);
                        CASE_STRINGERIZE2(CL_BGR1_APPLE, order);
                        CASE_STRINGERIZE2(CL_SFIXED14_APPLE, order);
                        CASE_STRINGERIZE2(CL_BIASED_HALF_APPLE, order);
                        CASE_STRINGERIZE2(CL_YCbYCr_APPLE, order);
                        CASE_STRINGERIZE2(CL_CbYCrY_APPLE, order);
                        CASE_STRINGERIZE2(CL_ABGR_APPLE, order);
    #endif
    #endif
                        default:
                            sprintf(order, "%x", formats[f].image_channel_order);
                            break;
                    }
                    switch(formats[f].image_channel_data_type) {
                        CASE_STRINGERIZE2(CL_SNORM_INT8, datat);
                        CASE_STRINGERIZE2(CL_SNORM_INT16, datat);
                        CASE_STRINGERIZE2(CL_UNORM_INT8, datat);
                        CASE_STRINGERIZE2(CL_UNORM_INT16, datat);
                        CASE_STRINGERIZE2(CL_UNORM_SHORT_565, datat);
                        CASE_STRINGERIZE2(CL_UNORM_SHORT_555, datat);
                        CASE_STRINGERIZE2(CL_UNORM_INT_101010, datat);
                        CASE_STRINGERIZE2(CL_SIGNED_INT8, datat);
                        CASE_STRINGERIZE2(CL_SIGNED_INT16, datat);
                        CASE_STRINGERIZE2(CL_SIGNED_INT32, datat);
                        CASE_STRINGERIZE2(CL_UNSIGNED_INT8, datat);
                        CASE_STRINGERIZE2(CL_UNSIGNED_INT16, datat);
                        CASE_STRINGERIZE2(CL_UNSIGNED_INT32, datat);
                        CASE_STRINGERIZE2(CL_HALF_FLOAT, datat);
                        CASE_STRINGERIZE2(CL_FLOAT, datat);
    #if defined(CL_VERSION_2_0)
                        CASE_STRINGERIZE2(CL_UNORM_INT24, datat);
    #endif
                        default:
                            sprintf(order, "%x", formats[f].image_channel_data_type);
                            break;
                    }
                    VX_PRINT(VX_ZONE_INFO, "%s : %s\n", order, datat);
                }
            }

            /* create a queue for each device */
            for (d = 0; d < context->num_devices[p]; d++)
            {
                context->queues[p][d] = clCreateCommandQueue(context->global[p],
                                                          context->devices[p][d],
                                                          CL_QUEUE_PROFILING_ENABLE,
                                                          &err);
                if (err == CL_SUCCESS) {
                }
            }

			char abs_source_path[VX_CL_MAX_PATH];
            /* for each kernel */
            for (k = 0; k < num_cl_kernels; k++)
            {
                char *sources = NULL;
                size_t programSze = 0;

                /* load the source file */
                VX_PRINT(VX_ZONE_INFO, "Joiner: %s\n", FILE_JOINER);
                VX_PRINT(VX_ZONE_INFO, "Path: %s\n", cl_dirs);
                VX_PRINT(VX_ZONE_INFO, "Kernel[%u] File: %s\n", k, cl_kernels[k]->sourcepath);
                VX_PRINT(VX_ZONE_INFO, "Kernel[%u] Name: %s\n", k, cl_kernels[k]->kernelname);
                VX_PRINT(VX_ZONE_INFO, "Kernel[%u] ID: %s\n", k, cl_kernels[k]->description.name);
				
				int cl_dirs_len = strlen(cl_dirs);
				int sourcepath_len = strlen(cl_kernels[k]->sourcepath);
				strncpy(abs_source_path, cl_dirs, cl_dirs_len);
				strncpy(&abs_source_path[cl_dirs_len], cl_kernels[k]->sourcepath, sourcepath_len);
				abs_source_path[cl_dirs_len+sourcepath_len] = '\0';
                sources = clLoadSources(abs_source_path, &programSze);
				VX_PRINT(VX_ZONE_INFO, "clLoadSources programSze:%d\n", programSze);
				
                /* create a program with this source */
                cl_kernels[k]->program[p] = clCreateProgramWithSource(context->global[p],
                    1,
                    (const char **)&sources,
                    &programSze,
                    &err);
                if (err == CL_SUCCESS)
                {
                    err = clBuildProgram((cl_program)cl_kernels[k]->program[p],
                        1,
                        (const cl_device_id *)context->devices,
                        (const char *)cl_args,
                        NULL,
                        NULL);
                    if (err != CL_SUCCESS)
                    {
                        CL_BUILD_MSG(err, "Build Error");
                        if (err == CL_BUILD_PROGRAM_FAILURE)
                        {
                            char log[10][1024];
                            size_t logSize = 0;
                            clGetProgramBuildInfo((cl_program)cl_kernels[k]->program[p],
                                (cl_device_id)context->devices[p][0],
                                CL_PROGRAM_BUILD_LOG,
                                sizeof(log),
                                log,
                                &logSize);
                            VX_PRINT(VX_ZONE_ERROR, "%s", log);
                        }
                    }
                    else
                    {
                        cl_int k2 = 0;
                        cl_build_status bstatus = 0;
                        size_t bs = 0;
                        err = clGetProgramBuildInfo(cl_kernels[k]->program[p],
                            context->devices[p][0],
                            CL_PROGRAM_BUILD_STATUS,
                            sizeof(cl_build_status),
                            &bstatus,
                            &bs);
                        VX_PRINT(VX_ZONE_INFO, "Status = %d (%d)\n", bstatus, err);
                        /* get the cl_kernels from the program */
                        cl_kernels[k]->num_kernels[p] = 1;
                        err = clCreateKernelsInProgram(cl_kernels[k]->program[p],
                            1,
                            &cl_kernels[k]->kernels[p],
                            NULL);
                        VX_PRINT(VX_ZONE_INFO, "Found %u cl_kernels in %s (%d)\n", cl_kernels[k]->num_kernels[p], cl_kernels[k]->sourcepath, err);
                        for (k2 = 0; (err == CL_SUCCESS) && (k2 < (cl_int)cl_kernels[k]->num_kernels[p]); k2++)
                        {
                            char kName[VX_MAX_KERNEL_NAME];
                            size_t size = 0;
                            err = clGetKernelInfo(cl_kernels[k]->kernels[p],
                                CL_KERNEL_FUNCTION_NAME,
                                0,
                                NULL,
                                &size);
                            err = clGetKernelInfo(cl_kernels[k]->kernels[p],
                                CL_KERNEL_FUNCTION_NAME,
                                size,
                                kName,
                                NULL);
                            VX_PRINT(VX_ZONE_INFO, "Kernel %s\n", kName);
                            if (strncmp(kName, cl_kernels[k]->kernelname, VX_MAX_KERNEL_NAME) == 0)
                            {
                                vx_kernel_f kfunc = cl_kernels[k]->description.function;
                                VX_PRINT(VX_ZONE_INFO, "Linked Kernel %s on target %s\n", cl_kernels[k]->kernelname, target->name);
                                target->num_kernels++;
                                target->base.context->num_kernels++;
                                status = vxInitializeKernel(target->base.context,
                                    &target->kernels[k],
                                    cl_kernels[k]->description.enumeration,
                                    (kfunc == NULL ? vxclCallOpenCLKernel : kfunc),
                                    cl_kernels[k]->description.name,
                                    cl_kernels[k]->description.parameters,
                                    cl_kernels[k]->description.numParams,
                                    cl_kernels[k]->description.input_validate,
                                    cl_kernels[k]->description.output_validate,
                                    cl_kernels[k]->description.initialize,
                                    cl_kernels[k]->description.deinitialize);
                                if (vxIsKernelUnique(&target->kernels[k]) == vx_true_e) {
                                    target->base.context->num_unique_kernels++;
                                } else {
                                    VX_PRINT(VX_ZONE_KERNEL, "Kernel %s is NOT unqiue\n", target->kernels[k].name);
                                }
                            }
                        }
                    }
                }
                else
                {
                    CL_ERROR_MSG(err, "Program");
                }
                free(sources);
            }
        }
    }
exit:
    if (err == CL_SUCCESS) {
        status = VX_SUCCESS;
    } else {
        status = VX_ERROR_NO_RESOURCES;
    }
    return status;
}
Exemplo n.º 16
0
OpenCLDeviceInfo::OpenCLDeviceInfo(cl_device_id device, cl_context context){
	// To get the device name, first we get the length.
	size_t stringSize;
	cl_int err = clGetDeviceInfo(device, CL_DEVICE_NAME, 0, NULL, &stringSize);

	// If error, we print to stdout and leave.
	if(clIsError(err)){
		clPrintError(err); return;
	}


	// We now allocate memory for it and get it.
	m_sDeviceName = (char*) malloc(stringSize+1);
	err = clGetDeviceInfo(device, CL_DEVICE_NAME, stringSize, m_sDeviceName, NULL);

	if(clIsError(err)){
		clPrintError(err); return;
	}

	// As with device name, we need to get size of both vendor string and version string.
	err = clGetDeviceInfo(device, CL_DEVICE_VENDOR, 0, NULL, &stringSize);
	if(clIsError(err)){
		clPrintError(err); return;
	}

	m_sDeviceVendorString = (char*) malloc(stringSize+1);
	err = clGetDeviceInfo(device, CL_DEVICE_VENDOR, stringSize, m_sDeviceVendorString, NULL);
	if(clIsError(err)){
		clPrintError(err); return;
	}

	// Now device version.
	err = clGetDeviceInfo(device, CL_DEVICE_VERSION, 0, NULL, &stringSize);
	if(clIsError(err)){
		clPrintError(err); return;
	}

	m_sOpenCLVersionString = (char*) malloc(stringSize+1);
	err = clGetDeviceInfo(device, CL_DEVICE_VERSION, stringSize, m_sOpenCLVersionString, NULL);
	if(clIsError(err)){
		clPrintError(err); return;
	}

	// Find the number of compute units. We know the size of an integer, so we don't ask for it. 
	cl_uint maxComputeUnits;
	err = clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(cl_uint), &maxComputeUnits, NULL);

	if(clIsError(err)){
		clPrintError(err); return;
	}
	m_maxComputeUnits = maxComputeUnits;

	// Find the frequency of the compute units. Same as before, we needn't query the size.
	cl_uint maxClockFrequency;
	err = clGetDeviceInfo(device, CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof(cl_uint), &maxClockFrequency, NULL);

	if(clIsError(err)){
		clPrintError(err); return;
	}
	m_maxComputeUnitFrequency = maxClockFrequency;
    
    size_t maxWorkGroupSize;
    err = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(size_t), &maxWorkGroupSize, NULL);

    if(clIsError(err)){
        clPrintError(err); return;
    }
    m_maxWorkGroupSize = maxWorkGroupSize;
    
    err = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_SIZES, 0, NULL, &m_workSizesDimensions);
    if(clIsError(err)){
        clPrintError(err); return;
    }
    m_maxWorkGroupSizes = (size_t*)malloc(m_workSizesDimensions);
    err = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_SIZES, m_workSizesDimensions, m_maxWorkGroupSizes, NULL);
    m_workSizesDimensions/=sizeof(size_t);
    if(clIsError(err)){
        clPrintError(err); return;
    }

	// We now query the device type. No need to check size.
	err = clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(cl_device_type), &m_deviceType, NULL);

	if(clIsError(err)){
		clPrintError(err); return;
	}

	cl_ulong globalMemSize;
	err = clGetDeviceInfo(device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(cl_ulong), &globalMemSize, NULL);

	if(clIsError(err)){
		clPrintError(err); return;
	}
	m_globalMemorySize = globalMemSize;
    
    err = clGetDeviceInfo(device, CL_DEVICE_LOCAL_MEM_SIZE, sizeof(cl_ulong), &m_localMemorySize, NULL);

    if(clIsError(err)){
        clPrintError(err); return;
    }
    
    err = clGetSupportedImageFormats(context, CL_MEM_READ_WRITE, CL_MEM_OBJECT_IMAGE2D, 0, NULL, &m_format_count);
    if(clIsError(err)){
        clPrintError(err); return;
    }
    m_image_formats = (cl_image_format*) malloc (sizeof(cl_image_format)*m_format_count + 1);
    err = clGetSupportedImageFormats(context, CL_MEM_READ_WRITE, CL_MEM_OBJECT_IMAGE2D, 10, m_image_formats, NULL);
    if(clIsError(err)){
        clPrintError(err); return;
    }
}
Exemplo n.º 17
0
void getGPUUnitSupportedImageFormats(cl_context context){
    
    cl_image_format supported_image_formats[1000];
    cl_uint supported_image_format_list_size;
    
    //collect supported image formats
    cl_int status = clGetSupportedImageFormats(
                                               context,
                                               CL_MEM_READ_ONLY,
                                               CL_MEM_OBJECT_IMAGE3D,
                                               sizeof(supported_image_formats) / sizeof(supported_image_formats[0]),
                                               supported_image_formats,
                                               &supported_image_format_list_size);
    if (status != CL_SUCCESS) {
        printf("%s\n", print_cl_errstring(status));
		exit(1);        
    }
    for (int i = 0; i < supported_image_format_list_size; i++) {
        printf("Supported image format: ");
        switch (supported_image_formats[i].image_channel_order) {
            case CL_R:
                printf("CL_R");
                break;
            case CL_A:
                printf("CL_A");
                break;
            case CL_INTENSITY:
                printf("CL_INTENSITY");
                break;
            case CL_LUMINANCE:
                printf("CL_LUMINANCE");
                break;
            case CL_RG:
                printf("CL_RG");
                break;
            case CL_RA:
                printf("CL_RA");
                break;
            case CL_RGB:
                printf("CL_RGB");
                break;
            case CL_RGBA:
                printf("CL_RGBA");
                break;
            case CL_ARGB:
                printf("CL_ARGB");
                break;
            case CL_BGRA:
                printf("CL_BGRA");
                break;
            default:
                printf("Unknown");
                break;
        }
        printf(", ");
        switch (supported_image_formats[i].image_channel_data_type) {
            case CL_UNORM_INT8:
                printf("CL_UNORM_INT8\n");
                break;
            case CL_UNORM_INT16:
                printf("CL_UNORM_INT16\n");
                break;
            case CL_SNORM_INT8:
                printf("CL_SNORM_INT8\n");
                break;
            case CL_SNORM_INT16:
                printf("CL_SNORM_INT16\n");
                break;
            case CL_HALF_FLOAT:
                printf("CL_HALF_FLOAT\n");
                break;
            case CL_FLOAT:
                printf("CL_FLOAT\n");
                break;
            case CL_UNORM_SHORT_565:
                printf("CL_UNORM_SHORT_565\n");
                break;
            case CL_UNORM_SHORT_555:
                printf("CL_UNORM_SHORT_555\n");
                break;
            case CL_UNORM_INT_101010:
                printf("CL_UNORM_INT_101010\n");
                break;
            case CL_SIGNED_INT8:
                printf("CL_SIGNED_INT8\n");
                break;
            case CL_UNSIGNED_INT8:
                printf("CL_UNSIGNED_INT8\n");
                break;
            case CL_SIGNED_INT16:
                printf("CL_SIGNED_INT16\n");
                break;
            case CL_SIGNED_INT32:
                printf("CL_SIGNED_INT32\n");
                break;
            case CL_UNSIGNED_INT16:
                printf("CL_UNSIGNED_INT16\n");
                break;
            case CL_UNSIGNED_INT32:
                printf("CL_UNSIGNED_INT32\n");
                break;
            default:
                printf("Unknown\n");
                break;
        }
    }
    
}