From 474baa04eda3b2bba3bf10c121ae98a7137dc128 Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Wed, 18 Nov 2020 18:37:54 -0800 Subject: [PATCH] clover/api: Support MSVC Three things: 1. MSVC dislikes mismatching declaration/definition of __declspec(dllexport). Since CL headers don't have the declspec, the implementations should't either. 2. An unnamed brace-initialization gets deduced as an initializer list, instead of a brace-constructed string. Just add the type name. 3. posix_memalign doesn't exist on Windows. Reviewed-by: Francisco Jerez Reviewed-by: Karol Herbst Part-of: --- src/gallium/frontends/clover/api/memory.cpp | 2 ++ src/gallium/frontends/clover/api/program.cpp | 2 +- src/gallium/frontends/clover/api/util.hpp | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gallium/frontends/clover/api/memory.cpp b/src/gallium/frontends/clover/api/memory.cpp index 89762d1b262..1ffe306289b 100644 --- a/src/gallium/frontends/clover/api/memory.cpp +++ b/src/gallium/frontends/clover/api/memory.cpp @@ -511,6 +511,7 @@ clSVMAlloc(cl_context d_ctx, if (!alignment) alignment = 0x80; // sizeof(long16) +#if HAVE_POSIX_MEMALIGN bool can_emulate = all_of(std::mem_fn(&device::has_system_svm), ctx.devices()); if (can_emulate) { // we can ignore all the flags as it's not required to honor them. @@ -520,6 +521,7 @@ clSVMAlloc(cl_context d_ctx, posix_memalign(&ptr, alignment, size); return ptr; } +#endif CLOVER_NOT_SUPPORTED_UNTIL("2.0"); return nullptr; diff --git a/src/gallium/frontends/clover/api/program.cpp b/src/gallium/frontends/clover/api/program.cpp index ebe5f233c3c..d390c1c9e13 100644 --- a/src/gallium/frontends/clover/api/program.cpp +++ b/src/gallium/frontends/clover/api/program.cpp @@ -123,7 +123,7 @@ clCreateProgramWithBinary(cl_context d_ctx, cl_uint n, return { CL_INVALID_VALUE, {} }; try { - std::stringbuf bin( { (char*)p, l } ); + std::stringbuf bin( std::string{ (char*)p, l } ); std::istream s(&bin); return { CL_SUCCESS, module::deserialize(s) }; diff --git a/src/gallium/frontends/clover/api/util.hpp b/src/gallium/frontends/clover/api/util.hpp index 66bd12597c6..788c99adbd2 100644 --- a/src/gallium/frontends/clover/api/util.hpp +++ b/src/gallium/frontends/clover/api/util.hpp @@ -29,8 +29,12 @@ #include "core/error.hpp" #include "core/property.hpp" #include "util/algorithm.hpp" +#include "util/detect_os.h" -#ifdef HAVE_CLOVER_ICD +#if DETECT_OS_WINDOWS +#define CLOVER_API +#define CLOVER_ICD_API +#elif HAVE_CLOVER_ICD #define CLOVER_API #define CLOVER_ICD_API PUBLIC #else