package org.kne.opencl64;

import java.lang.foreign.Arena;
import java.lang.foreign.MemorySegment;
import java.lang.foreign.ValueLayout;
import java.lang.foreign.ValueLayout.OfInt;
import java.lang.foreign.ValueLayout.OfLong;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;

import club.doki7.ffm.ptr.IntPtr;
import club.doki7.ffm.ptr.PointerPtr;
import club.doki7.opencl.CL;
import club.doki7.opencl.CLConstants;
import club.doki7.opencl.handle.CLDeviceId;
import club.doki7.opencl.handle.CLPlatformId;
import club.doki7.opencl.handle.CLProgram;

public class CLUtils {
	  private CL opencl;

	public CLUtils(CL opencl) {
		this.opencl=opencl;
	}

	/**
     * Returns the value of the device info parameter with the given name
     *
     * @param device The device
     * @param paramName The parameter name
     * @return The value
     */
    public int getInt(CLDeviceId device, int paramName)
    {
        return getInts(device, paramName, 1).getAtIndex(OfInt.JAVA_INT, 0);
    }

    /**
     * Returns the values of the device info parameter with the given name
     *
     * @param device The device
     * @param paramName The parameter name
     * @param numValues The number of values
     * @return The value
     */
    public MemorySegment getInts(CLDeviceId device, int paramName, int numValues)
    {
    	MemorySegment values = 	Arena.ofAuto().allocate(4*numValues);
        int errcode =opencl.getDeviceInfo(device, paramName, 4 * numValues, values, null);
		 CLUtils.checkResult(errcode);
        return values;
    }

    /**
     * Returns the value of the device info parameter with the given name
     *
     * @param device The device
     * @param paramName The parameter name
     * @return The value
     */
    public long getLong(CLDeviceId device, int paramName)
    {
        return getLongs(device, paramName, 1).getAtIndex(OfLong.JAVA_LONG, 0);
    }

    /**
     * Returns the values of the device info parameter with the given name
     *
     * @param device The device
     * @param paramName The parameter name
     * @param numValues The number of values
     * @return The value
     */
    public MemorySegment getLongs(CLDeviceId device, int paramName, int numValues)
    {
        MemorySegment values = Arena.ofAuto().allocate(8*numValues);
        int errcode=opencl.getDeviceInfo(device, paramName, 8 * numValues, values, null);
		 CLUtils.checkResult(errcode);
        return values;
    }

    /**
     * Returns the value of the device info parameter with the given name
     *
     * @param device The device
     * @param paramName The parameter name
     * @return The value
     */
    public String getString(CLDeviceId device, int paramName)
    {
        // Obtain the length of the string that will be queried
        PointerPtr size=PointerPtr.allocate(Arena.ofAuto());
       int errcode= opencl.getDeviceInfo(device, paramName, 0, MemorySegment.NULL, size);
		 CLUtils.checkResult(errcode);

        // Create a buffer of the appropriate size and fill it with the info
        MemorySegment memseg=Arena.ofAuto().allocate(size.read().address()+1);
        errcode =opencl.getDeviceInfo(device, paramName, memseg.byteSize(), memseg, size);
		 CLUtils.checkResult(errcode);
         // Create a string from the buffer (excluding the trailing \0 byte)
        return memseg.getString(0, Charset.forName("utf-8"));
        // return new String(buffer, 0, buffer.length-1);
    }

    /**
     * Returns the value of the platform info parameter with the given name
     *
     * @param platform The platform
     * @param paramName The parameter name
     * @return The value
     */
    public String getString(CLPlatformId platform, int paramName)
    {
        // Obtain the length of the string that will be queried
        PointerPtr size=PointerPtr.allocate(Arena.ofAuto());
        int errcode=opencl.getPlatformInfo(platform, paramName, 0, MemorySegment.NULL, size);
		 CLUtils.checkResult(errcode);

        // Create a buffer of the appropriate size and fill it with the info
       MemorySegment memseg=Arena.ofAuto().allocate(size.read().address()+1);
      errcode= opencl.getPlatformInfo(platform, paramName, memseg.byteSize(), memseg, size);
		 CLUtils.checkResult(errcode);
        // Create a string from the buffer (excluding the trailing \0 byte)
       return memseg.getString(0, Charset.forName("utf-8"));
       // return new String(buffer, 0, buffer.length-1);
    }
    
    /**
     * Returns the value of the device info parameter with the given name
     *
     * @param device The device
     * @param paramName The parameter name
     * @return The value
     */
    public long getSize(CLDeviceId device, int paramName)
    {
        return getSizes(device, paramName, 1)[0];
    }
    
    /**
     * Returns the values of the device info parameter with the given name
     *
     * @param device The device
     * @param paramName The parameter name
     * @param numValues The number of values
     * @return The value
     */
    public long[] getSizes(CLDeviceId device, int paramName, int numValues)
    {
        // The size of the returned data has to depend on 
        // the size of a size_t, which is handled here
    	long sizet=ValueLayout.ADDRESS.byteSize();
    	MemorySegment buffer=Arena.ofAuto().allocate(sizet*numValues);
       
        int errcode=opencl.getDeviceInfo(device, paramName, sizet * numValues, 
        		buffer, null);
		 CLUtils.checkResult(errcode);
        long values[] = new long[numValues];
        if (sizet == 4)
        {
            for (int i=0; i<numValues; i++)
            {
                values[i] = buffer.getAtIndex(OfInt.JAVA_INT,i );
            }
        }
        else
        {
            for (int i=0; i<numValues; i++)
            {
                values[i] = buffer.getAtIndex(OfLong.JAVA_LONG,i );
            }
        }
        return values;
    }
    
    
    /**
     * If the given result is different to CLConstants.SUCCESS and
     * exceptions have been enabled, this method will throw a
     * CLException with an error message that corresponds to the
     * given result code. Otherwise, the given result is simply
     * returned.
     *
     * @param result The result to check
     * @return The result that was given as the parameter
     * @throws CLException If exceptions have been enabled and
     * the given result code is not CLConstants.SUCCESS
     */
    public static int checkResult(OpenCLProgram cl_program, List<OpenCLDevice> devid,int result) {
    	if(result==CLConstants.BUILD_PROGRAM_FAILURE) {
    		if(devid==null) {
    			devid=cl_program.getContext().getDevices();
    		}
			StringBuilder builder=new StringBuilder("BUILD_PROGRAM_FAILURE\n");
    			for(int i=0;i<devid.size();i++) {
    				OpenCLDevice dev=devid.get(i);
    				builder.append("Device:");
    				builder.append(dev.getVendor());
    				builder.append(" ");
    				builder.append(dev.getName());
    				builder.append("\n");
    				builder.append( cl_program.getBuildLog(dev));
    			}
    		return checkResult(builder.toString(), result);
    	}
		return checkResult(result);
	}
    
    public static int checkResult(IntPtr result) {
    	return checkResult(result.read());
    }
    public static int checkResult(String message, IntPtr result) {
    	int resultv=result.read();
    	return checkResult(message,resultv);
    }
    public static int checkResult(int result)
    {
    	return checkResult(stringFor_errorCode(result),result);
    }
    public static int checkResult(String message,int result)
    {
        if ( result != CLConstants.SUCCESS)
        {	
        	switch(result) {
        	case CLConstants.BUILD_PROGRAM_FAILURE:
        		throw new OpenCLProgramBuildException(message, result);
        	default:
            throw new OpenCLException(message, result);
        	}
        }
        return result;
    }




    //=== String methods for constants =======================================


    /**
     * Returns the String identifying the given error code
     *
     * @param n The error code
     * @return The String identifying the given error code
     */
    public static String stringFor_errorCode(int n)
    {
        switch (n)
        {
            case CLConstants.SUCCESS: return "CL_SUCCESS";
            case CLConstants.DEVICE_NOT_FOUND: return "CL_DEVICE_NOT_FOUND";
            case CLConstants.DEVICE_NOT_AVAILABLE: return "CL_DEVICE_NOT_AVAILABLE";
            case CLConstants.COMPILER_NOT_AVAILABLE: return "CL_COMPILER_NOT_AVAILABLE";
            case CLConstants.MEM_OBJECT_ALLOCATION_FAILURE: return "CL_MEM_OBJECT_ALLOCATION_FAILURE";
            case CLConstants.OUT_OF_RESOURCES: return "CL_OUT_OF_RESOURCES";
            case CLConstants.OUT_OF_HOST_MEMORY: return "CL_OUT_OF_HOST_MEMORY";
            case CLConstants.PROFILING_INFO_NOT_AVAILABLE: return "CL_PROFILING_INFO_NOT_AVAILABLE";
            case CLConstants.MEM_COPY_OVERLAP: return "CL_MEM_COPY_OVERLAP";
            case CLConstants.IMAGE_FORMAT_MISMATCH: return "CL_IMAGE_FORMAT_MISMATCH";
            case CLConstants.IMAGE_FORMAT_NOT_SUPPORTED: return "CL_IMAGE_FORMAT_NOT_SUPPORTED";
            case CLConstants.BUILD_PROGRAM_FAILURE: return "CL_BUILD_PROGRAM_FAILURE";
            case CLConstants.MAP_FAILURE: return "CL_MAP_FAILURE";
            case CLConstants.MISALIGNED_SUB_BUFFER_OFFSET: return "CL_MISALIGNED_SUB_BUFFER_OFFSET";
            case CLConstants.EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST: return "CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST";
            case CLConstants.COMPILE_PROGRAM_FAILURE: return "CL_COMPILE_PROGRAM_FAILURE";
            case CLConstants.LINKER_NOT_AVAILABLE: return "CL_LINKER_NOT_AVAILABLE";
            case CLConstants.LINK_PROGRAM_FAILURE: return "CL_LINK_PROGRAM_FAILURE";
            case CLConstants.DEVICE_PARTITION_FAILED: return "CL_DEVICE_PARTITION_FAILED";
            case CLConstants.KERNEL_ARG_INFO_NOT_AVAILABLE: return "CL_KERNEL_ARG_INFO_NOT_AVAILABLE";
            case CLConstants.INVALID_VALUE: return "CL_INVALID_VALUE";
            case CLConstants.INVALID_DEVICE_TYPE: return "CL_INVALID_DEVICE_TYPE";
            case CLConstants.INVALID_PLATFORM: return "CL_INVALID_PLATFORM";
            case CLConstants.INVALID_DEVICE: return "CL_INVALID_DEVICE";
            case CLConstants.INVALID_CONTEXT: return "CL_INVALID_CONTEXT";
            case CLConstants.INVALID_QUEUE_PROPERTIES: return "CL_INVALID_QUEUE_PROPERTIES";
            case CLConstants.INVALID_COMMAND_QUEUE: return "CL_INVALID_COMMAND_QUEUE";
            case CLConstants.INVALID_HOST_PTR: return "CL_INVALID_HOST_PTR";
            case CLConstants.INVALID_MEM_OBJECT: return "CL_INVALID_MEM_OBJECT";
            case CLConstants.INVALID_IMAGE_FORMAT_DESCRIPTOR: return "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR";
            case CLConstants.INVALID_IMAGE_SIZE: return "CL_INVALID_IMAGE_SIZE";
            case CLConstants.INVALID_SAMPLER: return "CL_INVALID_SAMPLER";
            case CLConstants.INVALID_BINARY: return "CL_INVALID_BINARY";
            case CLConstants.INVALID_BUILD_OPTIONS: return "CL_INVALID_BUILD_OPTIONS";
            case CLConstants.INVALID_PROGRAM: return "CL_INVALID_PROGRAM";
            case CLConstants.INVALID_PROGRAM_EXECUTABLE: return "CL_INVALID_PROGRAM_EXECUTABLE";
            case CLConstants.INVALID_KERNEL_NAME: return "CL_INVALID_KERNEL_NAME";
            case CLConstants.INVALID_KERNEL_DEFINITION: return "CL_INVALID_KERNEL_DEFINITION";
            case CLConstants.INVALID_KERNEL: return "CL_INVALID_KERNEL";
            case CLConstants.INVALID_ARG_INDEX: return "CL_INVALID_ARG_INDEX";
            case CLConstants.INVALID_ARG_VALUE: return "CL_INVALID_ARG_VALUE";
            case CLConstants.INVALID_ARG_SIZE: return "CL_INVALID_ARG_SIZE";
            case CLConstants.INVALID_KERNEL_ARGS: return "CL_INVALID_KERNEL_ARGS";
            case CLConstants.INVALID_WORK_DIMENSION: return "CL_INVALID_WORK_DIMENSION";
            case CLConstants.INVALID_WORK_GROUP_SIZE: return "CL_INVALID_WORK_GROUP_SIZE";
            case CLConstants.INVALID_WORK_ITEM_SIZE: return "CL_INVALID_WORK_ITEM_SIZE";
            case CLConstants.INVALID_GLOBAL_OFFSET: return "CL_INVALID_GLOBAL_OFFSET";
            case CLConstants.INVALID_EVENT_WAIT_LIST: return "CL_INVALID_EVENT_WAIT_LIST";
            case CLConstants.INVALID_EVENT: return "CL_INVALID_EVENT";
            case CLConstants.INVALID_OPERATION: return "CL_INVALID_OPERATION";
            case CLConstants.INVALID_GL_OBJECT: return "CL_INVALID_GL_OBJECT";
            case CLConstants.INVALID_BUFFER_SIZE: return "CL_INVALID_BUFFER_SIZE";
            case CLConstants.INVALID_MIP_LEVEL: return "CL_INVALID_MIP_LEVEL";
            case CLConstants.INVALID_GLOBAL_WORK_SIZE: return "CL_INVALID_GLOBAL_WORK_SIZE";
            case CLConstants.INVALID_PROPERTY: return "CL_INVALID_PROPERTY";
            case CLConstants.INVALID_IMAGE_DESCRIPTOR: return "CL_INVALID_IMAGE_DESCRIPTOR";
            case CLConstants.INVALID_COMPILER_OPTIONS: return "CL_INVALID_COMPILER_OPTIONS";
            case CLConstants.INVALID_LINKER_OPTIONS: return "CL_INVALID_LINKER_OPTIONS";
            case CLConstants.INVALID_DEVICE_PARTITION_COUNT: return "CL_INVALID_DEVICE_PARTITION_COUNT";
            case CLConstants.INVALID_PIPE_SIZE: return "CL_INVALID_PIPE_SIZE";
            case CLConstants.INVALID_DEVICE_QUEUE: return "CL_INVALID_DEVICE_QUEUE";
            case CLConstants.INVALID_GL_SHAREGROUP_REFERENCE_KHR: return "CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR";
            case CLConstants.PLATFORM_NOT_FOUND_KHR: return "CL_PLATFORM_NOT_FOUND_KHR";

            // Some OpenCL implementation return 1 for glBuildProgram
            // if the source code contains errors...
            case 1: return "Error in program source code";
        }
        return "INVALID error code: "+n;
    }

    /**
     * Returns the String identifying the given cl_platform_info
     *
     * @param n A cl_platform_info value
     * @return The String for the given cl_platform_info
     */
    public static String stringFor_cl_platform_info(int n)
    {
        switch (n)
        {
            case CLConstants.PLATFORM_PROFILE: return "CL_PLATFORM_PROFILE";
            case CLConstants.PLATFORM_VERSION: return "CL_PLATFORM_VERSION";
            case CLConstants.PLATFORM_NAME: return "CL_PLATFORM_NAME";
            case CLConstants.PLATFORM_VENDOR: return "CL_PLATFORM_VENDOR";
            case CLConstants.PLATFORM_EXTENSIONS: return "CL_PLATFORM_EXTENSIONS";
            case CLConstants.PLATFORM_ICD_SUFFIX_KHR: return "CL_PLATFORM_ICD_SUFFIX_KHR";
        }
        return "INVALID cl_platform_info: " + n;
    }

    /**
     * Returns the String identifying the given cl_device_info
     *
     * @param n A cl_device_info value
     * @return The String for the given cl_device_info
     */
    public static String stringFor_cl_device_info(int n)
    {
        switch (n)
        {
            case CLConstants.DEVICE_TYPE: return "CL_DEVICE_TYPE";
            case CLConstants.DEVICE_VENDOR_ID: return "CL_DEVICE_VENDOR_ID";
            case CLConstants.DEVICE_MAX_COMPUTE_UNITS: return "CL_DEVICE_MAX_COMPUTE_UNITS";
            case CLConstants.DEVICE_MAX_WORK_ITEM_DIMENSIONS: return "CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS";
            case CLConstants.DEVICE_MAX_WORK_GROUP_SIZE: return "CL_DEVICE_MAX_WORK_GROUP_SIZE";
            case CLConstants.DEVICE_MAX_WORK_ITEM_SIZES: return "CL_DEVICE_MAX_WORK_ITEM_SIZES";
            case CLConstants.DEVICE_PREFERRED_VECTOR_WIDTH_CHAR: return "CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR";
            case CLConstants.DEVICE_PREFERRED_VECTOR_WIDTH_SHORT: return "CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT";
            case CLConstants.DEVICE_PREFERRED_VECTOR_WIDTH_INT: return "CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT";
            case CLConstants.DEVICE_PREFERRED_VECTOR_WIDTH_LONG: return "CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG";
            case CLConstants.DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT: return "CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT";
            case CLConstants.DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE: return "CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE";
            case CLConstants.DEVICE_MAX_CLOCK_FREQUENCY: return "CL_DEVICE_MAX_CLOCK_FREQUENCY";
            case CLConstants.DEVICE_ADDRESS_BITS: return "CL_DEVICE_ADDRESS_BITS";
            case CLConstants.DEVICE_MAX_READ_IMAGE_ARGS: return "CL_DEVICE_MAX_READ_IMAGE_ARGS";
            case CLConstants.DEVICE_MAX_WRITE_IMAGE_ARGS: return "CL_DEVICE_MAX_WRITE_IMAGE_ARGS";
            case CLConstants.DEVICE_MAX_MEM_ALLOC_SIZE: return "CL_DEVICE_MAX_MEM_ALLOC_SIZE";
            case CLConstants.DEVICE_IMAGE2D_MAX_WIDTH: return "CL_DEVICE_IMAGE2D_MAX_WIDTH";
            case CLConstants.DEVICE_IMAGE2D_MAX_HEIGHT: return "CL_DEVICE_IMAGE2D_MAX_HEIGHT";
            case CLConstants.DEVICE_IMAGE3D_MAX_WIDTH: return "CL_DEVICE_IMAGE3D_MAX_WIDTH";
            case CLConstants.DEVICE_IMAGE3D_MAX_HEIGHT: return "CL_DEVICE_IMAGE3D_MAX_HEIGHT";
            case CLConstants.DEVICE_IMAGE3D_MAX_DEPTH: return "CL_DEVICE_IMAGE3D_MAX_DEPTH";
            case CLConstants.DEVICE_IMAGE_SUPPORT: return "CL_DEVICE_IMAGE_SUPPORT";
            case CLConstants.DEVICE_MAX_PARAMETER_SIZE: return "CL_DEVICE_MAX_PARAMETER_SIZE";
            case CLConstants.DEVICE_MAX_SAMPLERS: return "CL_DEVICE_MAX_SAMPLERS";
            case CLConstants.DEVICE_MEM_BASE_ADDR_ALIGN: return "CL_DEVICE_MEM_BASE_ADDR_ALIGN";
            case CLConstants.DEVICE_MIN_DATA_TYPE_ALIGN_SIZE: return "CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE";
            case CLConstants.DEVICE_SINGLE_FP_CONFIG: return "CL_DEVICE_SINGLE_FP_CONFIG";
            case CLConstants.DEVICE_DOUBLE_FP_CONFIG: return "CL_DEVICE_DOUBLE_FP_CONFIG";
            case CLConstants.DEVICE_HALF_FP_CONFIG: return "CL_DEVICE_HALF_FP_CONFIG";
            case CLConstants.DEVICE_GLOBAL_MEM_CACHE_TYPE: return "CL_DEVICE_GLOBAL_MEM_CACHE_TYPE";
            case CLConstants.DEVICE_GLOBAL_MEM_CACHELINE_SIZE: return "CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE";
            case CLConstants.DEVICE_GLOBAL_MEM_CACHE_SIZE: return "CL_DEVICE_GLOBAL_MEM_CACHE_SIZE";
            case CLConstants.DEVICE_GLOBAL_MEM_SIZE: return "CL_DEVICE_GLOBAL_MEM_SIZE";
            case CLConstants.DEVICE_MAX_CONSTANT_BUFFER_SIZE: return "CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE";
            case CLConstants.DEVICE_MAX_CONSTANT_ARGS: return "CL_DEVICE_MAX_CONSTANT_ARGS";
            case CLConstants.DEVICE_LOCAL_MEM_TYPE: return "CL_DEVICE_LOCAL_MEM_TYPE";
            case CLConstants.DEVICE_LOCAL_MEM_SIZE: return "CL_DEVICE_LOCAL_MEM_SIZE";
            case CLConstants.DEVICE_ERROR_CORRECTION_SUPPORT: return "CL_DEVICE_ERROR_CORRECTION_SUPPORT";
            case CLConstants.DEVICE_PROFILING_TIMER_RESOLUTION: return "CL_DEVICE_PROFILING_TIMER_RESOLUTION";
            case CLConstants.DEVICE_ENDIAN_LITTLE: return "CL_DEVICE_ENDIAN_LITTLE";
            case CLConstants.DEVICE_AVAILABLE: return "CL_DEVICE_AVAILABLE";
            case CLConstants.DEVICE_COMPILER_AVAILABLE: return "CL_DEVICE_COMPILER_AVAILABLE";
            case CLConstants.DEVICE_EXECUTION_CAPABILITIES: return "CL_DEVICE_EXECUTION_CAPABILITIES";
            //case CLConstants.DEVICE_QUEUE_PROPERTIES: return "CL_DEVICE_QUEUE_PROPERTIES";
            case CLConstants.DEVICE_NAME: return "CL_DEVICE_NAME";
            case CLConstants.DEVICE_VENDOR: return "CL_DEVICE_VENDOR";
            case CLConstants.DRIVER_VERSION: return "CL_DRIVER_VERSION";
            case CLConstants.DEVICE_PROFILE: return "CL_DEVICE_PROFILE";
            case CLConstants.DEVICE_VERSION: return "CL_DEVICE_VERSION";
            case CLConstants.DEVICE_EXTENSIONS: return "CL_DEVICE_EXTENSIONS";
            case CLConstants.DEVICE_PLATFORM: return "CL_DEVICE_PLATFORM";
            case CLConstants.DEVICE_PREFERRED_VECTOR_WIDTH_HALF: return "CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF";
            case CLConstants.DEVICE_HOST_UNIFIED_MEMORY: return "CL_DEVICE_HOST_UNIFIED_MEMORY";
            case CLConstants.DEVICE_NATIVE_VECTOR_WIDTH_CHAR: return "CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR";
            case CLConstants.DEVICE_NATIVE_VECTOR_WIDTH_SHORT: return "CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT";
            case CLConstants.DEVICE_NATIVE_VECTOR_WIDTH_INT: return "CL_DEVICE_NATIVE_VECTOR_WIDTH_INT";
            case CLConstants.DEVICE_NATIVE_VECTOR_WIDTH_LONG: return "CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG";
            case CLConstants.DEVICE_NATIVE_VECTOR_WIDTH_FLOAT: return "CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT";
            case CLConstants.DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE: return "CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE";
            case CLConstants.DEVICE_NATIVE_VECTOR_WIDTH_HALF: return "CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF";
            case CLConstants.DEVICE_OPENCL_C_VERSION: return "CL_DEVICE_OPENCL_C_VERSION";
            case CLConstants.DEVICE_LINKER_AVAILABLE: return "CL_DEVICE_LINKER_AVAILABLE";
            case CLConstants.DEVICE_BUILT_IN_KERNELS: return "CL_DEVICE_BUILT_IN_KERNELS";
            case CLConstants.DEVICE_IMAGE_MAX_BUFFER_SIZE: return "CL_DEVICE_IMAGE_MAX_BUFFER_SIZE";
            case CLConstants.DEVICE_IMAGE_MAX_ARRAY_SIZE: return "CL_DEVICE_IMAGE_MAX_ARRAY_SIZE";
            case CLConstants.DEVICE_PARENT_DEVICE: return "CL_DEVICE_PARENT_DEVICE";
            case CLConstants.DEVICE_PARTITION_MAX_SUB_DEVICES: return "CL_DEVICE_PARTITION_MAX_SUB_DEVICES";
            case CLConstants.DEVICE_PARTITION_PROPERTIES: return "CL_DEVICE_PARTITION_PROPERTIES";
            case CLConstants.DEVICE_PARTITION_AFFINITY_DOMAIN: return "CL_DEVICE_PARTITION_AFFINITY_DOMAIN";
            case CLConstants.DEVICE_PARTITION_TYPE: return "CL_DEVICE_PARTITION_TYPE";
            case CLConstants.DEVICE_REFERENCE_COUNT: return "CL_DEVICE_REFERENCE_COUNT";
            case CLConstants.DEVICE_PREFERRED_INTEROP_USER_SYNC: return "CL_DEVICE_PREFERRED_INTEROP_USER_SYNC";
            case CLConstants.DEVICE_PRINTF_BUFFER_SIZE: return "CL_DEVICE_PRINTF_BUFFER_SIZE";
            case CLConstants.DEVICE_QUEUE_ON_HOST_PROPERTIES: return "CL_DEVICE_QUEUE_ON_HOST_PROPERTIES";
            case CLConstants.DEVICE_IMAGE_PITCH_ALIGNMENT: return "CL_DEVICE_IMAGE_PITCH_ALIGNMENT";
            case CLConstants.DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT: return "CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT";
            case CLConstants.DEVICE_MAX_READ_WRITE_IMAGE_ARGS: return "CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS";
            case CLConstants.DEVICE_MAX_GLOBAL_VARIABLE_SIZE: return "CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE";
            case CLConstants.DEVICE_QUEUE_ON_DEVICE_PROPERTIES: return "CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES";
            case CLConstants.DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE: return "CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE";
            case CLConstants.DEVICE_QUEUE_ON_DEVICE_MAX_SIZE: return "CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE";
            case CLConstants.DEVICE_MAX_ON_DEVICE_QUEUES: return "CL_DEVICE_MAX_ON_DEVICE_QUEUES";
            case CLConstants.DEVICE_MAX_ON_DEVICE_EVENTS: return "CL_DEVICE_MAX_ON_DEVICE_EVENTS";
            case CLConstants.DEVICE_SVM_CAPABILITIES: return "CL_DEVICE_SVM_CAPABILITIES";
            case CLConstants.DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE: return "CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE";
            case CLConstants.DEVICE_MAX_PIPE_ARGS: return "CL_DEVICE_MAX_PIPE_ARGS";
            case CLConstants.DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS: return "CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS";
            case CLConstants.DEVICE_PIPE_MAX_PACKET_SIZE: return "CL_DEVICE_PIPE_MAX_PACKET_SIZE";
            case CLConstants.DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT: return "CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT";
            case CLConstants.DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT: return "CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT";
            case CLConstants.DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT: return "CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT";
        }
        return "INVALID cl_device_info: " + n;
    }

