clover: add support for opencl C features
authorDave Airlie <airlied@redhat.com>
Tue, 10 Nov 2020 05:08:46 +0000 (15:08 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 10 Nov 2020 20:30:26 +0000 (06:30 +1000)
This adds support to the compiler and api for this CL 3.0 feature.

fixes CTS compiler features_macro

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7520>

src/gallium/frontends/clover/api/device.cpp
src/gallium/frontends/clover/core/device.cpp
src/gallium/frontends/clover/core/device.hpp
src/gallium/frontends/clover/llvm/invocation.cpp

index d5204d3..9ed873d 100644 (file)
@@ -421,6 +421,10 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
       buf.as_vector<cl_name_version>() = dev.supported_extensions();
       break;
 
+   case CL_DEVICE_OPENCL_C_FEATURES:
+      buf.as_vector<cl_name_version>() = dev.opencl_c_features();
+      break;
+
    default:
       throw error(CL_INVALID_VALUE);
    }
index 4db593c..76b61a1 100644 (file)
@@ -409,3 +409,14 @@ device::opencl_c_all_versions() const {
    }
    return vec;
 }
+
+std::vector<cl_name_version>
+device::opencl_c_features() const {
+   std::vector<cl_name_version> vec;
+
+   vec.push_back( (cl_name_version) {CL_MAKE_VERSION(3, 0, 0), "__opencl_c_int64" });
+   if (has_doubles())
+      vec.push_back( (cl_name_version) {CL_MAKE_VERSION(3, 0, 0), "__opencl_c_fp64" });
+
+   return vec;
+}
index 81687b5..bc57c8d 100644 (file)
@@ -96,6 +96,8 @@ namespace clover {
       std::vector<cl_name_version> opencl_c_all_versions() const;
       std::vector<cl_name_version> supported_extensions() const;
 
+      std::vector<cl_name_version> opencl_c_features() const;
+
       friend class command_queue;
       friend class root_resource;
       friend class hard_event;
index 413db85..ef0c31c 100644 (file)
@@ -291,6 +291,12 @@ namespace {
                                           std::to_string(CL_VERSION_MAJOR_KHR(dev_version)) +
                                           std::to_string(CL_VERSION_MINOR_KHR(dev_version)) + "0");
 
+      if (CL_VERSION_MAJOR(dev.version) >= 3) {
+         const auto features = dev.opencl_c_features();
+         for (const auto &feature : features)
+            c.getPreprocessorOpts().addMacroDef(feature.name);
+      }
+
       // clc.h requires that this macro be defined:
       c.getPreprocessorOpts().addMacroDef("cl_clang_storage_class_specifiers");
       c.getPreprocessorOpts().addRemappedFile(