[Mesa-dev] [PATCH] clover/device: Calculate CL_DEVICE_MEM_BASE_ADDR_ALIGN in device

Jan Vesely jan.vesely at rutgers.edu
Thu Aug 17 04:21:50 UTC 2017


On Wed, 2017-08-16 at 22:54 -0500, Aaron Watry wrote:
> The CL CTS queries CL_DEVICE_MEM_BASE_ADDR_ALIGN for a device and
> then allocates user pointers aligned to that value for its tests.
> 
> The minimum value is defined as:
>   the size (in bits) of the largest OpenCL built-in data type supported
>   by the device (long16 in FULL profile, long16 or int16 in EMBEDDED
>   profile) for devices that are not of type CL_DEVICE_TYPE_CUSTOM.
> 
> At the moment, all known devices that support user pointers require
> CPU page alignment for buffers created from user pointers, so just
> query that from sysconf.
> 
> v2: Use system page size instead of a new pipe cap

system page size makes sense.
LGTM. Reviewed-by: Jan Vesely <jan.vesely at rutgers.edu>

Jan

> 
> Signed-off-by: Aaron Watry <awatry at gmail.com>
> Cc: Francisco Jerez <currojerez at riseup.net>
> Cc: Jan Vesely <jan.vesely at rutgers.edu>
> ---
>  src/gallium/state_trackers/clover/api/device.cpp  | 3 ++-
>  src/gallium/state_trackers/clover/core/device.cpp | 5 +++++
>  src/gallium/state_trackers/clover/core/device.hpp | 1 +
>  3 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/src/gallium/state_trackers/clover/api/device.cpp b/src/gallium/state_trackers/clover/api/device.cpp
> index b1b7917e4e..b5ffe110be 100644
> --- a/src/gallium/state_trackers/clover/api/device.cpp
> +++ b/src/gallium/state_trackers/clover/api/device.cpp
> @@ -205,7 +205,8 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
>        break;
>  
>     case CL_DEVICE_MEM_BASE_ADDR_ALIGN:
> -      buf.as_scalar<cl_uint>() = 128 * 8;
> +      buf.as_scalar<cl_uint>() = 8 *
> +         MAX2(dev.mem_base_addr_align(), sizeof(cl_long) * 16);
>        break;
>  
>     case CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE:
> diff --git a/src/gallium/state_trackers/clover/core/device.cpp b/src/gallium/state_trackers/clover/core/device.cpp
> index f6bbc38a98..c5964bc6e3 100644
> --- a/src/gallium/state_trackers/clover/core/device.cpp
> +++ b/src/gallium/state_trackers/clover/core/device.cpp
> @@ -194,6 +194,11 @@ device::has_unified_memory() const {
>     return pipe->get_param(pipe, PIPE_CAP_UMA);
>  }
>  
> +cl_uint
> +device::mem_base_addr_align() const {
> +   return sysconf(_SC_PAGESIZE);
> +}
> +
>  std::vector<size_t>
>  device::max_block_size() const {
>     auto v = get_compute_param<uint64_t>(pipe, ir_format(),
> diff --git a/src/gallium/state_trackers/clover/core/device.hpp b/src/gallium/state_trackers/clover/core/device.hpp
> index efc217aedb..4e11519421 100644
> --- a/src/gallium/state_trackers/clover/core/device.hpp
> +++ b/src/gallium/state_trackers/clover/core/device.hpp
> @@ -68,6 +68,7 @@ namespace clover {
>        bool image_support() const;
>        bool has_doubles() const;
>        bool has_unified_memory() const;
> +      cl_uint mem_base_addr_align() const;
>  
>        std::vector<size_t> max_block_size() const;
>        cl_uint subgroup_size() const;

-- 
Jan Vesely <jan.vesely at rutgers.edu>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170817/ad862d9f/attachment.sig>


More information about the mesa-dev mailing list