    /**
     * Returns the String identifying the given cl_device_mem_cache_type
     *
     * @param n A cl_device_mem_cache_type value
     * @return The String for the given cl_device_mem_cache_type
     */
    public static String stringFor_cl_device_mem_cache_type(int n)
    {
        switch (n)
        {
            case CLConstants.NONE: return "CL_NONE";
            case CLConstants.READ_ONLY_CACHE: return "CL_READ_ONLY_CACHE";
            case CLConstants.READ_WRITE_CACHE: return "CL_READ_WRITE_CACHE";
        }
        return "INVALID cl_device_mem_cache_type: " + n;
    }

    /**
     * Returns the String identifying the given cl_device_local_mem_type
     *
     * @param n A cl_device_local_mem_type value
     * @return The String for the given cl_device_local_mem_type
     */
    public static String stringFor_cl_device_local_mem_type(int n)
    {
        switch (n)
        {
            case CLConstants.LOCAL: return "CL_LOCAL";
            case CLConstants.GLOBAL: return "CL_GLOBAL";
        }
        return "INVALID cl_device_local_mem_type: " + n;
    }

    /**
     * Returns the String identifying the given cl_context_info
     *
     * @param n A cl_context_info value
     * @return The String for the given cl_context_info
     */
    public static String stringFor_cl_context_info(int n)
    {
        switch (n)
        {
            case CLConstants.CONTEXT_REFERENCE_COUNT: return "CL_CONTEXT_REFERENCE_COUNT";
            case CLConstants.CONTEXT_DEVICES: return "CL_CONTEXT_DEVICES";
            case CLConstants.CONTEXT_PROPERTIES: return "CL_CONTEXT_PROPERTIES";
            case CLConstants.CONTEXT_NUM_DEVICES: return "CL_CONTEXT_NUM_DEVICES";
        }
        return "INVALID cl_context_info: " + n;
    }

    /**
     * Returns the String identifying the given cl_context_properties
     *
     * @param n A cl_context_properties value
     * @return The String for the given cl_context_properties
     */
    public static String stringFor_cl_context_properties(int n)
    {
        switch (n)
        {
            case CLConstants.CONTEXT_PLATFORM: return "CL_CONTEXT_PLATFORM";
            case CLConstants.CONTEXT_INTEROP_USER_SYNC: return "CL_CONTEXT_INTEROP_USER_SYNC";
            case CLConstants.GL_CONTEXT_KHR: return "CL_GL_CONTEXT_KHR";
            case CLConstants.EGL_DISPLAY_KHR: return "CL_EGL_DISPLAY_KHR";
            case CLConstants.GLX_DISPLAY_KHR: return "CL_GLX_DISPLAY_KHR";
            case CLConstants.WGL_HDC_KHR: return "CL_WGL_HDC_KHR";
            case CLConstants.CGL_SHAREGROUP_KHR: return "CL_CGL_SHAREGROUP_KHR";
        }
        return "INVALID cl_context_properties: " + n;
    }


    /**
     * Returns the String identifying the given cl_device_partition_property
     *
     * @param n A cl_device_partition_property value
     * @return The String for the given cl_device_partition_property
     */
    public static String stringFor_cl_device_partition_property(int n)
    {
        switch (n)
        {
            case CLConstants.DEVICE_PARTITION_EQUALLY: return "CL_DEVICE_PARTITION_EQUALLY";
            case CLConstants.DEVICE_PARTITION_BY_COUNTS: return "CL_DEVICE_PARTITION_BY_COUNTS";
            case CLConstants.DEVICE_PARTITION_BY_COUNTS_LIST_END: return "CL_DEVICE_PARTITION_BY_COUNTS_LIST_END";
            case CLConstants.DEVICE_PARTITION_BY_AFFINITY_DOMAIN: return "CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN";
        }
        return "INVALID cl_device_partition_property: " + n;
    }

    /**
     * Returns the String identifying the given cl_command_queue_info
     *
     * @param n A cl_command_queue_info value
     * @return The String for the given cl_command_queue_info
     */
    public static String stringFor_cl_command_queue_info(int n)
    {
        switch (n)
        {
            case CLConstants.QUEUE_CONTEXT: return "CL_QUEUE_CONTEXT";
            case CLConstants.QUEUE_DEVICE: return "CL_QUEUE_DEVICE";
            case CLConstants.QUEUE_REFERENCE_COUNT: return "CL_QUEUE_REFERENCE_COUNT";
            case CLConstants.QUEUE_PROPERTIES: return "CL_QUEUE_PROPERTIES";
            case CLConstants.QUEUE_SIZE: return "CL_QUEUE_SIZE";
        }
        return "INVALID cl_command_queue_info: " + n;
    }

    /**
     * Returns the String identifying the given cl_channel_order
     *
     * @param n A cl_channel_order value
     * @return The String for the given cl_channel_order
     */
    public static String stringFor_cl_channel_order(int n)
    {
        switch (n)
        {
            case CLConstants.R: return "CL_R";
            case CLConstants.A: return "CL_A";
            case CLConstants.RG: return "CL_RG";
            case CLConstants.RA: return "CL_RA";
            case CLConstants.RGB: return "CL_RGB";
            case CLConstants.RGBA: return "CL_RGBA";
            case CLConstants.BGRA: return "CL_BGRA";
            case CLConstants.ARGB: return "CL_ARGB";
            case CLConstants.INTENSITY: return "CL_INTENSITY";
            case CLConstants.LUMINANCE: return "CL_LUMINANCE";
            case CLConstants.Rx: return "CL_Rx";
            case CLConstants.RGx: return "CL_RGx";
            case CLConstants.RGBx: return "CL_RGBx";
            case CLConstants.DEPTH: return "CL_DEPTH";
            case CLConstants.DEPTH_STENCIL: return "CL_DEPTH_STENCIL";
            case CLConstants.sRGB: return "CL_sRGB";
            case CLConstants.sRGBx: return "CL_sRGBx";
            case CLConstants.sRGBA: return "CL_sRGBA";
            case CLConstants.sBGRA: return "CL_sBGRA";
            case CLConstants.ABGR: return "CL_ABGR";
        }
        return "INVALID cl_channel_order: " + n;
    }

    /**
     * Returns the String identifying the given cl_channel_type
     *
     * @param n A cl_channel_type value
     * @return The String for the given cl_channel_type
     */
    public static String stringFor_cl_channel_type(int n)
    {
        switch (n)
        {
            case CLConstants.SNORM_INT8: return "CL_SNORM_INT8";
            case CLConstants.SNORM_INT16: return "CL_SNORM_INT16";
            case CLConstants.UNORM_INT8: return "CL_UNORM_INT8";
            case CLConstants.UNORM_INT16: return "CL_UNORM_INT16";
            case CLConstants.UNORM_SHORT_565: return "CL_UNORM_SHORT_565";
            case CLConstants.UNORM_SHORT_555: return "CL_UNORM_SHORT_555";
            case CLConstants.UNORM_INT_101010: return "CL_UNORM_INT_101010";
            case CLConstants.SIGNED_INT8: return "CL_SIGNED_INT8";
            case CLConstants.SIGNED_INT16: return "CL_SIGNED_INT16";
            case CLConstants.SIGNED_INT32: return "CL_SIGNED_INT32";
            case CLConstants.UNSIGNED_INT8: return "CL_UNSIGNED_INT8";
            case CLConstants.UNSIGNED_INT16: return "CL_UNSIGNED_INT16";
            case CLConstants.UNSIGNED_INT32: return "CL_UNSIGNED_INT32";
            case CLConstants.HALF_FLOAT: return "CL_HALF_FLOAT";
            case CLConstants.FLOAT: return "CL_FLOAT";
            case CLConstants.UNORM_INT24: return "CL_UNORM_INT24";
        }
        return "INVALID cl_channel_type: " + n;
    }

    /**
     * Returns the String identifying the given cl_mem_object_type
     *
     * @param n A cl_mem_object_type value
     * @return The String for the given cl_mem_object_type
     */
    public static String stringFor_cl_mem_object_type(int n)
    {
        switch (n)
        {
            case CLConstants.MEM_OBJECT_BUFFER: return "CL_MEM_OBJECT_BUFFER";
            case CLConstants.MEM_OBJECT_IMAGE2D: return "CL_MEM_OBJECT_IMAGE2D";
            case CLConstants.MEM_OBJECT_IMAGE3D: return "CL_MEM_OBJECT_IMAGE3D";
            case CLConstants.MEM_OBJECT_IMAGE2D_ARRAY: return "CL_MEM_OBJECT_IMAGE2D_ARRAY";
            case CLConstants.MEM_OBJECT_IMAGE1D: return "CL_MEM_OBJECT_IMAGE1D";
            case CLConstants.MEM_OBJECT_IMAGE1D_ARRAY: return "CL_MEM_OBJECT_IMAGE1D_ARRAY";
            case CLConstants.MEM_OBJECT_IMAGE1D_BUFFER: return "CL_MEM_OBJECT_IMAGE1D_BUFFER";
            case CLConstants.MEM_OBJECT_PIPE: return "CL_MEM_OBJECT_PIPE";
        }
        return "INVALID cl_mem_object_type: " + n;
    }

