Mesa (master): clover: Implement clGetExtensionFunctionAddressForPlatform.
Module: Mesa Branch: master Commit: cb0879985a40bcde1516e5341c5a3e5ea0968b87 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cb0879985a40bcde1516e5341c5a3e5ea0968b87 Author: Serge Martin Date: Sun Sep 27 11:15:14 2015 +0200 clover: Implement clGetExtensionFunctionAddressForPlatform. Add clGetExtensionFunctionAddressForPlatform (CL 1.2). Reviewed-by: Francisco Jerez --- src/gallium/state_trackers/clover/api/dispatch.cpp | 2 +- src/gallium/state_trackers/clover/api/dispatch.hpp | 4 src/gallium/state_trackers/clover/api/platform.cpp | 16 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/clover/api/dispatch.cpp b/src/gallium/state_trackers/clover/api/dispatch.cpp index f10babe..8f4cfdc 100644 --- a/src/gallium/state_trackers/clover/api/dispatch.cpp +++ b/src/gallium/state_trackers/clover/api/dispatch.cpp @@ -131,7 +131,7 @@ namespace clover { clEnqueueMigrateMemObjects, clEnqueueMarkerWithWaitList, clEnqueueBarrierWithWaitList, - NULL, // clGetExtensionFunctionAddressForPlatform + GetExtensionFunctionAddressForPlatform, NULL, // clCreateFromGLTexture NULL, // clGetDeviceIDsFromD3D11KHR NULL, // clCreateFromD3D11BufferKHR diff --git a/src/gallium/state_trackers/clover/api/dispatch.hpp b/src/gallium/state_trackers/clover/api/dispatch.hpp index 7f62282..0ec1b51 100644 --- a/src/gallium/state_trackers/clover/api/dispatch.hpp +++ b/src/gallium/state_trackers/clover/api/dispatch.hpp @@ -777,6 +777,10 @@ namespace clover { void * GetExtensionFunctionAddress(const char *p_name); + void * + GetExtensionFunctionAddressForPlatform(cl_platform_id d_platform, + const char *p_name); + cl_int IcdGetPlatformIDsKHR(cl_uint num_entries, cl_platform_id *rd_platforms, cl_uint *rnum_platforms); diff --git a/src/gallium/state_trackers/clover/api/platform.cpp b/src/gallium/state_trackers/clover/api/platform.cpp index b1b1fdf..ed86163 100644 --- a/src/gallium/state_trackers/clover/api/platform.cpp +++ b/src/gallium/state_trackers/clover/api/platform.cpp @@ -92,6 +92,16 @@ clover::GetPlatformInfo(cl_platform_id d_platform, cl_platform_info param, } void * +clover::GetExtensionFunctionAddressForPlatform(cl_platform_id d_platform, + const char *p_name) try { + obj(d_platform); + return GetExtensionFunctionAddress(p_name); + +} catch (error &e) { + return NULL; +} + +void * clover::GetExtensionFunctionAddress(const char *p_name) { std::string name { p_name }; @@ -118,6 +128,12 @@ clGetExtensionFunctionAddress(const char *p_name) { return GetExtensionFunctionAddress(p_name); } +CLOVER_ICD_API void * +clGetExtensionFunctionAddressForPlatform(cl_platform_id d_platform, + const char *p_name) { + return GetExtensionFunctionAddressForPlatform(d_platform, p_name); +} + CLOVER_ICD_API cl_int clIcdGetPlatformIDsKHR(cl_uint num_entries, cl_platform_id *rd_platforms, cl_uint *rnum_platforms) { ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): clover: Introduce CLOVER_EXTRA_*_OPTIONS environment variables
Module: Mesa Branch: master Commit: 2fba72046da09dd28f54df02794b358773899d13 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2fba72046da09dd28f54df02794b358773899d13 Author: Vedran Miletić Date: Wed Sep 28 16:18:24 2016 +0200 clover: Introduce CLOVER_EXTRA_*_OPTIONS environment variables The options specified in the CLOVER_EXTRA_BUILD_OPTIONS shell variable are appended to the options specified by the OpenCL program in the clBuildProgram function call, if any. Analogously, the options specified in the CLOVER_EXTRA_COMPILE_OPTIONS and CLOVER_EXTRA_LINK_OPTIONS variables are appended to the options specified in clCompileProgram and clLinkProgram function calls, respectively. v2: * rename to CLOVER_EXTRA_COMPILER_OPTIONS * use debug_get_option * append to linker options as well v3: code cleanups v4: separate CLOVER_EXTRA_LINKER_OPTIONS options v5: * fix documentation typo * use CLOVER_EXTRA_COMPILER_OPTIONS in link stage v6: * separate in CLOVER_EXTRA_{BUILD,COMPILE,LINK}_OPTIONS * append options in cl{Build,Compile,Link}Program Signed-off-by: Vedran Miletić Reviewed-by[v1]: Edward O'Callaghan v7 [Francisco Jerez]: Slight simplification. Reviewed-by: Francisco Jerez --- docs/envvars.html | 15 +++ src/gallium/state_trackers/clover/api/program.cpp | 10 +++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/docs/envvars.html b/docs/envvars.html index cf57ca5..af1a30c 100644 --- a/docs/envvars.html +++ b/docs/envvars.html @@ -235,6 +235,21 @@ Setting to "tgsi", for example, will print all the TGSI shaders. See src/mesa/state_tracker/st_debug.c for other options. +Clover state tracker environment variables + + +CLOVER_EXTRA_BUILD_OPTIONS - allows specifying additional compiler and linker +options. Specified options are appended after the options set by the OpenCL +program in clBuildProgram. +CLOVER_EXTRA_COMPILE_OPTIONS - allows specifying additional compiler +options. Specified options are appended after the options set by the OpenCL +program in clCompileProgram. +CLOVER_EXTRA_LINK_OPTIONS - allows specifying additional linker +options. Specified options are appended after the options set by the OpenCL +program in clLinkProgram. + + + Softpipe driver environment variables SOFTPIPE_DUMP_FS - if set, the softpipe driver will print fragment shaders diff --git a/src/gallium/state_trackers/clover/api/program.cpp b/src/gallium/state_trackers/clover/api/program.cpp index c3f9cb9..ba4ce7a 100644 --- a/src/gallium/state_trackers/clover/api/program.cpp +++ b/src/gallium/state_trackers/clover/api/program.cpp @@ -22,6 +22,7 @@ #include "api/util.hpp" #include "core/program.hpp" +#include "util/u_debug.h" #include @@ -177,7 +178,8 @@ clBuildProgram(cl_program d_prog, cl_uint num_devs, auto &prog = obj(d_prog); auto devs = (d_devs ? objs(d_devs, num_devs) : ref_vector(prog.context().devices())); - auto opts = (p_opts ? p_opts : ""); + const auto opts = std::string(p_opts ? p_opts : "") + " " + + debug_get_option("CLOVER_EXTRA_BUILD_OPTIONS", ""); validate_build_common(prog, num_devs, d_devs, pfn_notify, user_data); @@ -202,7 +204,8 @@ clCompileProgram(cl_program d_prog, cl_uint num_devs, auto &prog = obj(d_prog); auto devs = (d_devs ? objs(d_devs, num_devs) : ref_vector(prog.context().devices())); - auto opts = (p_opts ? p_opts : ""); + const auto opts = std::string(p_opts ? p_opts : "") + " " + + debug_get_option("CLOVER_EXTRA_COMPILE_OPTIONS", ""); header_map headers; validate_build_common(prog, num_devs, d_devs, pfn_notify, user_data); @@ -271,7 +274,8 @@ clLinkProgram(cl_context d_ctx, cl_uint num_devs, const cl_device_id *d_devs, void (*pfn_notify) (cl_program, void *), void *user_data, cl_int *r_errcode) try { auto &ctx = obj(d_ctx); - auto opts = (p_opts ? p_opts : ""); + const auto opts = std::string(p_opts ? p_opts : "") + " " + + debug_get_option("CLOVER_EXTRA_LINK_OPTIONS", ""); auto progs = objs(d_progs, num_progs); auto prog = create(ctx); auto devs = validate_link_devices(progs, ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): clover: Pass unquoted compiler arguments to Clang
Module: Mesa Branch: master Commit: e3272865c216933168e6c08766d266a33d0e1497 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e3272865c216933168e6c08766d266a33d0e1497 Author: Vedran Miletić Date: Wed Sep 28 17:11:43 2016 +0200 clover: Pass unquoted compiler arguments to Clang OpenCL apps can quote arguments they pass to the OpenCL compiler, most commonly include paths containing spaces. If the Clang OpenCL compiler was called via a shell, the shell would split the arguments with respect to to quotes and then remove quotes before passing the arguments to the compiler. Since we call Clang as a library, we have to split the argument with respect to quotes and then remove quotes before passing the arguments. v2: move to tokenize(), remove throwing of CL_INVALID_COMPILER_OPTIONS v3: simplify parsing logic, use more C++11 v4: restore error throwing, clarify a comment Signed-off-by: Vedran Miletić Reviewed-by: Francisco Jerez --- src/gallium/state_trackers/clover/llvm/util.hpp | 40 ++--- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/src/gallium/state_trackers/clover/llvm/util.hpp b/src/gallium/state_trackers/clover/llvm/util.hpp index 8db6f20..222becd 100644 --- a/src/gallium/state_trackers/clover/llvm/util.hpp +++ b/src/gallium/state_trackers/clover/llvm/util.hpp @@ -24,6 +24,7 @@ #ifndef CLOVER_LLVM_UTIL_HPP #define CLOVER_LLVM_UTIL_HPP +#include "core/error.hpp" #include "util/u_debug.h" #include @@ -42,11 +43,42 @@ namespace clover { inline std::vector tokenize(const std::string &s) { std::vector ss; - std::istringstream iss(s); - std::string t; + std::ostringstream oss; - while (getline(iss, t, ' ')) -ss.push_back(t); + // OpenCL programs can pass a quoted argument, most frequently the + // include path. This is useful so that path containing spaces is + // treated as a single argument instead of being split by the spaces. + // Additionally, the argument should also be unquoted before being + // passed to the compiler. We avoid using std::string::replace here to + // remove quotes, as the single and double quote characters can be a + // part of the file name. + bool escape_next = false; + bool in_quote_double = false; + bool in_quote_single = false; + + for (auto c : s) { +if (escape_next) { + oss.put(c); + escape_next = false; +} else if (c == '\\') { + escape_next = true; +} else if (c == '"' && !in_quote_single) { + in_quote_double = !in_quote_double; +} else if (c == '\'' && !in_quote_double) { + in_quote_single = !in_quote_single; +} else if (c != ' ' || in_quote_single || in_quote_double) { + oss.put(c); +} else if (oss.tellp() > 0) { + ss.emplace_back(oss.str()); + oss.str(""); +} + } + + if (oss.tellp() > 0) +ss.emplace_back(oss.str()); + + if (in_quote_double || in_quote_single) +throw invalid_build_options_error(); return ss; } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit