[Mesa-dev] [PATCH 3/3] clover: add clCompile
--- src/gallium/state_trackers/clover/api/dispatch.cpp | 2 +- src/gallium/state_trackers/clover/api/program.cpp | 39 +++--- .../state_trackers/clover/core/compiler.hpp| 12 --- src/gallium/state_trackers/clover/core/error.hpp | 2 +- src/gallium/state_trackers/clover/core/program.cpp | 14 ++-- src/gallium/state_trackers/clover/core/program.hpp | 5 ++- .../state_trackers/clover/llvm/invocation.cpp | 39 ++ 7 files changed, 93 insertions(+), 20 deletions(-) diff --git a/src/gallium/state_trackers/clover/api/dispatch.cpp b/src/gallium/state_trackers/clover/api/dispatch.cpp index 35d150d..b5a4094 100644 --- a/src/gallium/state_trackers/clover/api/dispatch.cpp +++ b/src/gallium/state_trackers/clover/api/dispatch.cpp @@ -122,7 +122,7 @@ namespace clover { clReleaseDevice, clCreateImage, clCreateProgramWithBuiltInKernels, - NULL, // clCompileProgram + clCompileProgram, NULL, // clLinkProgram clUnloadPlatformCompiler, NULL, // clGetKernelArgInfo diff --git a/src/gallium/state_trackers/clover/api/program.cpp b/src/gallium/state_trackers/clover/api/program.cpp index 6771735..33df0cd 100644 --- a/src/gallium/state_trackers/clover/api/program.cpp +++ b/src/gallium/state_trackers/clover/api/program.cpp @@ -152,14 +152,34 @@ CLOVER_API cl_int clBuildProgram(cl_program d_prog, cl_uint num_devs, const cl_device_id *d_devs, const char *p_opts, void (*pfn_notify)(cl_program, void *), - void *user_data) try { + void *user_data) { + cl_int error = clCompileProgram(d_prog, num_devs, d_devs, p_opts, + 0, 0, 0, + pfn_notify, user_data); + return error == CL_COMPILE_PROGRAM_FAILURE ? + CL_BUILD_PROGRAM_FAILURE : error; +} + +CLOVER_API cl_int +clCompileProgram(cl_program d_prog, cl_uint num_devs, + const cl_device_id *d_devs, const char *p_opts, + cl_uint num_headers, const cl_program *d_header_progs, + const char **header_names, + void (*pfn_notify)(cl_program, void *), + void *user_data) try { 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 : ""); - if (bool(num_devs) != bool(d_devs) || - (!pfn_notify && user_data)) + if (bool(num_devs) != bool(d_devs)) + throw error(CL_INVALID_VALUE); + + if (!pfn_notify && user_data) + throw error(CL_INVALID_VALUE); + + if (bool(num_headers) != bool(header_names) || + bool(num_headers) != bool(d_header_progs)) throw error(CL_INVALID_VALUE); if (any_of([&](const device &dev) { @@ -170,7 +190,18 @@ clBuildProgram(cl_program d_prog, cl_uint num_devs, if (prog.kernel_ref_count()) throw error(CL_INVALID_OPERATION); - prog.build(devs, opts); + std::map headers; + for (cl_uint i = 0; i < num_headers; ++i) { + auto h_name = std::string(header_names[i]); + auto &h_prog = obj(d_header_progs[i]); + + if (!h_prog.has_source) + throw error(CL_INVALID_OPERATION); + + headers.insert(make_pair(h_name, h_prog.source())); + } + + prog.build(devs, opts, headers); return CL_SUCCESS; } catch (error &e) { diff --git a/src/gallium/state_trackers/clover/core/compiler.hpp b/src/gallium/state_trackers/clover/core/compiler.hpp index 6ef84d1..c2c4063 100644 --- a/src/gallium/state_trackers/clover/core/compiler.hpp +++ b/src/gallium/state_trackers/clover/core/compiler.hpp @@ -29,11 +29,15 @@ #include "pipe/p_defines.h" namespace clover { + typedef compat::pair, +compat::vector_ref > vector_ref_pair; + module compile_program_llvm(const compat::string &source, - pipe_shader_ir ir, - const compat::string &target, - const compat::string &opts, - compat::string &r_log); + const compat::vector &headers, + pipe_shader_ir ir, + const compat::string &target, + const compat::string &opts, + compat::string &r_log); module compile_program_tgsi(const compat::string &source); } diff --git a/src/gallium/state_trackers/clover/core/error.hpp b/src/gallium/state_trackers/clover/core/error.hpp index cecbe9b..7b010f1 100644 --- a/src/gallium/state_trackers/clover/core/error.hpp +++ b/src/gallium/state_trackers/clover/core/error.hpp @@ -67,7 +67,7 @@ namespace clover { class build_error : public error { public: build_error(const compat::string &what = "") : - error(CL_BUILD_PROGRAM_FAILURE, what) { + error(CL_COMPILE_PROGRAM_FAILURE, what) { } }; diff --git a/src/gallium/state_trackers/clover/cor
Re: [Mesa-dev] [PATCH 3/3] clover: add clCompile
On Sun, Sep 28, 2014 at 12:57:22PM +0200, EdB wrote: > --- > src/gallium/state_trackers/clover/api/dispatch.cpp | 2 +- > src/gallium/state_trackers/clover/api/program.cpp | 39 > +++--- > .../state_trackers/clover/core/compiler.hpp| 12 --- > src/gallium/state_trackers/clover/core/error.hpp | 2 +- > src/gallium/state_trackers/clover/core/program.cpp | 14 ++-- > src/gallium/state_trackers/clover/core/program.hpp | 5 ++- > .../state_trackers/clover/llvm/invocation.cpp | 39 > ++ > 7 files changed, 93 insertions(+), 20 deletions(-) > > diff --git a/src/gallium/state_trackers/clover/api/dispatch.cpp > b/src/gallium/state_trackers/clover/api/dispatch.cpp > index 35d150d..b5a4094 100644 > --- a/src/gallium/state_trackers/clover/api/dispatch.cpp > +++ b/src/gallium/state_trackers/clover/api/dispatch.cpp > @@ -122,7 +122,7 @@ namespace clover { >clReleaseDevice, >clCreateImage, >clCreateProgramWithBuiltInKernels, > - NULL, // clCompileProgram > + clCompileProgram, >NULL, // clLinkProgram >clUnloadPlatformCompiler, >NULL, // clGetKernelArgInfo > diff --git a/src/gallium/state_trackers/clover/api/program.cpp > b/src/gallium/state_trackers/clover/api/program.cpp > index 6771735..33df0cd 100644 > --- a/src/gallium/state_trackers/clover/api/program.cpp > +++ b/src/gallium/state_trackers/clover/api/program.cpp > @@ -152,14 +152,34 @@ CLOVER_API cl_int > clBuildProgram(cl_program d_prog, cl_uint num_devs, > const cl_device_id *d_devs, const char *p_opts, > void (*pfn_notify)(cl_program, void *), > - void *user_data) try { > + void *user_data) { > + cl_int error = clCompileProgram(d_prog, num_devs, d_devs, p_opts, > + 0, 0, 0, > + pfn_notify, user_data); > + return error == CL_COMPILE_PROGRAM_FAILURE ? > + CL_BUILD_PROGRAM_FAILURE : error; > +} > + > +CLOVER_API cl_int > +clCompileProgram(cl_program d_prog, cl_uint num_devs, > + const cl_device_id *d_devs, const char *p_opts, > + cl_uint num_headers, const cl_program *d_header_progs, > + const char **header_names, > + void (*pfn_notify)(cl_program, void *), > + void *user_data) try { > 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 : ""); > > - if (bool(num_devs) != bool(d_devs) || > - (!pfn_notify && user_data)) > + if (bool(num_devs) != bool(d_devs)) > + throw error(CL_INVALID_VALUE); > + > + if (!pfn_notify && user_data) > + throw error(CL_INVALID_VALUE); > + > + if (bool(num_headers) != bool(header_names) || > + bool(num_headers) != bool(d_header_progs)) >throw error(CL_INVALID_VALUE); > > if (any_of([&](const device &dev) { > @@ -170,7 +190,18 @@ clBuildProgram(cl_program d_prog, cl_uint num_devs, > if (prog.kernel_ref_count()) >throw error(CL_INVALID_OPERATION); > > - prog.build(devs, opts); > + std::map headers; > + for (cl_uint i = 0; i < num_headers; ++i) { > + auto h_name = std::string(header_names[i]); > + auto &h_prog = obj(d_header_progs[i]); > + > + if (!h_prog.has_source) > + throw error(CL_INVALID_OPERATION); > + > + headers.insert(make_pair(h_name, h_prog.source())); > + } > + > + prog.build(devs, opts, headers); > return CL_SUCCESS; > > } catch (error &e) { > diff --git a/src/gallium/state_trackers/clover/core/compiler.hpp > b/src/gallium/state_trackers/clover/core/compiler.hpp > index 6ef84d1..c2c4063 100644 > --- a/src/gallium/state_trackers/clover/core/compiler.hpp > +++ b/src/gallium/state_trackers/clover/core/compiler.hpp > @@ -29,11 +29,15 @@ > #include "pipe/p_defines.h" > > namespace clover { > + typedef compat::pair, > +compat::vector_ref > vector_ref_pair; > + > module compile_program_llvm(const compat::string &source, > - pipe_shader_ir ir, > - const compat::string &target, > - const compat::string &opts, > - compat::string &r_log); > + const compat::vector &headers, > + pipe_shader_ir ir, > + const compat::string &target, > + const compat::string &opts, > + compat::string &r_log); > > module compile_program_tgsi(const compat::string &source); > } > diff --git a/src/gallium/state_trackers/clover/core/error.hpp > b/src/gallium/state_trackers/clover/core/error.hpp > index cecbe9b..7b010f1 100644 > --- a/src/gallium/state_trackers/clover/core/error.hpp > +++ b/src/gallium/state_trackers/clover/core/error.hpp > @@ -67,7 +67,7 @@
Re: [Mesa-dev] [PATCH 3/3] clover: add clCompile
On Thursday, October 09, 2014 06:29:40 AM Tom Stellard wrote: > On Sun, Sep 28, 2014 at 12:57:22PM +0200, EdB wrote: > > --- > > > > src/gallium/state_trackers/clover/api/dispatch.cpp | 2 +- > > src/gallium/state_trackers/clover/api/program.cpp | 39 > > +++--- .../state_trackers/clover/core/compiler.hpp > > | 12 --- > > src/gallium/state_trackers/clover/core/error.hpp | 2 +- > > src/gallium/state_trackers/clover/core/program.cpp | 14 ++-- > > src/gallium/state_trackers/clover/core/program.hpp | 5 ++- > > .../state_trackers/clover/llvm/invocation.cpp | 39 > > ++ 7 files changed, 93 insertions(+), 20 > > deletions(-) > > > > diff --git a/src/gallium/state_trackers/clover/api/dispatch.cpp > > b/src/gallium/state_trackers/clover/api/dispatch.cpp index > > 35d150d..b5a4094 100644 > > --- a/src/gallium/state_trackers/clover/api/dispatch.cpp > > +++ b/src/gallium/state_trackers/clover/api/dispatch.cpp > > @@ -122,7 +122,7 @@ namespace clover { > > > >clReleaseDevice, > >clCreateImage, > >clCreateProgramWithBuiltInKernels, > > > > - NULL, // clCompileProgram > > + clCompileProgram, > > > >NULL, // clLinkProgram > >clUnloadPlatformCompiler, > >NULL, // clGetKernelArgInfo > > > > diff --git a/src/gallium/state_trackers/clover/api/program.cpp > > b/src/gallium/state_trackers/clover/api/program.cpp index > > 6771735..33df0cd 100644 > > --- a/src/gallium/state_trackers/clover/api/program.cpp > > +++ b/src/gallium/state_trackers/clover/api/program.cpp > > @@ -152,14 +152,34 @@ CLOVER_API cl_int > > > > clBuildProgram(cl_program d_prog, cl_uint num_devs, > > > > const cl_device_id *d_devs, const char *p_opts, > > void (*pfn_notify)(cl_program, void *), > > > > - void *user_data) try { > > + void *user_data) { > > + cl_int error = clCompileProgram(d_prog, num_devs, d_devs, p_opts, > > + 0, 0, 0, > > + pfn_notify, user_data); > > + return error == CL_COMPILE_PROGRAM_FAILURE ? > > + CL_BUILD_PROGRAM_FAILURE : error; > > +} > > + > > +CLOVER_API cl_int > > +clCompileProgram(cl_program d_prog, cl_uint num_devs, > > + const cl_device_id *d_devs, const char *p_opts, > > + cl_uint num_headers, const cl_program *d_header_progs, > > + const char **header_names, > > + void (*pfn_notify)(cl_program, void *), > > + void *user_data) try { > > > > 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 : ""); > > > > - if (bool(num_devs) != bool(d_devs) || > > - (!pfn_notify && user_data)) > > + if (bool(num_devs) != bool(d_devs)) > > + throw error(CL_INVALID_VALUE); > > + > > + if (!pfn_notify && user_data) > > + throw error(CL_INVALID_VALUE); > > + > > + if (bool(num_headers) != bool(header_names) || > > + bool(num_headers) != bool(d_header_progs)) > > > >throw error(CL_INVALID_VALUE); > > > > if (any_of([&](const device &dev) { > > > > @@ -170,7 +190,18 @@ clBuildProgram(cl_program d_prog, cl_uint num_devs, > > > > if (prog.kernel_ref_count()) > > > >throw error(CL_INVALID_OPERATION); > > > > - prog.build(devs, opts); > > + std::map headers; > > + for (cl_uint i = 0; i < num_headers; ++i) { > > + auto h_name = std::string(header_names[i]); > > + auto &h_prog = obj(d_header_progs[i]); > > + > > + if (!h_prog.has_source) > > + throw error(CL_INVALID_OPERATION); > > + > > + headers.insert(make_pair(h_name, h_prog.source())); > > + } > > + > > + prog.build(devs, opts, headers); > > > > return CL_SUCCESS; > > > > } catch (error &e) { > > > > diff --git a/src/gallium/state_trackers/clover/core/compiler.hpp > > b/src/gallium/state_trackers/clover/core/compiler.hpp index > > 6ef84d1..c2c4063 100644 > > --- a/src/gallium/state_trackers/clover/core/compiler.hpp > > +++ b/src/gallium/state_trackers/clover/core/compiler.hpp > > @@ -29,11 +29,15 @@ > > > > #include "pipe/p_defines.h" > > > > namespace clover { > > > > + typedef compat::pair, > > +compat::vector_ref > vector_ref_pair; > > + > > > > module compile_program_llvm(const compat::string &source, > > > > - pipe_shader_ir ir, > > - const compat::string &target, > > - const compat::string &opts, > > - compat::string &r_log); > > + const compat::vector &headers, > > + pipe_shader_ir ir, > > + const compat::string &target, > > + const compat::string &opts, > >
Re: [Mesa-dev] [PATCH 3/3] clover: add clCompile
On Wednesday, October 08, 2014 08:31:39 PM Francisco Jerez wrote: > I'm attaching a somewhat cleaned up version of this patch, does it look > OK to you? Tom, do you have any comments on the LLVM changes? It looks > good to me. I've tested the modified version you push at http://cgit.freedesktop.org/~currojerez/mesa/log/?h=clover-compile-program and it's ok > > EdB writes: > > --- > > > > src/gallium/state_trackers/clover/api/dispatch.cpp | 2 +- > > src/gallium/state_trackers/clover/api/program.cpp | 39 > > +++--- .../state_trackers/clover/core/compiler.hpp > > | 12 --- > > src/gallium/state_trackers/clover/core/error.hpp | 2 +- > > src/gallium/state_trackers/clover/core/program.cpp | 14 ++-- > > src/gallium/state_trackers/clover/core/program.hpp | 5 ++- > > .../state_trackers/clover/llvm/invocation.cpp | 39 > > ++ 7 files changed, 93 insertions(+), 20 > > deletions(-) > > > >[...] ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/3] clover: add clCompile
On Thu, Oct 09, 2014 at 09:22:46PM +0200, EdB wrote: > On Thursday, October 09, 2014 06:29:40 AM Tom Stellard wrote: > > On Sun, Sep 28, 2014 at 12:57:22PM +0200, EdB wrote: > > > --- > > > > > > src/gallium/state_trackers/clover/api/dispatch.cpp | 2 +- > > > src/gallium/state_trackers/clover/api/program.cpp | 39 > > > +++--- .../state_trackers/clover/core/compiler.hpp > > > | 12 --- > > > src/gallium/state_trackers/clover/core/error.hpp | 2 +- > > > src/gallium/state_trackers/clover/core/program.cpp | 14 ++-- > > > src/gallium/state_trackers/clover/core/program.hpp | 5 ++- > > > .../state_trackers/clover/llvm/invocation.cpp | 39 > > > ++ 7 files changed, 93 insertions(+), 20 > > > deletions(-) > > > > > > diff --git a/src/gallium/state_trackers/clover/api/dispatch.cpp > > > b/src/gallium/state_trackers/clover/api/dispatch.cpp index > > > 35d150d..b5a4094 100644 > > > --- a/src/gallium/state_trackers/clover/api/dispatch.cpp > > > +++ b/src/gallium/state_trackers/clover/api/dispatch.cpp > > > @@ -122,7 +122,7 @@ namespace clover { > > > > > >clReleaseDevice, > > >clCreateImage, > > >clCreateProgramWithBuiltInKernels, > > > > > > - NULL, // clCompileProgram > > > + clCompileProgram, > > > > > >NULL, // clLinkProgram > > >clUnloadPlatformCompiler, > > >NULL, // clGetKernelArgInfo > > > > > > diff --git a/src/gallium/state_trackers/clover/api/program.cpp > > > b/src/gallium/state_trackers/clover/api/program.cpp index > > > 6771735..33df0cd 100644 > > > --- a/src/gallium/state_trackers/clover/api/program.cpp > > > +++ b/src/gallium/state_trackers/clover/api/program.cpp > > > @@ -152,14 +152,34 @@ CLOVER_API cl_int > > > > > > clBuildProgram(cl_program d_prog, cl_uint num_devs, > > > > > > const cl_device_id *d_devs, const char *p_opts, > > > void (*pfn_notify)(cl_program, void *), > > > > > > - void *user_data) try { > > > + void *user_data) { > > > + cl_int error = clCompileProgram(d_prog, num_devs, d_devs, p_opts, > > > + 0, 0, 0, > > > + pfn_notify, user_data); > > > + return error == CL_COMPILE_PROGRAM_FAILURE ? > > > + CL_BUILD_PROGRAM_FAILURE : error; > > > +} > > > + > > > +CLOVER_API cl_int > > > +clCompileProgram(cl_program d_prog, cl_uint num_devs, > > > + const cl_device_id *d_devs, const char *p_opts, > > > + cl_uint num_headers, const cl_program *d_header_progs, > > > + const char **header_names, > > > + void (*pfn_notify)(cl_program, void *), > > > + void *user_data) try { > > > > > > 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 : ""); > > > > > > - if (bool(num_devs) != bool(d_devs) || > > > - (!pfn_notify && user_data)) > > > + if (bool(num_devs) != bool(d_devs)) > > > + throw error(CL_INVALID_VALUE); > > > + > > > + if (!pfn_notify && user_data) > > > + throw error(CL_INVALID_VALUE); > > > + > > > + if (bool(num_headers) != bool(header_names) || > > > + bool(num_headers) != bool(d_header_progs)) > > > > > >throw error(CL_INVALID_VALUE); > > > > > > if (any_of([&](const device &dev) { > > > > > > @@ -170,7 +190,18 @@ clBuildProgram(cl_program d_prog, cl_uint num_devs, > > > > > > if (prog.kernel_ref_count()) > > > > > >throw error(CL_INVALID_OPERATION); > > > > > > - prog.build(devs, opts); > > > + std::map headers; > > > + for (cl_uint i = 0; i < num_headers; ++i) { > > > + auto h_name = std::string(header_names[i]); > > > + auto &h_prog = obj(d_header_progs[i]); > > > + > > > + if (!h_prog.has_source) > > > + throw error(CL_INVALID_OPERATION); > > > + > > > + headers.insert(make_pair(h_name, h_prog.source())); > > > + } > > > + > > > + prog.build(devs, opts, headers); > > > > > > return CL_SUCCESS; > > > > > > } catch (error &e) { > > > > > > diff --git a/src/gallium/state_trackers/clover/core/compiler.hpp > > > b/src/gallium/state_trackers/clover/core/compiler.hpp index > > > 6ef84d1..c2c4063 100644 > > > --- a/src/gallium/state_trackers/clover/core/compiler.hpp > > > +++ b/src/gallium/state_trackers/clover/core/compiler.hpp > > > @@ -29,11 +29,15 @@ > > > > > > #include "pipe/p_defines.h" > > > > > > namespace clover { > > > > > > + typedef compat::pair, > > > +compat::vector_ref > vector_ref_pair; > > > + > > > > > > module compile_program_llvm(const compat::string &source, > > > > > > - pipe_shader_ir ir, > > > - const compat::string &target, > > > -
Re: [Mesa-dev] [PATCH 3/3] clover: add clCompile
On Friday 10 October 2014 10:16:08 Tom Stellard wrote: > On Thu, Oct 09, 2014 at 09:22:46PM +0200, EdB wrote: > > On Thursday, October 09, 2014 06:29:40 AM Tom Stellard wrote: > > > On Sun, Sep 28, 2014 at 12:57:22PM +0200, EdB wrote: > > > > --- > > > > > > > > src/gallium/state_trackers/clover/api/dispatch.cpp | 2 +- > > > > src/gallium/state_trackers/clover/api/program.cpp | 39 > > > > +++--- .../state_trackers/clover/core/compiler.hpp > > > > > > > > | 12 --- > > > > > > > > src/gallium/state_trackers/clover/core/error.hpp | 2 +- > > > > src/gallium/state_trackers/clover/core/program.cpp | 14 ++-- > > > > src/gallium/state_trackers/clover/core/program.hpp | 5 ++- > > > > .../state_trackers/clover/llvm/invocation.cpp | 39 > > > > ++ 7 files changed, 93 insertions(+), 20 > > > > deletions(-) > > > > > > > > diff --git a/src/gallium/state_trackers/clover/api/dispatch.cpp > > > > b/src/gallium/state_trackers/clover/api/dispatch.cpp index > > > > 35d150d..b5a4094 100644 > > > > --- a/src/gallium/state_trackers/clover/api/dispatch.cpp > > > > +++ b/src/gallium/state_trackers/clover/api/dispatch.cpp > > > > @@ -122,7 +122,7 @@ namespace clover { > > > > > > > >clReleaseDevice, > > > >clCreateImage, > > > >clCreateProgramWithBuiltInKernels, > > > > > > > > - NULL, // clCompileProgram > > > > + clCompileProgram, > > > > > > > >NULL, // clLinkProgram > > > >clUnloadPlatformCompiler, > > > >NULL, // clGetKernelArgInfo > > > > > > > > diff --git a/src/gallium/state_trackers/clover/api/program.cpp > > > > b/src/gallium/state_trackers/clover/api/program.cpp index > > > > 6771735..33df0cd 100644 > > > > --- a/src/gallium/state_trackers/clover/api/program.cpp > > > > +++ b/src/gallium/state_trackers/clover/api/program.cpp > > > > @@ -152,14 +152,34 @@ CLOVER_API cl_int > > > > > > > > clBuildProgram(cl_program d_prog, cl_uint num_devs, > > > > > > > > const cl_device_id *d_devs, const char *p_opts, > > > > void (*pfn_notify)(cl_program, void *), > > > > > > > > - void *user_data) try { > > > > + void *user_data) { > > > > + cl_int error = clCompileProgram(d_prog, num_devs, d_devs, p_opts, > > > > + 0, 0, 0, > > > > + pfn_notify, user_data); > > > > + return error == CL_COMPILE_PROGRAM_FAILURE ? > > > > + CL_BUILD_PROGRAM_FAILURE : error; > > > > +} > > > > + > > > > +CLOVER_API cl_int > > > > +clCompileProgram(cl_program d_prog, cl_uint num_devs, > > > > + const cl_device_id *d_devs, const char *p_opts, > > > > + cl_uint num_headers, const cl_program > > > > *d_header_progs, > > > > + const char **header_names, > > > > + void (*pfn_notify)(cl_program, void *), > > > > + void *user_data) try { > > > > > > > > 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 : ""); > > > > > > > > - if (bool(num_devs) != bool(d_devs) || > > > > - (!pfn_notify && user_data)) > > > > + if (bool(num_devs) != bool(d_devs)) > > > > + throw error(CL_INVALID_VALUE); > > > > + > > > > + if (!pfn_notify && user_data) > > > > + throw error(CL_INVALID_VALUE); > > > > + > > > > + if (bool(num_headers) != bool(header_names) || > > > > + bool(num_headers) != bool(d_header_progs)) > > > > > > > >throw error(CL_INVALID_VALUE); > > > > > > > > if (any_of([&](const device &dev) { > > > > > > > > @@ -170,7 +190,18 @@ clBuildProgram(cl_program d_prog, cl_uint > > > > num_devs, > > > > > > > > if (prog.kernel_ref_count()) > > > > > > > >throw error(CL_INVALID_OPERATION); > > > > > > > > - prog.build(devs, opts); > > > > + std::map headers; > > > > + for (cl_uint i = 0; i < num_headers; ++i) { > > > > + auto h_name = std::string(header_names[i]); > > > > + auto &h_prog = obj(d_header_progs[i]); > > > > + > > > > + if (!h_prog.has_source) > > > > + throw error(CL_INVALID_OPERATION); > > > > + > > > > + headers.insert(make_pair(h_name, h_prog.source())); > > > > + } > > > > + > > > > + prog.build(devs, opts, headers); > > > > > > > > return CL_SUCCESS; > > > > > > > > } catch (error &e) { > > > > > > > > diff --git a/src/gallium/state_trackers/clover/core/compiler.hpp > > > > b/src/gallium/state_trackers/clover/core/compiler.hpp index > > > > 6ef84d1..c2c4063 100644 > > > > --- a/src/gallium/state_trackers/clover/core/compiler.hpp > > > > +++ b/src/gallium/state_trackers/clover/core/compiler.hpp > > > > @@ -29,11 +29,15 @@ > > > > > > > > #include "pipe/p_defines.h" > > > > > > > > namespace clover { > > > > > > > >
Re: [Mesa-dev] [PATCH 3/3] clover: add clCompile
On Fri, Oct 10, 2014 at 07:51:40PM +0200, EdB wrote: > On Friday 10 October 2014 10:16:08 Tom Stellard wrote: > > On Thu, Oct 09, 2014 at 09:22:46PM +0200, EdB wrote: > > > On Thursday, October 09, 2014 06:29:40 AM Tom Stellard wrote: > > > > On Sun, Sep 28, 2014 at 12:57:22PM +0200, EdB wrote: > > > > > --- > > > > > > > > > > src/gallium/state_trackers/clover/api/dispatch.cpp | 2 +- > > > > > src/gallium/state_trackers/clover/api/program.cpp | 39 > > > > > +++--- .../state_trackers/clover/core/compiler.hpp > > > > > > > > > > | 12 --- > > > > > > > > > > src/gallium/state_trackers/clover/core/error.hpp | 2 +- > > > > > src/gallium/state_trackers/clover/core/program.cpp | 14 ++-- > > > > > src/gallium/state_trackers/clover/core/program.hpp | 5 ++- > > > > > .../state_trackers/clover/llvm/invocation.cpp | 39 > > > > > ++ 7 files changed, 93 insertions(+), 20 > > > > > deletions(-) > > > > > > > > > > diff --git a/src/gallium/state_trackers/clover/api/dispatch.cpp > > > > > b/src/gallium/state_trackers/clover/api/dispatch.cpp index > > > > > 35d150d..b5a4094 100644 > > > > > --- a/src/gallium/state_trackers/clover/api/dispatch.cpp > > > > > +++ b/src/gallium/state_trackers/clover/api/dispatch.cpp > > > > > @@ -122,7 +122,7 @@ namespace clover { > > > > > > > > > >clReleaseDevice, > > > > >clCreateImage, > > > > >clCreateProgramWithBuiltInKernels, > > > > > > > > > > - NULL, // clCompileProgram > > > > > + clCompileProgram, > > > > > > > > > >NULL, // clLinkProgram > > > > >clUnloadPlatformCompiler, > > > > >NULL, // clGetKernelArgInfo > > > > > > > > > > diff --git a/src/gallium/state_trackers/clover/api/program.cpp > > > > > b/src/gallium/state_trackers/clover/api/program.cpp index > > > > > 6771735..33df0cd 100644 > > > > > --- a/src/gallium/state_trackers/clover/api/program.cpp > > > > > +++ b/src/gallium/state_trackers/clover/api/program.cpp > > > > > @@ -152,14 +152,34 @@ CLOVER_API cl_int > > > > > > > > > > clBuildProgram(cl_program d_prog, cl_uint num_devs, > > > > > > > > > > const cl_device_id *d_devs, const char *p_opts, > > > > > void (*pfn_notify)(cl_program, void *), > > > > > > > > > > - void *user_data) try { > > > > > + void *user_data) { > > > > > + cl_int error = clCompileProgram(d_prog, num_devs, d_devs, p_opts, > > > > > + 0, 0, 0, > > > > > + pfn_notify, user_data); > > > > > + return error == CL_COMPILE_PROGRAM_FAILURE ? > > > > > + CL_BUILD_PROGRAM_FAILURE : error; > > > > > +} > > > > > + > > > > > +CLOVER_API cl_int > > > > > +clCompileProgram(cl_program d_prog, cl_uint num_devs, > > > > > + const cl_device_id *d_devs, const char *p_opts, > > > > > + cl_uint num_headers, const cl_program > > > > > *d_header_progs, > > > > > + const char **header_names, > > > > > + void (*pfn_notify)(cl_program, void *), > > > > > + void *user_data) try { > > > > > > > > > > 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 : ""); > > > > > > > > > > - if (bool(num_devs) != bool(d_devs) || > > > > > - (!pfn_notify && user_data)) > > > > > + if (bool(num_devs) != bool(d_devs)) > > > > > + throw error(CL_INVALID_VALUE); > > > > > + > > > > > + if (!pfn_notify && user_data) > > > > > + throw error(CL_INVALID_VALUE); > > > > > + > > > > > + if (bool(num_headers) != bool(header_names) || > > > > > + bool(num_headers) != bool(d_header_progs)) > > > > > > > > > >throw error(CL_INVALID_VALUE); > > > > > > > > > > if (any_of([&](const device &dev) { > > > > > > > > > > @@ -170,7 +190,18 @@ clBuildProgram(cl_program d_prog, cl_uint > > > > > num_devs, > > > > > > > > > > if (prog.kernel_ref_count()) > > > > > > > > > >throw error(CL_INVALID_OPERATION); > > > > > > > > > > - prog.build(devs, opts); > > > > > + std::map headers; > > > > > + for (cl_uint i = 0; i < num_headers; ++i) { > > > > > + auto h_name = std::string(header_names[i]); > > > > > + auto &h_prog = obj(d_header_progs[i]); > > > > > + > > > > > + if (!h_prog.has_source) > > > > > + throw error(CL_INVALID_OPERATION); > > > > > + > > > > > + headers.insert(make_pair(h_name, h_prog.source())); > > > > > + } > > > > > + > > > > > + prog.build(devs, opts, headers); > > > > > > > > > > return CL_SUCCESS; > > > > > > > > > > } catch (error &e) { > > > > > > > > > > diff --git a/src/gallium/state_trackers/clover/core/compiler.hpp > > > > > b/src/gallium/state_trackers/clover/core/compiler.hpp index > > > >
Re: [Mesa-dev] [PATCH 3/3] clover: add clCompile
On Friday 10 October 2014 15:45:51 Tom Stellard wrote: > On Fri, Oct 10, 2014 at 07:51:40PM +0200, EdB wrote: > > On Friday 10 October 2014 10:16:08 Tom Stellard wrote: > > > On Thu, Oct 09, 2014 at 09:22:46PM +0200, EdB wrote: > > > > On Thursday, October 09, 2014 06:29:40 AM Tom Stellard wrote: > > > > > On Sun, Sep 28, 2014 at 12:57:22PM +0200, EdB wrote: > > > > > > --- > > > > > > > > > > > > src/gallium/state_trackers/clover/api/dispatch.cpp | 2 +- > > > > > > src/gallium/state_trackers/clover/api/program.cpp | 39 > > > > > > +++--- > > > > > > .../state_trackers/clover/core/compiler.hpp > > > > > > > > > > > > | 12 --- > > > > > > > > > > > > src/gallium/state_trackers/clover/core/error.hpp | 2 +- > > > > > > src/gallium/state_trackers/clover/core/program.cpp | 14 ++-- > > > > > > src/gallium/state_trackers/clover/core/program.hpp | 5 ++- > > > > > > .../state_trackers/clover/llvm/invocation.cpp | 39 > > > > > > ++ 7 files changed, 93 insertions(+), 20 > > > > > > deletions(-) > > > > > > > > > > > > diff --git a/src/gallium/state_trackers/clover/api/dispatch.cpp > > > > > > b/src/gallium/state_trackers/clover/api/dispatch.cpp index > > > > > > 35d150d..b5a4094 100644 > > > > > > --- a/src/gallium/state_trackers/clover/api/dispatch.cpp > > > > > > +++ b/src/gallium/state_trackers/clover/api/dispatch.cpp > > > > > > @@ -122,7 +122,7 @@ namespace clover { > > > > > > > > > > > >clReleaseDevice, > > > > > >clCreateImage, > > > > > >clCreateProgramWithBuiltInKernels, > > > > > > > > > > > > - NULL, // clCompileProgram > > > > > > + clCompileProgram, > > > > > > > > > > > >NULL, // clLinkProgram > > > > > >clUnloadPlatformCompiler, > > > > > >NULL, // clGetKernelArgInfo > > > > > > > > > > > > diff --git a/src/gallium/state_trackers/clover/api/program.cpp > > > > > > b/src/gallium/state_trackers/clover/api/program.cpp index > > > > > > 6771735..33df0cd 100644 > > > > > > --- a/src/gallium/state_trackers/clover/api/program.cpp > > > > > > +++ b/src/gallium/state_trackers/clover/api/program.cpp > > > > > > @@ -152,14 +152,34 @@ CLOVER_API cl_int > > > > > > > > > > > > clBuildProgram(cl_program d_prog, cl_uint num_devs, > > > > > > > > > > > > const cl_device_id *d_devs, const char *p_opts, > > > > > > void (*pfn_notify)(cl_program, void *), > > > > > > > > > > > > - void *user_data) try { > > > > > > + void *user_data) { > > > > > > + cl_int error = clCompileProgram(d_prog, num_devs, d_devs, > > > > > > p_opts, > > > > > > + 0, 0, 0, > > > > > > + pfn_notify, user_data); > > > > > > + return error == CL_COMPILE_PROGRAM_FAILURE ? > > > > > > + CL_BUILD_PROGRAM_FAILURE : error; > > > > > > +} > > > > > > + > > > > > > +CLOVER_API cl_int > > > > > > +clCompileProgram(cl_program d_prog, cl_uint num_devs, > > > > > > + const cl_device_id *d_devs, const char *p_opts, > > > > > > + cl_uint num_headers, const cl_program > > > > > > *d_header_progs, > > > > > > + const char **header_names, > > > > > > + void (*pfn_notify)(cl_program, void *), > > > > > > + void *user_data) try { > > > > > > > > > > > > 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 : ""); > > > > > > > > > > > > - if (bool(num_devs) != bool(d_devs) || > > > > > > - (!pfn_notify && user_data)) > > > > > > + if (bool(num_devs) != bool(d_devs)) > > > > > > + throw error(CL_INVALID_VALUE); > > > > > > + > > > > > > + if (!pfn_notify && user_data) > > > > > > + throw error(CL_INVALID_VALUE); > > > > > > + > > > > > > + if (bool(num_headers) != bool(header_names) || > > > > > > + bool(num_headers) != bool(d_header_progs)) > > > > > > > > > > > >throw error(CL_INVALID_VALUE); > > > > > > > > > > > > if (any_of([&](const device &dev) { > > > > > > > > > > > > @@ -170,7 +190,18 @@ clBuildProgram(cl_program d_prog, cl_uint > > > > > > num_devs, > > > > > > > > > > > > if (prog.kernel_ref_count()) > > > > > > > > > > > >throw error(CL_INVALID_OPERATION); > > > > > > > > > > > > - prog.build(devs, opts); > > > > > > + std::map headers; > > > > > > + for (cl_uint i = 0; i < num_headers; ++i) { > > > > > > + auto h_name = std::string(header_names[i]); > > > > > > + auto &h_prog = obj(d_header_progs[i]); > > > > > > + > > > > > > + if (!h_prog.has_source) > > > > > > + throw error(CL_INVALID_OPERATION); > > > > > > + > > > > > > + headers.insert(make_pair(h_name, h_prog.source())); > > > > > > + } > > > > > > +
Re: [Mesa-dev] [PATCH 3/3] clover: add clCompile
Sorry, I didn't test it enought. It needs the two following patch in order to work ok EdB (2): clover: add allow_empty_tag clover: don't return CL_INVALID_VALUE if there is no header src/gallium/state_trackers/clover/api/program.cpp | 2 +- src/gallium/state_trackers/clover/core/object.hpp | 18 ++ 2 files changed, 19 insertions(+), 1 deletion(-) -- 1.9.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/3] clover: add clCompile
EdB writes: > Sorry, I didn't test it enought. > It needs the two following patch in order to work ok > > EdB (2): > clover: add allow_empty_tag > clover: don't return CL_INVALID_VALUE if there is no header > These look good, Reviewed-by: Francisco Jerez > src/gallium/state_trackers/clover/api/program.cpp | 2 +- > src/gallium/state_trackers/clover/core/object.hpp | 18 ++ > 2 files changed, 19 insertions(+), 1 deletion(-) > > -- > 1.9.3 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev pgpXVsEmiZGg6.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/3] clover: add clCompile
Francisco Jerez writes: > EdB writes: > >> Sorry, I didn't test it enought. >> It needs the two following patch in order to work ok >> >> EdB (2): >> clover: add allow_empty_tag >> clover: don't return CL_INVALID_VALUE if there is no header >> > > These look good, > Reviewed-by: Francisco Jerez I've pushed the whole clCompileProgram series. Thanks! > >> src/gallium/state_trackers/clover/api/program.cpp | 2 +- >> src/gallium/state_trackers/clover/core/object.hpp | 18 ++ >> 2 files changed, 19 insertions(+), 1 deletion(-) >> >> -- >> 1.9.3 >> >> ___ >> mesa-dev mailing list >> mesa-dev@lists.freedesktop.org >> http://lists.freedesktop.org/mailman/listinfo/mesa-dev pgpDSlFhhdGeT.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/3] clover: add clCompile
Le 2014-10-20 09:42, Francisco Jerez a écrit : Francisco Jerez writes: EdB writes: Sorry, I didn't test it enought. It needs the two following patch in order to work ok EdB (2): clover: add allow_empty_tag clover: don't return CL_INVALID_VALUE if there is no header These look good, Reviewed-by: Francisco Jerez I've pushed the whole clCompileProgram series. Thanks! Thanks, Tom ask me to try another method in order to avoid using the fake headers path. However, I'm not at home for the moment, anyway this one is ok, but I'll try to send a new path. src/gallium/state_trackers/clover/api/program.cpp | 2 +- src/gallium/state_trackers/clover/core/object.hpp | 18 ++ 2 files changed, 19 insertions(+), 1 deletion(-) -- 1.9.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/3] clover: add clCompile
I'm attaching a somewhat cleaned up version of this patch, does it look OK to you? Tom, do you have any comments on the LLVM changes? It looks good to me. EdB writes: > --- > src/gallium/state_trackers/clover/api/dispatch.cpp | 2 +- > src/gallium/state_trackers/clover/api/program.cpp | 39 > +++--- > .../state_trackers/clover/core/compiler.hpp| 12 --- > src/gallium/state_trackers/clover/core/error.hpp | 2 +- > src/gallium/state_trackers/clover/core/program.cpp | 14 ++-- > src/gallium/state_trackers/clover/core/program.hpp | 5 ++- > .../state_trackers/clover/llvm/invocation.cpp | 39 > ++ > 7 files changed, 93 insertions(+), 20 deletions(-) >[...] From 22fb191b64841a95578542bf9023710dff31e40d Mon Sep 17 00:00:00 2001 From: EdB Date: Wed, 8 Oct 2014 20:06:17 +0300 Subject: [PATCH] clover: Add initial implementation of clCompileProgram for CL 1.2. [ Francisco Jerez: General clean-up. ] Reviewed-by: Francisco Jerez --- src/gallium/state_trackers/clover/api/dispatch.cpp | 2 +- src/gallium/state_trackers/clover/api/program.cpp | 35 +++--- .../state_trackers/clover/core/compiler.hpp| 4 +++ src/gallium/state_trackers/clover/core/error.hpp | 2 +- src/gallium/state_trackers/clover/core/program.cpp | 7 +++-- src/gallium/state_trackers/clover/core/program.hpp | 4 ++- .../state_trackers/clover/llvm/invocation.cpp | 29 -- 7 files changed, 71 insertions(+), 12 deletions(-) diff --git a/src/gallium/state_trackers/clover/api/dispatch.cpp b/src/gallium/state_trackers/clover/api/dispatch.cpp index 35d150d..b5a4094 100644 --- a/src/gallium/state_trackers/clover/api/dispatch.cpp +++ b/src/gallium/state_trackers/clover/api/dispatch.cpp @@ -122,7 +122,7 @@ namespace clover { clReleaseDevice, clCreateImage, clCreateProgramWithBuiltInKernels, - NULL, // clCompileProgram + clCompileProgram, NULL, // clLinkProgram clUnloadPlatformCompiler, NULL, // clGetKernelArgInfo diff --git a/src/gallium/state_trackers/clover/api/program.cpp b/src/gallium/state_trackers/clover/api/program.cpp index 6771735..c6bf439 100644 --- a/src/gallium/state_trackers/clover/api/program.cpp +++ b/src/gallium/state_trackers/clover/api/program.cpp @@ -152,14 +152,30 @@ CLOVER_API cl_int clBuildProgram(cl_program d_prog, cl_uint num_devs, const cl_device_id *d_devs, const char *p_opts, void (*pfn_notify)(cl_program, void *), - void *user_data) try { + void *user_data) { + cl_int ret = clCompileProgram(d_prog, num_devs, d_devs, p_opts, + 0, NULL, NULL, pfn_notify, user_data); + + return (ret == CL_COMPILE_PROGRAM_FAILURE ? + CL_BUILD_PROGRAM_FAILURE : ret); +} + +CLOVER_API cl_int +clCompileProgram(cl_program d_prog, cl_uint num_devs, + const cl_device_id *d_devs, const char *p_opts, + cl_uint num_headers, const cl_program *d_header_progs, + const char **header_names, + void (*pfn_notify)(cl_program, void *), + void *user_data) try { 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 : ""); if (bool(num_devs) != bool(d_devs) || - (!pfn_notify && user_data)) + (!pfn_notify && user_data) || + bool(num_headers) != bool(header_names) || + bool(num_headers) != bool(d_header_progs)) throw error(CL_INVALID_VALUE); if (any_of([&](const device &dev) { @@ -167,10 +183,21 @@ clBuildProgram(cl_program d_prog, cl_uint num_devs, }, devs)) throw error(CL_INVALID_DEVICE); - if (prog.kernel_ref_count()) + if (prog.kernel_ref_count() || + !prog.has_source) throw error(CL_INVALID_OPERATION); - prog.build(devs, opts); + const header_map headers = map([](const char *name, const program &header) { + if (!header.has_source) +throw error(CL_INVALID_OPERATION); + + return compat::pair( +name, header.source()); + }, + range(header_names, num_headers), + objs(d_header_progs, num_headers)); + + prog.build(devs, opts, headers); return CL_SUCCESS; } catch (error &e) { diff --git a/src/gallium/state_trackers/clover/core/compiler.hpp b/src/gallium/state_trackers/clover/core/compiler.hpp index 6ef84d1..7210d1e 100644 --- a/src/gallium/state_trackers/clover/core/compiler.hpp +++ b/src/gallium/state_trackers/clover/core/compiler.hpp @@ -29,7 +29,11 @@ #include "pipe/p_defines.h" namespace clover { + typedef compat::vector > header_map; + module compile_program_llvm(const compat::string &source, + const header_map &headers, pipe_shader_ir ir, const compat::s