    /**
     * Returns the String identifying the given cl_mem_info
     *
     * @param n A cl_mem_info value
     * @return The String for the given cl_mem_info
     */
    public static String stringFor_cl_mem_info(int n)
    {
        switch (n)
        {
            case CLConstants.MEM_TYPE: return "CL_MEM_TYPE";
            case CLConstants.MEM_FLAGS: return "CL_MEM_FLAGS";
            case CLConstants.MEM_SIZE: return "CL_MEM_SIZE";
            case CLConstants.MEM_HOST_PTR: return "CL_MEM_HOST_PTR";
            case CLConstants.MEM_MAP_COUNT: return "CL_MEM_MAP_COUNT";
            case CLConstants.MEM_REFERENCE_COUNT: return "CL_MEM_REFERENCE_COUNT";
            case CLConstants.MEM_CONTEXT: return "CL_MEM_CONTEXT";
            case CLConstants.MEM_ASSOCIATED_MEMOBJECT: return "CL_MEM_ASSOCIATED_MEMOBJECT";
            case CLConstants.MEM_OFFSET: return "CL_MEM_OFFSET";
            case CLConstants.MEM_USES_SVM_POINTER: return "CL_MEM_USES_SVM_POINTER";
        }
        return "INVALID cl_mem_info: " + n;
    }

    /**
     * Returns the String identifying the given cl_image_info
     *
     * @param n A cl_image_info value
     * @return The String for the given cl_image_info
     */
    public static String stringFor_cl_image_info(int n)
    {
        switch (n)
        {
            case CLConstants.IMAGE_FORMAT: return "CL_IMAGE_FORMAT";
            case CLConstants.IMAGE_ELEMENT_SIZE: return "CL_IMAGE_ELEMENT_SIZE";
            case CLConstants.IMAGE_ROW_PITCH: return "CL_IMAGE_ROW_PITCH";
            case CLConstants.IMAGE_SLICE_PITCH: return "CL_IMAGE_SLICE_PITCH";
            case CLConstants.IMAGE_WIDTH: return "CL_IMAGE_WIDTH";
            case CLConstants.IMAGE_HEIGHT: return "CL_IMAGE_HEIGHT";
            case CLConstants.IMAGE_DEPTH: return "CL_IMAGE_DEPTH";
            case CLConstants.IMAGE_ARRAY_SIZE: return "CL_IMAGE_ARRAY_SIZE";
            case CLConstants.IMAGE_BUFFER: return "CL_IMAGE_BUFFER";
            case CLConstants.IMAGE_NUM_MIP_LEVELS: return "CL_IMAGE_NUM_MIP_LEVELS";
            case CLConstants.IMAGE_NUM_SAMPLES: return "CL_IMAGE_NUM_SAMPLES";
        }
        return "INVALID cl_image_info: " + n;
    }


    /**
     * Returns the String identifying the given cl_pipe_info
     *
     * @param n A cl_pipe_info value
     * @return The String for the given cl_pipe_info
     */
    public static String stringFor_cl_pipe_info(int n)
    {
        switch (n)
        {
            case CLConstants.PIPE_PACKET_SIZE: return "CL_PIPE_PACKET_SIZE";
            case CLConstants.PIPE_MAX_PACKETS: return "CL_PIPE_MAX_PACKETS";
        }
        return "INVALID cl_pipe_info: " + n;
    }

    /**
     * Returns the String identifying the given cl_addressing_mode
     *
     * @param n A cl_addressing_mode value
     * @return The String for the given cl_addressing_mode
     */
    public static String stringFor_cl_addressing_mode(int n)
    {
        switch (n)
        {
            case CLConstants.ADDRESS_NONE: return "CL_ADDRESS_NONE";
            case CLConstants.ADDRESS_CLAMP_TO_EDGE: return "CL_ADDRESS_CLAMP_TO_EDGE";
            case CLConstants.ADDRESS_CLAMP: return "CL_ADDRESS_CLAMP";
            case CLConstants.ADDRESS_REPEAT: return "CL_ADDRESS_REPEAT";
            case CLConstants.ADDRESS_MIRRORED_REPEAT: return "CL_ADDRESS_MIRRORED_REPEAT";
        }
        return "INVALID cl_addressing_mode: " + n;
    }

    /**
     * Returns the String identifying the given cl_filter_mode
     *
     * @param n A cl_filter_mode value
     * @return The String for the given cl_filter_mode
     */
    public static String stringFor_cl_filter_mode(int n)
    {
        switch (n)
        {
            case CLConstants.FILTER_NEAREST: return "CL_FILTER_NEAREST";
            case CLConstants.FILTER_LINEAR: return "CL_FILTER_LINEAR";
        }
        return "INVALID cl_filter_mode: " + n;
    }

    /**
     * Returns the String identifying the given cl_sampler_info
     *
     * @param n A cl_sampler_info value
     * @return The String for the given cl_sampler_info
     */
    public static String stringFor_cl_sampler_info(int n)
    {
        switch (n)
        {
            case CLConstants.SAMPLER_REFERENCE_COUNT: return "CL_SAMPLER_REFERENCE_COUNT";
            case CLConstants.SAMPLER_CONTEXT: return "CL_SAMPLER_CONTEXT";
            case CLConstants.SAMPLER_NORMALIZED_COORDS: return "CL_SAMPLER_NORMALIZED_COORDS";
            case CLConstants.SAMPLER_ADDRESSING_MODE: return "CL_SAMPLER_ADDRESSING_MODE";
            case CLConstants.SAMPLER_FILTER_MODE: return "CL_SAMPLER_FILTER_MODE";
            case CLConstants.SAMPLER_MIP_FILTER_MODE: return "CL_SAMPLER_MIP_FILTER_MODE";
            case CLConstants.SAMPLER_LOD_MIN: return "CL_SAMPLER_LOD_MIN";
            case CLConstants.SAMPLER_LOD_MAX: return "CL_SAMPLER_LOD_MAX";
        }
        return "INVALID cl_sampler_info: " + n;
    }

    /**
     * Returns the String identifying the given cl_program_info
     *
     * @param n A cl_program_info value
     * @return The String for the given cl_program_info
     */
    public static String stringFor_cl_program_info(int n)
    {
        switch (n)
        {
            case CLConstants.PROGRAM_REFERENCE_COUNT: return "CL_PROGRAM_REFERENCE_COUNT";
            case CLConstants.PROGRAM_CONTEXT: return "CL_PROGRAM_CONTEXT";
            case CLConstants.PROGRAM_NUM_DEVICES: return "CL_PROGRAM_NUM_DEVICES";
            case CLConstants.PROGRAM_DEVICES: return "CL_PROGRAM_DEVICES";
            case CLConstants.PROGRAM_SOURCE: return "CL_PROGRAM_SOURCE";
            case CLConstants.PROGRAM_BINARY_SIZES: return "CL_PROGRAM_BINARY_SIZES";
            case CLConstants.PROGRAM_BINARIES: return "CL_PROGRAM_BINARIES";
            case CLConstants.PROGRAM_NUM_KERNELS: return "CL_PROGRAM_NUM_KERNELS";
            case CLConstants.PROGRAM_KERNEL_NAMES: return "CL_PROGRAM_KERNEL_NAMES";
        }
        return "INVALID cl_program_info: " + n;
    }

    /**
     * Returns the String identifying the given cl_program_build_info
     *
     * @param n A cl_program_build_info value
     * @return The String for the given cl_program_build_info
     */
    public static String stringFor_cl_program_build_info(int n)
    {
        switch (n)
        {
            case CLConstants.PROGRAM_BUILD_STATUS: return "CL_PROGRAM_BUILD_STATUS";
            case CLConstants.PROGRAM_BUILD_OPTIONS: return "CL_PROGRAM_BUILD_OPTIONS";
            case CLConstants.PROGRAM_BUILD_LOG: return "CL_PROGRAM_BUILD_LOG";
            case CLConstants.PROGRAM_BINARY_TYPE: return "CL_PROGRAM_BINARY_TYPE";
            case CLConstants.PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE: return "CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE";
        }
        return "INVALID cl_program_build_info: " + n;
    }

