示例#1
0
文件: mem.cpp 项目: Agorath/freeocl
	cl_int clReleaseMemObjectFCL (cl_mem memobj)
	{
		MSG(clReleaseMemObjectFCL);
		if (!FreeOCL::is_valid(memobj))
			return CL_INVALID_MEM_OBJECT;

		memobj->release();
		if (memobj->get_ref_count() == 0)
		{
			memobj->invalidate();
			memobj->unlock();
			delete memobj;
		}
		else
			memobj->unlock();
		return CL_SUCCESS;
	}
示例#2
0
文件: mem.cpp 项目: Agorath/freeocl
	cl_int clGetMemObjectInfoFCL (cl_mem memobj,
							   cl_mem_info param_name,
							   size_t param_value_size,
							   void *param_value,
							   size_t *param_value_size_ret)
	{
		MSG(clGetMemObjectInfoFCL);
		FreeOCL::unlocker unlock;
		if (!FreeOCL::is_valid(memobj))
			return CL_INVALID_MEM_OBJECT;
		unlock.handle(memobj);

		bool bTooSmall = false;
		switch(param_name)
		{
		case CL_MEM_TYPE:					bTooSmall = SET_VAR(memobj->mem_type);	break;
		case CL_MEM_FLAGS:					bTooSmall = SET_VAR(memobj->flags);	break;
		case CL_MEM_SIZE:					bTooSmall = SET_VAR(memobj->size);	break;
		case CL_MEM_HOST_PTR:				bTooSmall = SET_VAR(memobj->host_ptr);	break;
		case CL_MEM_MAP_COUNT:
			{
				cl_uint n = memobj->mapped.size();
				bTooSmall = SET_VAR(n);
			}
			break;
		case CL_MEM_REFERENCE_COUNT:		bTooSmall = SET_VAR(memobj->get_ref_count());	break;
		case CL_MEM_CONTEXT:				bTooSmall = SET_VAR(memobj->context);	break;
		case CL_MEM_ASSOCIATED_MEMOBJECT:	bTooSmall = SET_VAR(memobj->parent);	break;
		case CL_MEM_OFFSET:					bTooSmall = SET_VAR(memobj->offset);	break;
		default:
			return CL_INVALID_VALUE;
		}

		if (bTooSmall && param_value != NULL)
			return CL_INVALID_VALUE;

		return CL_SUCCESS;
	}