OpenCL错误码转字符串

OpenCL错误码转字符串(以中文表示)

错误代码位:0 ~ -19、-30 ~ -68

const char* errorCodeToString(cl_int errCode) {
	const char* err = NULL;
	switch (errCode) {
	case CL_SUCCESS:
		err = "CL_SUCCESS:命令成功执行,没有出现错误!";
		break;
	case CL_DEVICE_NOT_FOUND:
		err = "CL_DEVICE_NOT_FOUND:未发现与条件匹配的OpenCL设备!";
		break;
	case CL_DEVICE_NOT_AVAILABLE:
		err = "CL_DEVICE_NOT_AVAILABLE:OpenCL设备目前不可用!";
		break;
	case CL_COMPILER_NOT_AVAILABLE:
		err = "CL_COMPILER_NOT_AVAILABLE:程序由源代码创建,不过没有可用的OpenCL C编译器!";
		break;
	case CL_MEM_OBJECT_ALLOCATION_FAILURE:
		err = "CL_MEM_OBJECT_ALLOCATION_FAILURE:无法为内存对象或图像对象分配内存!";
		break;
	case CL_OUT_OF_RESOURCES:
		err = "CL_OUT_OF_RESOURCES:没有足够的资源执行命令!";
		break;
	case CL_OUT_OF_HOST_MEMORY:
		err = "CL_OUT_OF_HOST_MEMORY:宿主机上没有足够的内存执行命令!";
		break;
	case CL_PROFILING_INFO_NOT_AVAILABLE:
		err = "CL_PROFILING_INFO_NOT_AVAILABLE:无法得到事件的性能评测信息或者命令队列不支持性能评测!";
		break;
	case CL_MEM_COPY_OVERLAP:
		err = "CL_MEM_COPY_OVERLAP:两个缓冲区在同一个内存区域重叠!";
		break;
	case CL_IMAGE_FORMAT_MISMATCH:
		err = "CL_IMAGE_FORMAT_MISMATCH:图像未采用相同的图像格式!";
		break;
	case CL_IMAGE_FORMAT_NOT_SUPPORTED:
		err = "CL_IMAGE_FORMAT_NOT_SUPPORTED:不支持指定的图像格式!";
		break;
	case CL_BUILD_PROGRAM_FAILURE:
		err = "CL_BUILD_PROGRAM_FAILURE:无法为程序构建可执行代码!";
		break;
	case CL_MAP_FAILURE:
		err = "CL_MAP_FAILURE:内存区域无法映射到宿主机内存!";
		break;
	case CL_MISALIGNED_SUB_BUFFER_OFFSET:
		err = "CL_MISALIGNED_SUB_BUFFER_OFFSET:子缓冲区偏移不对中!";
		break;
	case CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST:
		err = "CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST:等待列表中事件的执行状态错误!";
		break;
	case CL_COMPILE_PROGRAM_FAILURE:
		err = "CL_COMPILE_PROGRAM_FAILURE:编译程序失败!";
		break;
	case CL_LINKER_NOT_AVAILABLE:
		err = "CL_LINKER_NOT_AVAILABLE:链接器不可用!";
		break;
	case CL_LINK_PROGRAM_FAILURE:
		err = "CL_LINK_PROGRAM_FAILURE:链接程序失败!";
		break;
	case CL_DEVICE_PARTITION_FAILED:
		err = "CL_DEVICE_PARTITION_FAILED:设备分区失败!";
		break;
	case CL_KERNEL_ARG_INFO_NOT_AVAILABLE:
		err = "CL_KERNEL_ARG_INFO_NOT_AVAILABLE:内核参数信息不可用!";
		break;


	case CL_INVALID_VALUE:
		err = "CL_INVALID_VALUE:命令的一个或多个参数指定了非法值!";
		break;
	case CL_INVALID_DEVICE_TYPE:
		err = "CL_INVALID_DEVICE_TYPE:传入的设备类型不是合法值!";
		break;
	case CL_INVALID_PLATFORM:
		err = "CL_INVALID_PLATFORM:传入的平台不是合法值!";
		break;
	case CL_INVALID_DEVICE:
		err = "CL_INVALID_DEVICE:传入的设备不是合法值!";
		break;
	case CL_INVALID_CONTEXT:
		err = "CL_INVALID_CONTEXT:传入的上下文不是合法值!";
		break;
	case CL_INVALID_QUEUE_PROPERTIES:
		err = "CL_INVALID_QUEUE_PROPERTIES:设备不支持命令队列属性!";
		break;
	case CL_INVALID_COMMAND_QUEUE:
		err = "CL_INVALID_COMMAND_QUEUE:传入的命令队列不是合法值!";
		break;
	case CL_INVALID_HOST_PTR:
		err = "CL_INVALID_HOST_PTR:宿主机指针不合法!";
		break;
	case CL_INVALID_MEM_OBJECT:
		err = "CL_INVALID_MEM_OBJECT:传入的内存对象不是合法值!";
		break;
	case CL_INVALID_IMAGE_FORMAT_DESCRIPTOR:
		err = "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR:传入的图像格式描述符不是合法值!";
		break;
	case CL_INVALID_IMAGE_SIZE:
		err = "CL_INVALID_IMAGE_SIZE:设备不支持这个图像大小!";
		break;
	case CL_INVALID_SAMPLER:
		err = "CL_INVALID_SAMPLER:传入的采样工具不是合法值!";
		break;
	case CL_INVALID_BINARY:
		err = "CL_INVALID_BINARY:传入了非法的二进制程序!";
		break;
	case CL_INVALID_BUILD_OPTIONS:
		err = "CL_INVALID_BUILD_OPTIONS:一个或多个构建选项不合法!";
		break;
	case CL_INVALID_PROGRAM:
		err = "CL_INVALID_PROGRAM:传入的程序不是合法值!";
		break;
	case CL_INVALID_PROGRAM_EXECUTABLE:
		err = "CL_INVALID_PROGRAM_EXECUTABLE:程序未能成功地构建命令队列关联设备上的一个可执行程序!";
		break;
	case CL_INVALID_KERNEL_NAME:
		err = "CL_INVALID_KERNEL_NAME:程序中不存在指定的内核!";
		break;
	case CL_INVALID_KERNEL_DEFINITION:
		err = "CL_INVALID_KERNEL_DEFINITION:程序源代码中定义的内核不合法!";
		break;
	case CL_INVALID_KERNEL:
		err = "CL_INVALID_KERNEL:传入的内核不是合法值!";
		break;
	case CL_INVALID_ARG_INDEX:
		err = "CL_INVALID_ARG_INDEX:参数索引指示的参数对于内核不合法!";
		break;
	case CL_INVALID_ARG_VALUE:
		err = "CL_INVALID_ARG_VALUE:对于一个非局部参数,内核参数值为NULL;或者对于一个局部参数,内核参数值为非NULL!";
		break;
	case CL_INVALID_ARG_SIZE:
		err = "CL_INVALID_ARG_SIZE:参数大小与内核参数不一致!";
		break;
	case CL_INVALID_KERNEL_ARGS:
		err = "CL_INVALID_KERNEL_ARGS:一个或多个内核参数未赋值!";
		break;
	case CL_INVALID_WORK_DIMENSION:
		err = "CL_INVALID_WORK_DIMENSION:工作维度值不是介于1~3的一个值!";
		break;
	case CL_INVALID_WORK_GROUP_SIZE:
		err = "CL_INVALID_WORK_GROUP_SIZE:局部或全局工作组大小不合法!";
		break;
	case CL_INVALID_WORK_ITEM_SIZE:
		err = "CL_INVALID_WORK_ITEM_SIZE:一个或多个工作项大小超出了设备支持的最大大小!";
		break;
	case CL_INVALID_GLOBAL_OFFSET:
		err = "CL_INVALID_GLOBAL_OFFSET:全局偏移量超出了所支持的界限!";
		break;
	case CL_INVALID_EVENT_WAIT_LIST:
		err = "CL_INVALID_EVENT_WAIT_LIST:提供的等待列表大小不合法或者其中包含非事件!";
		break;
	case CL_INVALID_EVENT:
		err = "CL_INVALID_EVENT:传入的事件不是一个合法值!";
		break;
	case CL_INVALID_OPERATION:
		err = "CL_INVALID_OPERATION:执行命令导致出现一个不合法的操作!";
		break;
	case CL_INVALID_GL_OBJECT:
		err = "CL_INVALID_GL_OBJECT:OpenGL引用的对象存在问题!";
		break;
	case CL_INVALID_BUFFER_SIZE:
		err = "CL_INVALID_BUFFER_SIZE:指定的缓冲区大小越界!";
		break;
	case CL_INVALID_MIP_LEVEL:
		err = "CL_INVALID_MIP_LEVEL:为OpenGL纹理指定的mipmap级别对于OpenGL对象不合法!";
		break;
	case CL_INVALID_GLOBAL_WORK_SIZE:
		err = "CL_INVALID_GLOBAL_WORK_SIZE:传入的全局工作大小不合法,可能为0或者超出了设备支持的大小!";
		break;
	case CL_INVALID_PROPERTY:
		err = "CL_INVALID_PROPERTY:传入无效的属性!";
		break;
	case CL_INVALID_IMAGE_DESCRIPTOR:
		err = "CL_INVALID_IMAGE_DESCRIPTOR:传入无效的图像描述符!";
		break;
	case CL_INVALID_COMPILER_OPTIONS:
		err = "CL_INVALID_COMPILER_OPTIONS:传入无效的编译器选项!";
		break;
	case CL_INVALID_LINKER_OPTIONS:
		err = "CL_INVALID_LINKER_OPTIONS:传入无效的链接器选项!";
		break;
	case CL_INVALID_DEVICE_PARTITION_COUNT:
		err = "CL_INVALID_DEVICE_PARTITION_COUNT:传入无效的设备分区计数!";
		break;
	default:
		err = "未知错误";
	}
	return err;
}

你可能感兴趣的:(OpenCL)