    /**
     * Returns the String identifying the given cl_program_binary_type
     *
     * @param n A cl_program_binary_type value
     * @return The String for the given cl_program_binary_type
     */
    public static String stringFor_cl_program_binary_type(int n)
    {
        switch (n)
        {
            case CLConstants.PROGRAM_BINARY_TYPE_NONE: return "CL_PROGRAM_BINARY_TYPE_NONE";
            case CLConstants.PROGRAM_BINARY_TYPE_COMPILED_OBJECT: return "CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT";
            case CLConstants.PROGRAM_BINARY_TYPE_LIBRARY: return "CL_PROGRAM_BINARY_TYPE_LIBRARY";
            case CLConstants.PROGRAM_BINARY_TYPE_EXECUTABLE: return "CL_PROGRAM_BINARY_TYPE_EXECUTABLE";
        }
        return "INVALID cl_program_binary_type: " + n;
    }


    /**
     * Returns the String identifying the given cl_build_status
     *
     * @param n A cl_build_status value
     * @return The String for the given cl_build_status
     */
    public static String stringFor_cl_build_status(int n)
    {
        switch (n)
        {
            case CLConstants.BUILD_SUCCESS: return "CL_BUILD_SUCCESS";
            case CLConstants.BUILD_NONE: return "CL_BUILD_NONE";
            case CLConstants.BUILD_ERROR: return "CL_BUILD_ERROR";
            case CLConstants.BUILD_IN_PROGRESS: return "CL_BUILD_IN_PROGRESS";
        }
        return "INVALID cl_build_status: " + n;
    }

    /**
     * Returns the String identifying the given cl_kernel_info
     *
     * @param n A cl_kernel_info value
     * @return The String for the given cl_kernel_info
     */
    public static String stringFor_cl_kernel_info(int n)
    {
        switch (n)
        {
            case CLConstants.KERNEL_FUNCTION_NAME: return "CL_KERNEL_FUNCTION_NAME";
            case CLConstants.KERNEL_NUM_ARGS: return "CL_KERNEL_NUM_ARGS";
            case CLConstants.KERNEL_REFERENCE_COUNT: return "CL_KERNEL_REFERENCE_COUNT";
            case CLConstants.KERNEL_CONTEXT: return "CL_KERNEL_CONTEXT";
            case CLConstants.KERNEL_PROGRAM: return "CL_KERNEL_PROGRAM";
            case CLConstants.KERNEL_ATTRIBUTES: return "CL_KERNEL_ATTRIBUTES";
        }
        return "INVALID cl_kernel_info: " + n;
    }


    /**
     * Returns the String identifying the given cl_kernel_arg_info
     *
     * @param n A cl_kernel_arg_info value
     * @return The String for the given cl_kernel_arg_info
     */
    public static String stringFor_cl_kernel_arg_info(int n)
    {
        switch (n)
        {
            case CLConstants.KERNEL_ARG_ADDRESS_QUALIFIER: return "CL_KERNEL_ARG_ADDRESS_QUALIFIER";
            case CLConstants.KERNEL_ARG_ACCESS_QUALIFIER: return "CL_KERNEL_ARG_ACCESS_QUALIFIER";
            case CLConstants.KERNEL_ARG_TYPE_NAME: return "CL_KERNEL_ARG_TYPE_NAME";
            case CLConstants.KERNEL_ARG_TYPE_QUALIFIER: return "CL_KERNEL_ARG_TYPE_QUALIFIER";
            case CLConstants.KERNEL_ARG_NAME: return "CL_KERNEL_ARG_NAME";
        }
        return "INVALID cl_kernel_arg_info: " + n;
    }

    /**
     * Returns the String identifying the given cl_kernel_arg_address_qualifier
     *
     * @param n A cl_kernel_arg_address_qualifier value
     * @return The String for the given cl_kernel_arg_address_qualifier
     */
    public static String stringFor_cl_kernel_arg_address_qualifier(int n)
    {
        switch (n)
        {
            case CLConstants.KERNEL_ARG_ADDRESS_GLOBAL: return "CL_KERNEL_ARG_ADDRESS_GLOBAL";
            case CLConstants.KERNEL_ARG_ADDRESS_LOCAL: return "CL_KERNEL_ARG_ADDRESS_LOCAL";
            case CLConstants.KERNEL_ARG_ADDRESS_CONSTANT: return "CL_KERNEL_ARG_ADDRESS_CONSTANT";
            case CLConstants.KERNEL_ARG_ADDRESS_PRIVATE: return "CL_KERNEL_ARG_ADDRESS_PRIVATE";
        }
        return "INVALID cl_kernel_arg_address_qualifier: " + n;
    }


    /**
     * Returns the String identifying the given cl_kernel_arg_access_qualifier
     *
     * @param n A cl_kernel_arg_access_qualifier value
     * @return The String for the given cl_kernel_arg_access_qualifier
     */
    public static String stringFor_cl_kernel_arg_access_qualifier(int n)
    {
        switch (n)
        {
            case CLConstants.KERNEL_ARG_ACCESS_READ_ONLY: return "CL_KERNEL_ARG_ACCESS_READ_ONLY";
            case CLConstants.KERNEL_ARG_ACCESS_WRITE_ONLY: return "CL_KERNEL_ARG_ACCESS_WRITE_ONLY";
            case CLConstants.KERNEL_ARG_ACCESS_READ_WRITE: return "CL_KERNEL_ARG_ACCESS_READ_WRITE";
            case CLConstants.KERNEL_ARG_ACCESS_NONE: return "CL_KERNEL_ARG_ACCESS_NONE";
        }
        return "INVALID cl_kernel_arg_access_qualifier: " + n;
    }


    /**
     * Returns the String identifying the given cl_kernel_work_group_info
     *
     * @param n A cl_kernel_work_group_info value
     * @return The String for the given cl_kernel_work_group_info
     */
    public static String stringFor_cl_kernel_work_group_info(int n)
    {
        switch (n)
        {
            case CLConstants.KERNEL_WORK_GROUP_SIZE: return "CL_KERNEL_WORK_GROUP_SIZE";
            case CLConstants.KERNEL_COMPILE_WORK_GROUP_SIZE: return "CL_KERNEL_COMPILE_WORK_GROUP_SIZE";
            case CLConstants.KERNEL_LOCAL_MEM_SIZE: return "CL_KERNEL_LOCAL_MEM_SIZE";
            case CLConstants.KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE: return "CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE";
            case CLConstants.KERNEL_PRIVATE_MEM_SIZE: return "CL_KERNEL_PRIVATE_MEM_SIZE";
            case CLConstants.KERNEL_GLOBAL_WORK_SIZE: return "CL_KERNEL_GLOBAL_WORK_SIZE";
        }
        return "INVALID cl_kernel_work_group_info: " + n;
    }

    /**
     * Returns the String identifying the given cl_kernel_exec_info
     *
     * @param n A cl_kernel_exec_info value
     * @return The String for the given cl_kernel_exec_info
     */
    public static String stringFor_cl_kernel_exec_info(int n)
    {
        switch (n)
        {
            case CLConstants.KERNEL_EXEC_INFO_SVM_PTRS: return "CL_KERNEL_EXEC_INFO_SVM_PTRS";
            case CLConstants.KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM: return "CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM";
        }
        return "INVALID cl_kernel_exec_info: " + n;
    }


    /**
     * Returns the String identifying the given cl_event_info
     *
     * @param n A cl_event_info value
     * @return The String for the given cl_event_info
     */
    public static String stringFor_cl_event_info(int n)
    {
        switch (n)
        {
            case CLConstants.EVENT_COMMAND_QUEUE: return "CL_EVENT_COMMAND_QUEUE";
            case CLConstants.EVENT_COMMAND_TYPE: return "CL_EVENT_COMMAND_TYPE";
            case CLConstants.EVENT_REFERENCE_COUNT: return "CL_EVENT_REFERENCE_COUNT";
            case CLConstants.EVENT_COMMAND_EXECUTION_STATUS: return "CL_EVENT_COMMAND_EXECUTION_STATUS";
            case CLConstants.EVENT_CONTEXT: return "CL_EVENT_CONTEXT";
        }
        return "INVALID cl_event_info: " + n;
    }

    /**
     * Returns the String identifying the given cl_command_type
     *
     * @param n A cl_command_type value
     * @return The String for the given cl_command_type
     */
    public static String stringFor_cl_command_type(int n)
    {
        switch (n)
        {
            case CLConstants.COMMAND_NDRANGE_KERNEL: return "CL_COMMAND_NDRANGE_KERNEL";
            case CLConstants.COMMAND_TASK: return "CL_COMMAND_TASK";
            case CLConstants.COMMAND_NATIVE_KERNEL: return "CL_COMMAND_NATIVE_KERNEL";
            case CLConstants.COMMAND_READ_BUFFER: return "CL_COMMAND_READ_BUFFER";
            case CLConstants.COMMAND_WRITE_BUFFER: return "CL_COMMAND_WRITE_BUFFER";
            case CLConstants.COMMAND_COPY_BUFFER: return "CL_COMMAND_COPY_BUFFER";
            case CLConstants.COMMAND_READ_IMAGE: return "CL_COMMAND_READ_IMAGE";
            case CLConstants.COMMAND_WRITE_IMAGE: return "CL_COMMAND_WRITE_IMAGE";
            case CLConstants.COMMAND_COPY_IMAGE: return "CL_COMMAND_COPY_IMAGE";
            case CLConstants.COMMAND_COPY_IMAGE_TO_BUFFER: return "CL_COMMAND_COPY_IMAGE_TO_BUFFER";
            case CLConstants.COMMAND_COPY_BUFFER_TO_IMAGE: return "CL_COMMAND_COPY_BUFFER_TO_IMAGE";
            case CLConstants.COMMAND_MAP_BUFFER: return "CL_COMMAND_MAP_BUFFER";
            case CLConstants.COMMAND_MAP_IMAGE: return "CL_COMMAND_MAP_IMAGE";
            case CLConstants.COMMAND_UNMAP_MEM_OBJECT: return "CL_COMMAND_UNMAP_MEM_OBJECT";
            case CLConstants.COMMAND_MARKER: return "CL_COMMAND_MARKER";
            case CLConstants.COMMAND_ACQUIRE_GL_OBJECTS: return "CL_COMMAND_ACQUIRE_GL_OBJECTS";
            case CLConstants.COMMAND_RELEASE_GL_OBJECTS: return "CL_COMMAND_RELEASE_GL_OBJECTS";
            case CLConstants.COMMAND_READ_BUFFER_RECT: return "CL_COMMAND_READ_BUFFER_RECT";
            case CLConstants.COMMAND_WRITE_BUFFER_RECT: return "CL_COMMAND_WRITE_BUFFER_RECT";
            case CLConstants.COMMAND_COPY_BUFFER_RECT: return "CL_COMMAND_COPY_BUFFER_RECT";
            case CLConstants.COMMAND_USER: return "CL_COMMAND_USER";
            case CLConstants.COMMAND_BARRIER: return "CL_COMMAND_BARRIER";
            case CLConstants.COMMAND_MIGRATE_MEM_OBJECTS: return "CL_COMMAND_MIGRATE_MEM_OBJECTS";
            case CLConstants.COMMAND_FILL_BUFFER: return "CL_COMMAND_FILL_BUFFER";
            case CLConstants.COMMAND_FILL_IMAGE: return "CL_COMMAND_FILL_IMAGE";
            case CLConstants.COMMAND_SVM_FREE: return "CL_COMMAND_SVM_FREE";
            case CLConstants.COMMAND_SVM_MEMCPY: return "CL_COMMAND_SVM_MEMCPY";
            case CLConstants.COMMAND_SVM_MEMFILL: return "CL_COMMAND_SVM_MEMFILL";
            case CLConstants.COMMAND_SVM_MAP: return "CL_COMMAND_SVM_MAP";
            case CLConstants.COMMAND_SVM_UNMAP: return "CL_COMMAND_SVM_UNMAP";
        }
        return "INVALID cl_command_type: " + n;
    }

    /**
     * Returns the command execution String identifying the given command_execution_status
     *
     * @param n A command_execution_status value
     * @return The String for the given command_execution_status
     */
    public static String stringFor_command_execution_status(int n)
    {
        switch (n)
        {
            case CLConstants.COMPLETE: return "CL_COMPLETE";
            case CLConstants.RUNNING: return "CL_RUNNING";
            case CLConstants.SUBMITTED: return "CL_SUBMITTED";
            case CLConstants.QUEUED: return "CL_QUEUED";
        }
        return "INVALID command_execution_status: " + n;

    }

    /**
     * Returns the String identifying the given cl_profiling_info
     *
     * @param n A cl_profiling_info value
     * @return The String for the given cl_profiling_info
     */
    public static String stringFor_cl_profiling_info(int n)
    {
        switch (n)
        {
            case CLConstants.PROFILING_COMMAND_QUEUED: return "CL_PROFILING_COMMAND_QUEUED";
            case CLConstants.PROFILING_COMMAND_SUBMIT: return "CL_PROFILING_COMMAND_SUBMIT";
            case CLConstants.PROFILING_COMMAND_START: return "CL_PROFILING_COMMAND_START";
            case CLConstants.PROFILING_COMMAND_END: return "CL_PROFILING_COMMAND_END";
            case CLConstants.PROFILING_COMMAND_COMPLETE: return "CL_PROFILING_COMMAND_COMPLETE";
        }
        return "INVALID cl_profiling_info: " + n;
    }


    /**
     * Returns the String identifying the given cl_gl_object_type
     *
     * @param n A cl_gl_object_type value
     * @return The String for the given cl_gl_object_type
     */
    public static String stringFor_cl_gl_object_type(int n)
    {
        switch (n)
        {
            case CLConstants.GL_OBJECT_BUFFER: return "CL_GL_OBJECT_BUFFER";
            case CLConstants.GL_OBJECT_TEXTURE2D: return "CL_GL_OBJECT_TEXTURE2D";
            case CLConstants.GL_OBJECT_TEXTURE3D: return "CL_GL_OBJECT_TEXTURE3D";
            case CLConstants.GL_OBJECT_RENDERBUFFER: return "CL_GL_OBJECT_RENDERBUFFER";
            case CLConstants.GL_OBJECT_TEXTURE2D_ARRAY: return "CL_GL_OBJECT_TEXTURE2D_ARRAY";
            case CLConstants.GL_OBJECT_TEXTURE1D: return "CL_GL_OBJECT_TEXTURE1D";
            case CLConstants.GL_OBJECT_TEXTURE1D_ARRAY: return "CL_GL_OBJECT_TEXTURE1D_ARRAY";
            case CLConstants.GL_OBJECT_TEXTURE_BUFFER: return "CL_GL_OBJECT_TEXTURE_BUFFER";
        }
        return "INVALID cl_gl_object_type: " + n;
    }

    /**
     * Returns the String identifying the given cl_gl_texture_info
     *
     * @param n A cl_gl_texture_info value
     * @return The String for the given cl_gl_texture_info
     */
    public static String stringFor_cl_gl_texture_info(int n)
    {
        switch (n)
        {
            case CLConstants.GL_TEXTURE_TARGET: return "CL_GL_TEXTURE_TARGET";
            case CLConstants.GL_MIPMAP_LEVEL: return "CL_GL_MIPMAP_LEVEL";
        }
        return "INVALID cl_gl_texture_info: " + n;
    }

    /**
     * Returns the String identifying the given cl_khr_gl_sharing
     *
     * @param n A cl_khr_gl_sharing value
     * @return The String for the given cl_khr_gl_sharing
     */
    public static String stringFor_cl_khr_gl_sharing(int n)
    {
        switch (n)
        {
            case CLConstants.CURRENT_DEVICE_FOR_GL_CONTEXT_KHR: return "CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR";
            case CLConstants.DEVICES_FOR_GL_CONTEXT_KHR: return "CL_DEVICES_FOR_GL_CONTEXT_KHR";
            case CLConstants.GL_CONTEXT_KHR: return "CL_GL_CONTEXT_KHR";
            case CLConstants.EGL_DISPLAY_KHR: return "CL_EGL_DISPLAY_KHR";
            case CLConstants.GLX_DISPLAY_KHR: return "CL_GLX_DISPLAY_KHR";
            case CLConstants.WGL_HDC_KHR: return "CL_WGL_HDC_KHR";
            case CLConstants.CGL_SHAREGROUP_KHR: return "CL_CGL_SHAREGROUP_KHR";
        }
        return "INVALID cl_khr_gl_sharing: " + n;
    }

   


    //=== String methods for constants of bitfields ==========================

    /**
     * Returns the string describing the given cl_device_type - bitfield
     *
     * @param n The cl_device_type - bitfield
     * @return The string describing the cl_device_type - bitfield
     */
    public static String stringFor_cl_device_type(long n)
    {
        if (n == 0)
        {
            return "(none)";
        }
        if (n == CLConstants.DEVICE_TYPE_ALL)
        {
            return "CL_DEVICE_TYPE_ALL";
        }
        String result = "";
        if ((n & CLConstants.DEVICE_TYPE_DEFAULT) != 0) result += "CL_DEVICE_TYPE_DEFAULT ";
        if ((n & CLConstants.DEVICE_TYPE_CPU) != 0) result += "CL_DEVICE_TYPE_CPU ";
        if ((n & CLConstants.DEVICE_TYPE_GPU) != 0) result += "CL_DEVICE_TYPE_GPU ";
        if ((n & CLConstants.DEVICE_TYPE_ACCELERATOR) != 0) result += "CL_DEVICE_TYPE_ACCELERATOR ";
        if ((n & CLConstants.DEVICE_TYPE_CUSTOM) != 0) result += "CL_DEVICE_TYPE_CUSTOM ";
        return result;
    }


    /**
     * Returns the string describing the given cl_device_fp_config - bitfield
     *
     * @param n The cl_device_fp_config - bitfield
     * @return The string describing the cl_device_fp_config - bitfield
     */
    public static String stringFor_cl_device_fp_config(long n)
    {
        if (n == 0)
        {
            return "(none)";
        }
        String result = "";
        if ((n & CLConstants.FP_DENORM) != 0) result += "CL_FP_DENORM ";
        if ((n & CLConstants.FP_INF_NAN) != 0) result += "CL_FP_INF_NAN ";
        if ((n & CLConstants.FP_ROUND_TO_NEAREST) != 0) result += "CL_FP_ROUND_TO_NEAREST ";
        if ((n & CLConstants.FP_ROUND_TO_ZERO) != 0) result += "CL_FP_ROUND_TO_ZERO ";
        if ((n & CLConstants.FP_ROUND_TO_INF) != 0) result += "CL_FP_ROUND_TO_INF ";
        if ((n & CLConstants.FP_FMA) != 0) result += "CL_FP_FMA ";
        if ((n & CLConstants.FP_SOFT_FLOAT) != 0) result += "CL_FP_SOFT_FLOAT ";
        if ((n & CLConstants.FP_CORRECTLY_ROUNDED_DIVIDE_SQRT) != 0) result += "CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT ";
        return result;
    }


    /**
     * Returns the string describing the given cl_device_exec_capabilities - bitfield
     *
     * @param n The cl_device_exec_capabilities - bitfield
     * @return The string describing the cl_device_exec_capabilities - bitfield
     */
    public static String stringFor_cl_device_exec_capabilities(long n)
    {
        if (n == 0)
        {
            return "(none)";
        }
        String result = "";
        if ((n & CLConstants.EXEC_KERNEL) != 0) result += "CL_EXEC_KERNEL ";
        if ((n & CLConstants.EXEC_NATIVE_KERNEL) != 0) result += "CL_EXEC_NATIVE_KERNEL ";
        return result;
    }


    /**
     * Returns the string describing the given cl_command_queue_properties - bitfield
     *
     * @param n The cl_command_queue_properties - bitfield
     * @return The string describing the cl_command_queue_properties - bitfield
     */
    public static String stringFor_cl_command_queue_properties(long n)
    {
        if (n == 0)
        {
            return "(none)";
        }
        String result = "";
        if ((n & CLConstants.QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) != 0) result += "CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE ";
        if ((n & CLConstants.QUEUE_PROFILING_ENABLE) != 0) result += "CL_QUEUE_PROFILING_ENABLE ";
        if ((n & CLConstants.QUEUE_ON_DEVICE) != 0) result += "CL_QUEUE_ON_DEVICE ";
        if ((n & CLConstants.QUEUE_ON_DEVICE_DEFAULT) != 0) result += "CL_QUEUE_ON_DEVICE_DEFAULT ";
        return result;
    }


    /**
     * Returns the string describing the given cl_device_affinity_domain - bitfield
     *
     * @param n The cl_device_affinity_domain - bitfield
     * @return The string describing the cl_device_affinity_domain - bitfield
     */
    public static String stringFor_cl_device_affinity_domain(long n)
    {
        if (n == 0)
        {
            return "(none)";
        }
        String result = "";
        if ((n & CLConstants.DEVICE_AFFINITY_DOMAIN_NUMA) != 0) result += "CL_DEVICE_AFFINITY_DOMAIN_NUMA ";
        if ((n & CLConstants.DEVICE_AFFINITY_DOMAIN_L4_CACHE) != 0) result += "CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE ";
        if ((n & CLConstants.DEVICE_AFFINITY_DOMAIN_L3_CACHE) != 0) result += "CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE ";
        if ((n & CLConstants.DEVICE_AFFINITY_DOMAIN_L2_CACHE) != 0) result += "CL_DEVICE_AFFINITY_DOMAIN_L2_CACHE ";
        if ((n & CLConstants.DEVICE_AFFINITY_DOMAIN_L1_CACHE) != 0) result += "CL_DEVICE_AFFINITY_DOMAIN_L1_CACHE ";
        if ((n & CLConstants.DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE) != 0) result += "CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE ";
        return result;
    }

    /**
     * Returns the string describing the given cl_device_svm_capabilities - bitfield
     *
     * @param n The cl_device_svm_capabilities - bitfield
     * @return The string describing the cl_device_svm_capabilities - bitfield
     */
    public static String stringFor_cl_device_svm_capabilities(long n)
    {
        if (n == 0)
        {
            return "(none)";
        }
        String result = "";
        if ((n & CLConstants.DEVICE_SVM_COARSE_GRAIN_BUFFER) != 0) result += "CL_DEVICE_SVM_COARSE_GRAIN_BUFFER ";
        if ((n & CLConstants.DEVICE_SVM_FINE_GRAIN_BUFFER) != 0) result += "CL_DEVICE_SVM_FINE_GRAIN_BUFFER ";
        if ((n & CLConstants.DEVICE_SVM_FINE_GRAIN_SYSTEM) != 0) result += "CL_DEVICE_SVM_FINE_GRAIN_SYSTEM ";
        if ((n & CLConstants.DEVICE_SVM_ATOMICS) != 0) result += "CL_DEVICE_SVM_ATOMICS ";
        return result;
    }

    /**
     * Returns the string describing the given cl_mem_flags - bitfield
     *
     * @param n The cl_mem_flags - bitfield
     * @return The string describing the cl_mem_flags - bitfield
     */
    public static String stringFor_cl_mem_flags(long n)
    {
        if (n == 0)
        {
            return "(none)";
        }
        String result = "";
        if ((n & CLConstants.MEM_READ_WRITE) != 0) result += "CL_MEM_READ_WRITE ";
        if ((n & CLConstants.MEM_WRITE_ONLY) != 0) result += "CL_MEM_WRITE_ONLY ";
        if ((n & CLConstants.MEM_READ_ONLY) != 0) result += "CL_MEM_READ_ONLY ";
        if ((n & CLConstants.MEM_USE_HOST_PTR) != 0) result += "CL_MEM_USE_HOST_PTR ";
        if ((n & CLConstants.MEM_ALLOC_HOST_PTR) != 0) result += "CL_MEM_ALLOC_HOST_PTR ";
        if ((n & CLConstants.MEM_COPY_HOST_PTR) != 0) result += "CL_MEM_COPY_HOST_PTR ";
        if ((n & CLConstants.MEM_HOST_WRITE_ONLY) != 0) result += "CL_MEM_HOST_WRITE_ONLY ";
        if ((n & CLConstants.MEM_HOST_READ_ONLY) != 0) result += "CL_MEM_HOST_READ_ONLY ";
        if ((n & CLConstants.MEM_HOST_NO_ACCESS) != 0) result += "CL_MEM_HOST_NO_ACCESS ";
        if ((n & CLConstants.MEM_SVM_FINE_GRAIN_BUFFER) != 0) result += "CL_MEM_SVM_FINE_GRAIN_BUFFER ";
        if ((n & CLConstants.MEM_SVM_ATOMICS) != 0) result += "CL_MEM_SVM_ATOMICS ";
        return result;
    }

    /**
     * Returns the string describing the given cl_mem_migration_flags - bitfield
     *
     * @param n The cl_mem_migration_flags - bitfield
     * @return The string describing the cl_mem_migration_flags - bitfield
     */
    public static String stringFor_cl_mem_migration_flags(long n)
    {
        if (n == 0)
        {
            return "(none)";
        }
        String result = "";
        if ((n & CLConstants.MIGRATE_MEM_OBJECT_HOST) != 0) result += "CL_MIGRATE_MEM_OBJECT_HOST ";
        if ((n & CLConstants.MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED) != 0) result += "CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED ";
        return result;
    }

    /**
     * Returns the string describing the given cl_map_flags - bitfield
     *
     * @param n The cl_map_flags - bitfield
     * @return The string describing the cl_map_flags - bitfield
     */
    public static String stringFor_cl_map_flags(long n)
    {
        if (n == 0)
        {
            return "(none)";
        }
        String result = "";
        if ((n & CLConstants.MAP_READ) != 0) result += "CL_MAP_READ ";
        if ((n & CLConstants.MAP_WRITE) != 0) result += "CL_MAP_WRITE ";
        if ((n & CLConstants.MAP_WRITE_INVALIDATE_REGION) != 0) result += "CL_MAP_WRITE_INVALIDATE_REGION ";
        return result;
    }

    /**
     * Returns the string describing the given cl_kernel_arg_type_qualifer - bitfield
     *
     * @param n The cl_kernel_arg_type_qualifer - bitfield
     * @return The string describing the cl_kernel_arg_type_qualifer - bitfield
     */
    public static String stringFor_cl_kernel_arg_type_qualifer(long n)
    {
        if (n == 0)
        {
            return "CL_KERNEL_ARG_TYPE_NONE";
        }
        String result = "";
        if ((n & CLConstants.KERNEL_ARG_TYPE_CONST) != 0) result += "CL_KERNEL_ARG_TYPE_CONST ";
        if ((n & CLConstants.KERNEL_ARG_TYPE_RESTRICT) != 0) result += "CL_KERNEL_ARG_TYPE_RESTRICT ";
        if ((n & CLConstants.KERNEL_ARG_TYPE_VOLATILE) != 0) result += "CL_KERNEL_ARG_TYPE_VOLATILE ";
        if ((n & CLConstants.KERNEL_ARG_TYPE_PIPE) != 0) result += "CL_KERNEL_ARG_TYPE_PIPE ";
        return result;
    }
}
