From 809af697e1c1e637d04e3d7f8f31f263ed86d618 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Mon, 24 Feb 2020 22:18:33 -0800 Subject: [PATCH 01/32] [SYCL] fix the enum variable conflict with user define [CORC-7433] Enum variables were too commonly used by users. This kind of conflicts cannot be avoided 100%, but we can minimize the chance by using the prefix SYCL_ Signed-off-by: Byoungro So --- sycl/include/CL/sycl/detail/scheduler/commands.hpp | 4 ++-- sycl/source/detail/scheduler/commands.cpp | 4 ++-- sycl/source/detail/scheduler/graph_processor.cpp | 6 +++--- sycl/source/detail/scheduler/scheduler.cpp | 14 +++++++------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/sycl/include/CL/sycl/detail/scheduler/commands.hpp b/sycl/include/CL/sycl/detail/scheduler/commands.hpp index 016816615560e..e251001c96742 100644 --- a/sycl/include/CL/sycl/detail/scheduler/commands.hpp +++ b/sycl/include/CL/sycl/detail/scheduler/commands.hpp @@ -38,8 +38,8 @@ enum BlockingT { NON_BLOCKING = 0, BLOCKING }; // The struct represents the result of command enqueueing struct EnqueueResultT { - enum ResultT { SUCCESS, BLOCKED, FAILED }; - EnqueueResultT(ResultT Result = SUCCESS, Command *Cmd = nullptr, + enum ResultT { SYCL_SUCCESS, SYCL_BLOCKED, SYCL_FAILED }; + EnqueueResultT(ResultT Result = SYCL_SUCCESS, Command *Cmd = nullptr, cl_int ErrCode = CL_SUCCESS) : MResult(Result), MCmd(Cmd), MErrCode(ErrCode) {} // Indicates result of enqueueing diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index 6e1b8d246364b..67b49632c585a 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -172,7 +172,7 @@ bool Command::enqueue(EnqueueResultT &EnqueueResult, BlockingT Blocking) { if (MIsBlockable && !MCanEnqueue) { // Exit if enqueue type is not blocking if (!Blocking) { - EnqueueResult = EnqueueResultT(EnqueueResultT::BLOCKED, this); + EnqueueResult = EnqueueResultT(EnqueueResultT::SYCL_BLOCKED, this); return false; } static bool ThrowOnBlock = getenv("SYCL_THROW_ON_BLOCK") != nullptr; @@ -196,7 +196,7 @@ bool Command::enqueue(EnqueueResultT &EnqueueResult, BlockingT Blocking) { cl_int Res = enqueueImp(); if (CL_SUCCESS != Res) - EnqueueResult = EnqueueResultT(EnqueueResultT::FAILED, this, Res); + EnqueueResult = EnqueueResultT(EnqueueResultT::SYCL_FAILED, this, Res); else // Consider the command is successfully enqueued if return code is // CL_SUCCESS diff --git a/sycl/source/detail/scheduler/graph_processor.cpp b/sycl/source/detail/scheduler/graph_processor.cpp index e9ccb51f2b57c..422e4f67b437c 100644 --- a/sycl/source/detail/scheduler/graph_processor.cpp +++ b/sycl/source/detail/scheduler/graph_processor.cpp @@ -41,7 +41,7 @@ void Scheduler::GraphProcessor::waitForEvent(EventImplPtr Event) { assert(Cmd && "Event has no associated command?"); EnqueueResultT Res; bool Enqueued = enqueueCommand(Cmd, Res, BLOCKING); - if (!Enqueued && EnqueueResultT::FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SYCL_FAILED == Res.MResult) // TODO: Reschedule commands. throw runtime_error("Enqueue process failed."); @@ -66,12 +66,12 @@ bool Scheduler::GraphProcessor::enqueueCommand(Command *Cmd, enqueueCommand(Dep.MDepCommand, EnqueueResult, Blocking); if (!Enqueued) switch (EnqueueResult.MResult) { - case EnqueueResultT::FAILED: + case EnqueueResultT::SYCL_FAILED: default: // Exit immediately if a command fails to avoid enqueueing commands // result of which will be discarded. return false; - case EnqueueResultT::BLOCKED: + case EnqueueResultT::SYCL_BLOCKED: // If some dependency is blocked from enqueueing remember that, but // try to enqueue other dependencies(that can be ready for // enqueueing). diff --git a/sycl/source/detail/scheduler/scheduler.cpp b/sycl/source/detail/scheduler/scheduler.cpp index b4f8c3af47174..613fca99c32c4 100644 --- a/sycl/source/detail/scheduler/scheduler.cpp +++ b/sycl/source/detail/scheduler/scheduler.cpp @@ -24,14 +24,14 @@ void Scheduler::waitForRecordToFinish(MemObjRecord *Record) { for (Command *Cmd : Record->MReadLeaves) { EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(Cmd, Res); - if (!Enqueued && EnqueueResultT::FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SYCL_FAILED == Res.MResult) throw runtime_error("Enqueue process failed."); GraphProcessor::waitForEvent(Cmd->getEvent()); } for (Command *Cmd : Record->MWriteLeaves) { EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(Cmd, Res); - if (!Enqueued && EnqueueResultT::FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SYCL_FAILED == Res.MResult) throw runtime_error("Enqueue process failed."); GraphProcessor::waitForEvent(Cmd->getEvent()); } @@ -39,7 +39,7 @@ void Scheduler::waitForRecordToFinish(MemObjRecord *Record) { Command *ReleaseCmd = AllocaCmd->getReleaseCmd(); EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(ReleaseCmd, Res); - if (!Enqueued && EnqueueResultT::FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SYCL_FAILED == Res.MResult) throw runtime_error("Enqueue process failed."); GraphProcessor::waitForEvent(ReleaseCmd->getEvent()); } @@ -64,7 +64,7 @@ EventImplPtr Scheduler::addCG(std::unique_ptr CommandGroup, // TODO: Check if lazy mode. EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(NewCmd, Res); - if (!Enqueued && EnqueueResultT::FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SYCL_FAILED == Res.MResult) throw runtime_error("Enqueue process failed."); } @@ -85,7 +85,7 @@ EventImplPtr Scheduler::addCopyBack(Requirement *Req) { try { EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(NewCmd, Res); - if (!Enqueued && EnqueueResultT::FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SYCL_FAILED == Res.MResult) throw runtime_error("Enqueue process failed."); } catch (...) { NewCmd->getQueue()->reportAsyncException(std::current_exception()); @@ -144,7 +144,7 @@ EventImplPtr Scheduler::addHostAccessor(Requirement *Req) { return nullptr; EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(NewCmd, Res); - if (!Enqueued && EnqueueResultT::FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SYCL_FAILED == Res.MResult) throw runtime_error("Enqueue process failed."); return NewCmd->getEvent(); } @@ -156,7 +156,7 @@ void Scheduler::releaseHostAccessor(Requirement *Req) { for (Command *Cmd : Leaves) { EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(Cmd, Res); - if (!Enqueued && EnqueueResultT::FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SYCL_FAILED == Res.MResult) throw runtime_error("Enqueue process failed."); } }; From 4862f8bfbbfe1c8a0937b1881147765cbe640b0b Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Tue, 25 Feb 2020 15:59:01 -0800 Subject: [PATCH 02/32] [SYCL] added a regression test for macro conflict Signed-off-by: Byoungro So --- sycl/test/regression/macro_conflict.cpp | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 sycl/test/regression/macro_conflict.cpp diff --git a/sycl/test/regression/macro_conflict.cpp b/sycl/test/regression/macro_conflict.cpp new file mode 100644 index 0000000000000..0772901cfb356 --- /dev/null +++ b/sycl/test/regression/macro_conflict.cpp @@ -0,0 +1,26 @@ +// RUN: %clangxx -fsycl %s -o %t.out +// RUN: %ACC_RUN_PLACEHOLDER %t.out + +// expected-no-diagnostics +// +//==-------------- macro_conflict.cpp --------------------------------------==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// This test checks if the user-defined macros SUCCESS, FAIL, BLOCKED are +// defined in global namespace by sycl.hpp +//===----------------------------------------------------------------------===// + +#define SUCCESS 0 +#define FAIL 1 +#define BLOCKED 2 + +#include + +int main() { + printf("hello world!\n"); + return 0; +} From 11ad1edced66009ab4701105a7bc67e1e9c67fbd Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Tue, 25 Feb 2020 18:07:56 -0800 Subject: [PATCH 03/32] fixed the clang format check issue Signed-off-by: Byoungro So --- sycl/test/regression/macro_conflict.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sycl/test/regression/macro_conflict.cpp b/sycl/test/regression/macro_conflict.cpp index 0772901cfb356..7a7de8614687c 100644 --- a/sycl/test/regression/macro_conflict.cpp +++ b/sycl/test/regression/macro_conflict.cpp @@ -1,6 +1,5 @@ -// RUN: %clangxx -fsycl %s -o %t.out +// RUN: %clangxx -fsycl %s -o %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out - // expected-no-diagnostics // //==-------------- macro_conflict.cpp --------------------------------------==// From 2a61c01cadfb14a25ff378b4d7b0d31da7dfc883 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Wed, 26 Feb 2020 08:25:24 -0800 Subject: [PATCH 04/32] fixed regression test compiler option Signed-off-by: Byoungro So --- sycl/test/regression/macro_conflict.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/sycl/test/regression/macro_conflict.cpp b/sycl/test/regression/macro_conflict.cpp index 7a7de8614687c..080bb215f8d86 100644 --- a/sycl/test/regression/macro_conflict.cpp +++ b/sycl/test/regression/macro_conflict.cpp @@ -1,13 +1,6 @@ -// RUN: %clangxx -fsycl %s -o %t.out -// RUN: %ACC_RUN_PLACEHOLDER %t.out +// RUN: %clangxx -fsyntax-only -Xjclang -verify %s -o %t.out // expected-no-diagnostics // -//==-------------- macro_conflict.cpp --------------------------------------==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// //===----------------------------------------------------------------------===// // This test checks if the user-defined macros SUCCESS, FAIL, BLOCKED are // defined in global namespace by sycl.hpp From 6dec0f210a596530b9a0456480f57a8a1a7eb596 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Wed, 26 Feb 2020 08:33:08 -0800 Subject: [PATCH 05/32] fixed a typo Signed-off-by: Byoungro So --- sycl/test/regression/macro_conflict.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/test/regression/macro_conflict.cpp b/sycl/test/regression/macro_conflict.cpp index 080bb215f8d86..eefeab08b8ca9 100644 --- a/sycl/test/regression/macro_conflict.cpp +++ b/sycl/test/regression/macro_conflict.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsyntax-only -Xjclang -verify %s -o %t.out +// RUN: %clangxx -fsyntax-only -Xclang -verify %s -o %t.out // expected-no-diagnostics // //===----------------------------------------------------------------------===// From 4fc8330a67cbbd1d37b460063d2cf6f756a17ae7 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Wed, 26 Feb 2020 14:39:06 -0800 Subject: [PATCH 06/32] Update sycl/source/detail/scheduler/commands.hpp Signed-off-by : Byoungro So Co-Authored-By: Alexey Bader --- sycl/source/detail/scheduler/commands.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/source/detail/scheduler/commands.hpp b/sycl/source/detail/scheduler/commands.hpp index d713b75cabbc8..0950ec1f5354a 100644 --- a/sycl/source/detail/scheduler/commands.hpp +++ b/sycl/source/detail/scheduler/commands.hpp @@ -38,7 +38,7 @@ enum BlockingT { NON_BLOCKING = 0, BLOCKING }; // The struct represents the result of command enqueueing struct EnqueueResultT { - enum ResultT { SYCL_SUCCESS, SYCL_BLOCKED, SYCL_FAILED }; + enum ResultT { SYCL_ENQUEUE_SUCCESS, SYCL_ENQUEUE_BLOCKED, SYCL_ENQUEUE_FAILED }; EnqueueResultT(ResultT Result = SYCL_SUCCESS, Command *Cmd = nullptr, cl_int ErrCode = CL_SUCCESS) : MResult(Result), MCmd(Cmd), MErrCode(ErrCode) {} From 85d75cf5ae7af29b246e48fd235e5eb4f41bee9a Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Wed, 26 Feb 2020 14:39:25 -0800 Subject: [PATCH 07/32] Update sycl/test/regression/macro_conflict.cpp Signed-off-by: Byoungro So Co-Authored-By: Alexey Bader --- sycl/test/regression/macro_conflict.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/test/regression/macro_conflict.cpp b/sycl/test/regression/macro_conflict.cpp index eefeab08b8ca9..2c7435e48e3be 100644 --- a/sycl/test/regression/macro_conflict.cpp +++ b/sycl/test/regression/macro_conflict.cpp @@ -3,7 +3,7 @@ // //===----------------------------------------------------------------------===// // This test checks if the user-defined macros SUCCESS, FAIL, BLOCKED are -// defined in global namespace by sycl.hpp +// conflicting with the symbols defined in SYCL header files. //===----------------------------------------------------------------------===// #define SUCCESS 0 From 50d283b48ef0f31569bccc4fecf382b362780b99 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Wed, 26 Feb 2020 15:43:09 -0800 Subject: [PATCH 08/32] changed the enum variable per Alexey's request Signed-off-by: Byoungro So --- sycl/source/detail/scheduler/commands.cpp | 4 ++-- sycl/source/detail/scheduler/commands.hpp | 2 +- sycl/source/detail/scheduler/graph_processor.cpp | 6 +++--- sycl/source/detail/scheduler/scheduler.cpp | 14 +++++++------- sycl/test/regression/macro_conflict.cpp | 2 -- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index b1969542fa2e9..d28ba6a2b2d00 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -172,7 +172,7 @@ bool Command::enqueue(EnqueueResultT &EnqueueResult, BlockingT Blocking) { if (MIsBlockable && !MCanEnqueue) { // Exit if enqueue type is not blocking if (!Blocking) { - EnqueueResult = EnqueueResultT(EnqueueResultT::SYCL_BLOCKED, this); + EnqueueResult = EnqueueResultT(EnqueueResultT::SYCL_ENQUEUE_BLOCKED, this); return false; } static bool ThrowOnBlock = getenv("SYCL_THROW_ON_BLOCK") != nullptr; @@ -196,7 +196,7 @@ bool Command::enqueue(EnqueueResultT &EnqueueResult, BlockingT Blocking) { cl_int Res = enqueueImp(); if (CL_SUCCESS != Res) - EnqueueResult = EnqueueResultT(EnqueueResultT::SYCL_FAILED, this, Res); + EnqueueResult = EnqueueResultT(EnqueueResultT::SYCL_ENQUEUE_FAILED, this, Res); else // Consider the command is successfully enqueued if return code is // CL_SUCCESS diff --git a/sycl/source/detail/scheduler/commands.hpp b/sycl/source/detail/scheduler/commands.hpp index 0950ec1f5354a..3056b82e22832 100644 --- a/sycl/source/detail/scheduler/commands.hpp +++ b/sycl/source/detail/scheduler/commands.hpp @@ -39,7 +39,7 @@ enum BlockingT { NON_BLOCKING = 0, BLOCKING }; // The struct represents the result of command enqueueing struct EnqueueResultT { enum ResultT { SYCL_ENQUEUE_SUCCESS, SYCL_ENQUEUE_BLOCKED, SYCL_ENQUEUE_FAILED }; - EnqueueResultT(ResultT Result = SYCL_SUCCESS, Command *Cmd = nullptr, + EnqueueResultT(ResultT Result = SYCL_ENQUEUE_SUCCESS, Command *Cmd = nullptr, cl_int ErrCode = CL_SUCCESS) : MResult(Result), MCmd(Cmd), MErrCode(ErrCode) {} // Indicates result of enqueueing diff --git a/sycl/source/detail/scheduler/graph_processor.cpp b/sycl/source/detail/scheduler/graph_processor.cpp index 5e7b5729943be..031828e6c21f1 100644 --- a/sycl/source/detail/scheduler/graph_processor.cpp +++ b/sycl/source/detail/scheduler/graph_processor.cpp @@ -41,7 +41,7 @@ void Scheduler::GraphProcessor::waitForEvent(EventImplPtr Event) { assert(Cmd && "Event has no associated command?"); EnqueueResultT Res; bool Enqueued = enqueueCommand(Cmd, Res, BLOCKING); - if (!Enqueued && EnqueueResultT::SYCL_FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SYCL_ENQUEUE_FAILED == Res.MResult) // TODO: Reschedule commands. throw runtime_error("Enqueue process failed."); @@ -66,12 +66,12 @@ bool Scheduler::GraphProcessor::enqueueCommand(Command *Cmd, enqueueCommand(Dep.MDepCommand, EnqueueResult, Blocking); if (!Enqueued) switch (EnqueueResult.MResult) { - case EnqueueResultT::SYCL_FAILED: + case EnqueueResultT::SYCL_ENQUEUE_FAILED: default: // Exit immediately if a command fails to avoid enqueueing commands // result of which will be discarded. return false; - case EnqueueResultT::SYCL_BLOCKED: + case EnqueueResultT::SYCL_ENQUEUE_BLOCKED: // If some dependency is blocked from enqueueing remember that, but // try to enqueue other dependencies(that can be ready for // enqueueing). diff --git a/sycl/source/detail/scheduler/scheduler.cpp b/sycl/source/detail/scheduler/scheduler.cpp index 65b3e8152c33e..5ac580bd5d921 100644 --- a/sycl/source/detail/scheduler/scheduler.cpp +++ b/sycl/source/detail/scheduler/scheduler.cpp @@ -30,14 +30,14 @@ void Scheduler::waitForRecordToFinish(MemObjRecord *Record) { for (Command *Cmd : Record->MReadLeaves) { EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(Cmd, Res); - if (!Enqueued && EnqueueResultT::SYCL_FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SYCL_ENQUEUE_FAILED == Res.MResult) throw runtime_error("Enqueue process failed."); GraphProcessor::waitForEvent(Cmd->getEvent()); } for (Command *Cmd : Record->MWriteLeaves) { EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(Cmd, Res); - if (!Enqueued && EnqueueResultT::SYCL_FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SYCL_ENQUEUE_FAILED == Res.MResult) throw runtime_error("Enqueue process failed."); GraphProcessor::waitForEvent(Cmd->getEvent()); } @@ -45,7 +45,7 @@ void Scheduler::waitForRecordToFinish(MemObjRecord *Record) { Command *ReleaseCmd = AllocaCmd->getReleaseCmd(); EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(ReleaseCmd, Res); - if (!Enqueued && EnqueueResultT::SYCL_FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SYCL_ENQUEUE_FAILED == Res.MResult) throw runtime_error("Enqueue process failed."); GraphProcessor::waitForEvent(ReleaseCmd->getEvent()); } @@ -70,7 +70,7 @@ EventImplPtr Scheduler::addCG(std::unique_ptr CommandGroup, // TODO: Check if lazy mode. EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(NewCmd, Res); - if (!Enqueued && EnqueueResultT::SYCL_FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SYCL_ENQUEUE_FAILED == Res.MResult) throw runtime_error("Enqueue process failed."); } @@ -91,7 +91,7 @@ EventImplPtr Scheduler::addCopyBack(Requirement *Req) { try { EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(NewCmd, Res); - if (!Enqueued && EnqueueResultT::SYCL_FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SYCL_ENQUEUE_FAILED == Res.MResult) throw runtime_error("Enqueue process failed."); } catch (...) { NewCmd->getQueue()->reportAsyncException(std::current_exception()); @@ -151,7 +151,7 @@ EventImplPtr Scheduler::addHostAccessor(Requirement *Req, return nullptr; EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(NewCmd, Res); - if (!Enqueued && EnqueueResultT::SYCL_FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SYCL_ENQUEUE_FAILED == Res.MResult) throw runtime_error("Enqueue process failed."); return NewCmd->getEvent(); } @@ -163,7 +163,7 @@ void Scheduler::releaseHostAccessor(Requirement *Req) { for (Command *Cmd : Leaves) { EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(Cmd, Res); - if (!Enqueued && EnqueueResultT::SYCL_FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SYCL_ENQUEUE_FAILED == Res.MResult) throw runtime_error("Enqueue process failed."); } }; diff --git a/sycl/test/regression/macro_conflict.cpp b/sycl/test/regression/macro_conflict.cpp index 2c7435e48e3be..b9785031f4ad8 100644 --- a/sycl/test/regression/macro_conflict.cpp +++ b/sycl/test/regression/macro_conflict.cpp @@ -7,8 +7,6 @@ //===----------------------------------------------------------------------===// #define SUCCESS 0 -#define FAIL 1 -#define BLOCKED 2 #include From 8414e8b203ca688b6d7e38a72e1f1681b8d975a1 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Wed, 26 Feb 2020 15:52:58 -0800 Subject: [PATCH 09/32] fixed clang-format error Signed-off-by: Byoungro So --- sycl/source/detail/scheduler/commands.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index d28ba6a2b2d00..746dc75e6e8eb 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -172,7 +172,8 @@ bool Command::enqueue(EnqueueResultT &EnqueueResult, BlockingT Blocking) { if (MIsBlockable && !MCanEnqueue) { // Exit if enqueue type is not blocking if (!Blocking) { - EnqueueResult = EnqueueResultT(EnqueueResultT::SYCL_ENQUEUE_BLOCKED, this); + EnqueueResult = + EnqueueResultT(EnqueueResultT::SYCL_ENQUEUE_BLOCKED, this); return false; } static bool ThrowOnBlock = getenv("SYCL_THROW_ON_BLOCK") != nullptr; @@ -196,7 +197,8 @@ bool Command::enqueue(EnqueueResultT &EnqueueResult, BlockingT Blocking) { cl_int Res = enqueueImp(); if (CL_SUCCESS != Res) - EnqueueResult = EnqueueResultT(EnqueueResultT::SYCL_ENQUEUE_FAILED, this, Res); + EnqueueResult = + EnqueueResultT(EnqueueResultT::SYCL_ENQUEUE_FAILED, this, Res); else // Consider the command is successfully enqueued if return code is // CL_SUCCESS From c93c0f852df61c9dc4663dcb654d8a6e50895e8b Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Wed, 26 Feb 2020 16:01:27 -0800 Subject: [PATCH 10/32] second attempt to fix the format error Signed-off-by: Byoungro So --- sycl/source/detail/scheduler/commands.cpp | 2 +- sycl/source/detail/scheduler/commands.hpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index 746dc75e6e8eb..9e3bd96a4fbff 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -173,7 +173,7 @@ bool Command::enqueue(EnqueueResultT &EnqueueResult, BlockingT Blocking) { // Exit if enqueue type is not blocking if (!Blocking) { EnqueueResult = - EnqueueResultT(EnqueueResultT::SYCL_ENQUEUE_BLOCKED, this); + EnqueueResultT(EnqueueResultT::SYCL_ENQUEUE_BLOCKED, this); return false; } static bool ThrowOnBlock = getenv("SYCL_THROW_ON_BLOCK") != nullptr; diff --git a/sycl/source/detail/scheduler/commands.hpp b/sycl/source/detail/scheduler/commands.hpp index 3056b82e22832..05f46e135744b 100644 --- a/sycl/source/detail/scheduler/commands.hpp +++ b/sycl/source/detail/scheduler/commands.hpp @@ -38,7 +38,11 @@ enum BlockingT { NON_BLOCKING = 0, BLOCKING }; // The struct represents the result of command enqueueing struct EnqueueResultT { - enum ResultT { SYCL_ENQUEUE_SUCCESS, SYCL_ENQUEUE_BLOCKED, SYCL_ENQUEUE_FAILED }; + enum ResultT { + SYCL_ENQUEUE_SUCCESS, + SYCL_ENQUEUE_BLOCKED, + SYCL_ENQUEUE_FAILED + }; EnqueueResultT(ResultT Result = SYCL_ENQUEUE_SUCCESS, Command *Cmd = nullptr, cl_int ErrCode = CL_SUCCESS) : MResult(Result), MCmd(Cmd), MErrCode(ErrCode) {} From 45d6f9993f91f01da92e7e9079f259ff457e7c1a Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Thu, 27 Feb 2020 13:04:29 -0800 Subject: [PATCH 11/32] removed main() to avoid runtime check per reviewer's request Signed-off-by: Byoungro So --- sycl/test/regression/macro_conflict.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/sycl/test/regression/macro_conflict.cpp b/sycl/test/regression/macro_conflict.cpp index b9785031f4ad8..0de9441709ef7 100644 --- a/sycl/test/regression/macro_conflict.cpp +++ b/sycl/test/regression/macro_conflict.cpp @@ -2,15 +2,11 @@ // expected-no-diagnostics // //===----------------------------------------------------------------------===// -// This test checks if the user-defined macros SUCCESS, FAIL, BLOCKED are +// This test checks if the user-defined macros SUCCESS is // conflicting with the symbols defined in SYCL header files. +// This test only checks compilation errorr, so the main function is omitted. //===----------------------------------------------------------------------===// #define SUCCESS 0 #include - -int main() { - printf("hello world!\n"); - return 0; -} From 5eda19056965363979cbf39f5b4c2bf37ac52020 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Fri, 28 Feb 2020 12:25:30 -0800 Subject: [PATCH 12/32] fixed a typo. Signed-off-by: Byoungro So --- sycl/test/regression/macro_conflict.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/test/regression/macro_conflict.cpp b/sycl/test/regression/macro_conflict.cpp index 0de9441709ef7..6e20ab56ded58 100644 --- a/sycl/test/regression/macro_conflict.cpp +++ b/sycl/test/regression/macro_conflict.cpp @@ -4,7 +4,7 @@ //===----------------------------------------------------------------------===// // This test checks if the user-defined macros SUCCESS is // conflicting with the symbols defined in SYCL header files. -// This test only checks compilation errorr, so the main function is omitted. +// This test only checks compilation error, so the main function is omitted. //===----------------------------------------------------------------------===// #define SUCCESS 0 From 65bccf4791eccc9db54e87ff6e3a92eeb015be00 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Fri, 28 Feb 2020 16:39:30 -0800 Subject: [PATCH 13/32] changed enum variables to conform to guideline Signed-off-by: Byoungro So --- sycl/source/detail/scheduler/commands.cpp | 4 ++-- sycl/source/detail/scheduler/commands.hpp | 8 ++++---- sycl/source/detail/scheduler/graph_processor.cpp | 6 +++--- sycl/source/detail/scheduler/scheduler.cpp | 14 +++++++------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index 9e3bd96a4fbff..4b5ef6c7ac7a4 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -173,7 +173,7 @@ bool Command::enqueue(EnqueueResultT &EnqueueResult, BlockingT Blocking) { // Exit if enqueue type is not blocking if (!Blocking) { EnqueueResult = - EnqueueResultT(EnqueueResultT::SYCL_ENQUEUE_BLOCKED, this); + EnqueueResultT(EnqueueResultT::SyclEnqueueBlocked, this); return false; } static bool ThrowOnBlock = getenv("SYCL_THROW_ON_BLOCK") != nullptr; @@ -198,7 +198,7 @@ bool Command::enqueue(EnqueueResultT &EnqueueResult, BlockingT Blocking) { if (CL_SUCCESS != Res) EnqueueResult = - EnqueueResultT(EnqueueResultT::SYCL_ENQUEUE_FAILED, this, Res); + EnqueueResultT(EnqueueResultT::SyclEnqueueFailed, this, Res); else // Consider the command is successfully enqueued if return code is // CL_SUCCESS diff --git a/sycl/source/detail/scheduler/commands.hpp b/sycl/source/detail/scheduler/commands.hpp index 05f46e135744b..2f6e047526c94 100644 --- a/sycl/source/detail/scheduler/commands.hpp +++ b/sycl/source/detail/scheduler/commands.hpp @@ -39,11 +39,11 @@ enum BlockingT { NON_BLOCKING = 0, BLOCKING }; // The struct represents the result of command enqueueing struct EnqueueResultT { enum ResultT { - SYCL_ENQUEUE_SUCCESS, - SYCL_ENQUEUE_BLOCKED, - SYCL_ENQUEUE_FAILED + SyclEnqueueSuccess, + SyclEnqueueBlocked, + SyclEnqueueFailed }; - EnqueueResultT(ResultT Result = SYCL_ENQUEUE_SUCCESS, Command *Cmd = nullptr, + EnqueueResultT(ResultT Result = SyclEnqueueSuccess, Command *Cmd = nullptr, cl_int ErrCode = CL_SUCCESS) : MResult(Result), MCmd(Cmd), MErrCode(ErrCode) {} // Indicates result of enqueueing diff --git a/sycl/source/detail/scheduler/graph_processor.cpp b/sycl/source/detail/scheduler/graph_processor.cpp index 031828e6c21f1..903f4ac43294a 100644 --- a/sycl/source/detail/scheduler/graph_processor.cpp +++ b/sycl/source/detail/scheduler/graph_processor.cpp @@ -41,7 +41,7 @@ void Scheduler::GraphProcessor::waitForEvent(EventImplPtr Event) { assert(Cmd && "Event has no associated command?"); EnqueueResultT Res; bool Enqueued = enqueueCommand(Cmd, Res, BLOCKING); - if (!Enqueued && EnqueueResultT::SYCL_ENQUEUE_FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) // TODO: Reschedule commands. throw runtime_error("Enqueue process failed."); @@ -66,12 +66,12 @@ bool Scheduler::GraphProcessor::enqueueCommand(Command *Cmd, enqueueCommand(Dep.MDepCommand, EnqueueResult, Blocking); if (!Enqueued) switch (EnqueueResult.MResult) { - case EnqueueResultT::SYCL_ENQUEUE_FAILED: + case EnqueueResultT::SyclEnqueueFailed: default: // Exit immediately if a command fails to avoid enqueueing commands // result of which will be discarded. return false; - case EnqueueResultT::SYCL_ENQUEUE_BLOCKED: + case EnqueueResultT::SyclEnqueueBlocked: // If some dependency is blocked from enqueueing remember that, but // try to enqueue other dependencies(that can be ready for // enqueueing). diff --git a/sycl/source/detail/scheduler/scheduler.cpp b/sycl/source/detail/scheduler/scheduler.cpp index 5ac580bd5d921..1a87ec99ee252 100644 --- a/sycl/source/detail/scheduler/scheduler.cpp +++ b/sycl/source/detail/scheduler/scheduler.cpp @@ -30,14 +30,14 @@ void Scheduler::waitForRecordToFinish(MemObjRecord *Record) { for (Command *Cmd : Record->MReadLeaves) { EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(Cmd, Res); - if (!Enqueued && EnqueueResultT::SYCL_ENQUEUE_FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) throw runtime_error("Enqueue process failed."); GraphProcessor::waitForEvent(Cmd->getEvent()); } for (Command *Cmd : Record->MWriteLeaves) { EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(Cmd, Res); - if (!Enqueued && EnqueueResultT::SYCL_ENQUEUE_FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) throw runtime_error("Enqueue process failed."); GraphProcessor::waitForEvent(Cmd->getEvent()); } @@ -45,7 +45,7 @@ void Scheduler::waitForRecordToFinish(MemObjRecord *Record) { Command *ReleaseCmd = AllocaCmd->getReleaseCmd(); EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(ReleaseCmd, Res); - if (!Enqueued && EnqueueResultT::SYCL_ENQUEUE_FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) throw runtime_error("Enqueue process failed."); GraphProcessor::waitForEvent(ReleaseCmd->getEvent()); } @@ -70,7 +70,7 @@ EventImplPtr Scheduler::addCG(std::unique_ptr CommandGroup, // TODO: Check if lazy mode. EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(NewCmd, Res); - if (!Enqueued && EnqueueResultT::SYCL_ENQUEUE_FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) throw runtime_error("Enqueue process failed."); } @@ -91,7 +91,7 @@ EventImplPtr Scheduler::addCopyBack(Requirement *Req) { try { EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(NewCmd, Res); - if (!Enqueued && EnqueueResultT::SYCL_ENQUEUE_FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) throw runtime_error("Enqueue process failed."); } catch (...) { NewCmd->getQueue()->reportAsyncException(std::current_exception()); @@ -151,7 +151,7 @@ EventImplPtr Scheduler::addHostAccessor(Requirement *Req, return nullptr; EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(NewCmd, Res); - if (!Enqueued && EnqueueResultT::SYCL_ENQUEUE_FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) throw runtime_error("Enqueue process failed."); return NewCmd->getEvent(); } @@ -163,7 +163,7 @@ void Scheduler::releaseHostAccessor(Requirement *Req) { for (Command *Cmd : Leaves) { EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(Cmd, Res); - if (!Enqueued && EnqueueResultT::SYCL_ENQUEUE_FAILED == Res.MResult) + if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) throw runtime_error("Enqueue process failed."); } }; From 043f1b8aa2e4cfeae0602eff4c04ec81a70a1cb0 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Fri, 28 Feb 2020 16:54:18 -0800 Subject: [PATCH 14/32] fixed the clang format issue Signed-off-by: Byoungro So --- sycl/source/detail/scheduler/commands.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index 4b5ef6c7ac7a4..3b97de5673a92 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -172,8 +172,7 @@ bool Command::enqueue(EnqueueResultT &EnqueueResult, BlockingT Blocking) { if (MIsBlockable && !MCanEnqueue) { // Exit if enqueue type is not blocking if (!Blocking) { - EnqueueResult = - EnqueueResultT(EnqueueResultT::SyclEnqueueBlocked, this); + EnqueueResult = EnqueueResultT(EnqueueResultT::SyclEnqueueBlocked, this); return false; } static bool ThrowOnBlock = getenv("SYCL_THROW_ON_BLOCK") != nullptr; From 8bbcbd0506103dc7acc214f0c5da9cf3abd5b515 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Fri, 28 Feb 2020 17:02:12 -0800 Subject: [PATCH 15/32] fix clang format issue Signed-off-by: Byoungro So --- sycl/source/detail/scheduler/commands.hpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/sycl/source/detail/scheduler/commands.hpp b/sycl/source/detail/scheduler/commands.hpp index 2f6e047526c94..315e0e366fd98 100644 --- a/sycl/source/detail/scheduler/commands.hpp +++ b/sycl/source/detail/scheduler/commands.hpp @@ -38,11 +38,7 @@ enum BlockingT { NON_BLOCKING = 0, BLOCKING }; // The struct represents the result of command enqueueing struct EnqueueResultT { - enum ResultT { - SyclEnqueueSuccess, - SyclEnqueueBlocked, - SyclEnqueueFailed - }; + enum ResultT { SyclEnqueueSuccess, SyclEnqueueBlocked, SyclEnqueueFailed }; EnqueueResultT(ResultT Result = SyclEnqueueSuccess, Command *Cmd = nullptr, cl_int ErrCode = CL_SUCCESS) : MResult(Result), MCmd(Cmd), MErrCode(ErrCode) {} From 7ad8d198fb1a0bb8b20595fa1cafccf10d230a6f Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Fri, 28 Feb 2020 20:22:48 -0800 Subject: [PATCH 16/32] fixed LIT test failure Signed-off-by: Byoungro So --- sycl/test/scheduler/BlockedCommands.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sycl/test/scheduler/BlockedCommands.cpp b/sycl/test/scheduler/BlockedCommands.cpp index 0cba98584a8c1..32421527f1562 100644 --- a/sycl/test/scheduler/BlockedCommands.cpp +++ b/sycl/test/scheduler/BlockedCommands.cpp @@ -54,7 +54,7 @@ int main() { return 1; } - if (detail::EnqueueResultT::BLOCKED != Res.MResult) { + if (detail::EnqueueResultT::SyclEnqueueBlocked != Res.MResult) { std::cerr << "Result of enqueueing blocked command should be BLOCKED" << std::endl; return 1; @@ -73,7 +73,7 @@ int main() { return 1; } - if (detail::EnqueueResultT::FAILED != Res.MResult) { + if (detail::EnqueueResultT::SyclEnqueueFailed != Res.MResult) { std::cerr << "The command is expected to fail to enqueue." << std::endl; return 1; } @@ -96,7 +96,7 @@ int main() { bool Enqueued = TestScheduler::enqueueCommand(&FakeCmd, Res, detail::BLOCKING); - if (!Enqueued || detail::EnqueueResultT::SUCCESS != Res.MResult) { + if (!Enqueued || detail::EnqueueResultT::SyclEnqueueSuccess != Res.MResult) { std::cerr << "The command is expected to be successfully enqueued." << std::endl; return 1; From f73a2d983b689c67c772ae7432527961b4851fec Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Fri, 28 Feb 2020 20:27:31 -0800 Subject: [PATCH 17/32] fixed the clang format issue Signed-off-by: Byoungro So --- sycl/test/scheduler/BlockedCommands.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sycl/test/scheduler/BlockedCommands.cpp b/sycl/test/scheduler/BlockedCommands.cpp index 32421527f1562..bdcbd300fb2cd 100644 --- a/sycl/test/scheduler/BlockedCommands.cpp +++ b/sycl/test/scheduler/BlockedCommands.cpp @@ -96,7 +96,8 @@ int main() { bool Enqueued = TestScheduler::enqueueCommand(&FakeCmd, Res, detail::BLOCKING); - if (!Enqueued || detail::EnqueueResultT::SyclEnqueueSuccess != Res.MResult) { + if (!Enqueued || + detail::EnqueueResultT::SyclEnqueueSuccess != Res.MResult) { std::cerr << "The command is expected to be successfully enqueued." << std::endl; return 1; From c86049c0caeecff41a3952d88904d50c21e8ff9e Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Fri, 28 Feb 2020 20:39:53 -0800 Subject: [PATCH 18/32] fixed format Signed-off-by: Byoungro So --- sycl/test/scheduler/BlockedCommands.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/test/scheduler/BlockedCommands.cpp b/sycl/test/scheduler/BlockedCommands.cpp index bdcbd300fb2cd..8f10f355785fe 100644 --- a/sycl/test/scheduler/BlockedCommands.cpp +++ b/sycl/test/scheduler/BlockedCommands.cpp @@ -97,7 +97,7 @@ int main() { TestScheduler::enqueueCommand(&FakeCmd, Res, detail::BLOCKING); if (!Enqueued || - detail::EnqueueResultT::SyclEnqueueSuccess != Res.MResult) { + detail::EnqueueResultT::SyclEnqueueSuccess != Res.MResult) { std::cerr << "The command is expected to be successfully enqueued." << std::endl; return 1; From bba388a5153d322d325ead55d5fbcd29194c0beb Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Mon, 4 May 2020 11:39:17 -0700 Subject: [PATCH 19/32] [SYCL] Export only pi* symbols in libpi_opencl.so Changed symbols from Oclpi* to pi* Set -fvisibility=hidden by default to hide all symbols. version script tells only pi* symbols are global. Signed-off-by: Byoungro So --- sycl/include/CL/sycl/detail/pi.h | 617 +++++++++++++++-------------- sycl/plugins/ld-version-script.txt | 10 + sycl/plugins/opencl/CMakeLists.txt | 36 +- sycl/plugins/opencl/pi_opencl.cpp | 227 ++++++----- 4 files changed, 475 insertions(+), 415 deletions(-) create mode 100644 sycl/plugins/ld-version-script.txt diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index 49e569077f9fd..ab0bd9440cbfc 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -46,6 +46,7 @@ // elsewhere, e.g. in the pi_opencl, but constants/enums mapping is now // done here, for efficiency and simplicity. // +#include "export.hpp" #include #include #include @@ -751,56 +752,62 @@ using pi_plugin = _pi_plugin; // populate the PI Version it supports, update targets field and populate // PiFunctionTable with Supported APIs. The pointers are in a predetermined // order in pi.def file. -pi_result piPluginInit(pi_plugin *plugin_info); +__SYCL_EXPORT pi_result piPluginInit(pi_plugin *plugin_info); // // Platform // -pi_result piPlatformsGet(pi_uint32 num_entries, pi_platform *platforms, - pi_uint32 *num_platforms); +__SYCL_EXPORT pi_result piPlatformsGet(pi_uint32 num_entries, + pi_platform *platforms, + pi_uint32 *num_platforms); -pi_result piPlatformGetInfo(pi_platform platform, pi_platform_info param_name, - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piPlatformGetInfo(pi_platform platform, + pi_platform_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret); -pi_result piDevicesGet(pi_platform platform, pi_device_type device_type, - pi_uint32 num_entries, pi_device *devices, - pi_uint32 *num_devices); +__SYCL_EXPORT pi_result piDevicesGet(pi_platform platform, + pi_device_type device_type, + pi_uint32 num_entries, pi_device *devices, + pi_uint32 *num_devices); -pi_result piDeviceGetInfo(pi_device device, pi_device_info param_name, - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piDeviceGetInfo(pi_device device, + pi_device_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret); -pi_result piDeviceRetain(pi_device device); +__SYCL_EXPORT pi_result piDeviceRetain(pi_device device); -pi_result piDeviceRelease(pi_device device); +__SYCL_EXPORT pi_result piDeviceRelease(pi_device device); -pi_result piDevicePartition(pi_device device, - const pi_device_partition_property *properties, - pi_uint32 num_devices, pi_device *out_devices, - pi_uint32 *out_num_devices); +__SYCL_EXPORT pi_result piDevicePartition( + pi_device device, const pi_device_partition_property *properties, + pi_uint32 num_devices, pi_device *out_devices, pi_uint32 *out_num_devices); /// Gets the native handle of a PI device object. /// /// \param device is the PI device to get the native handle of. /// \param nativeHandle is the native handle of device. -pi_result piextDeviceGetNativeHandle(pi_device device, - pi_native_handle *nativeHandle); +__SYCL_EXPORT pi_result +piextDeviceGetNativeHandle(pi_device device, pi_native_handle *nativeHandle); /// Creates PI device object from a native handle. /// NOTE: The created PI object takes ownership of the native handle. /// /// \param nativeHandle is the native handle to create PI device from. /// \param device is the PI device created from the native handle. -pi_result piextDeviceCreateWithNativeHandle(pi_native_handle nativeHandle, - pi_device *device); +__SYCL_EXPORT pi_result piextDeviceCreateWithNativeHandle( + pi_native_handle nativeHandle, pi_device *device); /// Selects the most appropriate device binary based on runtime information /// and the IR characteristics. /// -pi_result piextDeviceSelectBinary(pi_device device, pi_device_binary *binaries, - pi_uint32 num_binaries, - pi_uint32 *selected_binary_ind); +__SYCL_EXPORT pi_result piextDeviceSelectBinary(pi_device device, + pi_device_binary *binaries, + pi_uint32 num_binaries, + pi_uint32 *selected_binary_ind); /// Retrieves a device function pointer to a user-defined function /// \arg \c function_name. \arg \c function_pointer_ret is set to 0 if query @@ -810,172 +817,180 @@ pi_result piextDeviceSelectBinary(pi_device device, pi_device_binary *binaries, /// must present in the list of devices returned by \c get_device method for /// \arg \c program. /// -pi_result piextGetDeviceFunctionPointer(pi_device device, pi_program program, - const char *function_name, - pi_uint64 *function_pointer_ret); +__SYCL_EXPORT pi_result piextGetDeviceFunctionPointer( + pi_device device, pi_program program, const char *function_name, + pi_uint64 *function_pointer_ret); // // Context // -pi_result piContextCreate(const pi_context_properties *properties, - pi_uint32 num_devices, const pi_device *devices, - void (*pfn_notify)(const char *errinfo, - const void *private_info, - size_t cb, void *user_data), - void *user_data, pi_context *ret_context); +__SYCL_EXPORT pi_result piContextCreate( + const pi_context_properties *properties, pi_uint32 num_devices, + const pi_device *devices, + void (*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, + void *user_data), + void *user_data, pi_context *ret_context); -pi_result piContextGetInfo(pi_context context, pi_context_info param_name, - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piContextGetInfo(pi_context context, + pi_context_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret); -pi_result piContextRetain(pi_context context); +__SYCL_EXPORT pi_result piContextRetain(pi_context context); -pi_result piContextRelease(pi_context context); +__SYCL_EXPORT pi_result piContextRelease(pi_context context); typedef void (*pi_context_extended_deleter)(void *user_data); -pi_result piextContextSetExtendedDeleter(pi_context context, - pi_context_extended_deleter func, - void *user_data); +__SYCL_EXPORT pi_result piextContextSetExtendedDeleter( + pi_context context, pi_context_extended_deleter func, void *user_data); /// Gets the native handle of a PI context object. /// /// \param context is the PI context to get the native handle of. /// \param nativeHandle is the native handle of context. -pi_result piextContextGetNativeHandle(pi_context context, - pi_native_handle *nativeHandle); +__SYCL_EXPORT pi_result +piextContextGetNativeHandle(pi_context context, pi_native_handle *nativeHandle); /// Creates PI context object from a native handle. /// NOTE: The created PI object takes ownership of the native handle. /// /// \param nativeHandle is the native handle to create PI context from. /// \param context is the PI context created from the native handle. -pi_result piextContextCreateWithNativeHandle(pi_native_handle nativeHandle, - pi_context *context); +__SYCL_EXPORT pi_result piextContextCreateWithNativeHandle( + pi_native_handle nativeHandle, pi_context *context); // // Queue // -pi_result piQueueCreate(pi_context context, pi_device device, - pi_queue_properties properties, pi_queue *queue); +__SYCL_EXPORT pi_result piQueueCreate(pi_context context, pi_device device, + pi_queue_properties properties, + pi_queue *queue); -pi_result piQueueGetInfo(pi_queue command_queue, pi_queue_info param_name, - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piQueueGetInfo(pi_queue command_queue, + pi_queue_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret); -pi_result piQueueRetain(pi_queue command_queue); +__SYCL_EXPORT pi_result piQueueRetain(pi_queue command_queue); -pi_result piQueueRelease(pi_queue command_queue); +__SYCL_EXPORT pi_result piQueueRelease(pi_queue command_queue); -pi_result piQueueFinish(pi_queue command_queue); +__SYCL_EXPORT pi_result piQueueFinish(pi_queue command_queue); /// Gets the native handle of a PI queue object. /// /// \param queue is the PI queue to get the native handle of. /// \param nativeHandle is the native handle of queue. -pi_result piextQueueGetNativeHandle(pi_queue queue, - pi_native_handle *nativeHandle); +__SYCL_EXPORT pi_result +piextQueueGetNativeHandle(pi_queue queue, pi_native_handle *nativeHandle); /// Creates PI queue object from a native handle. /// NOTE: The created PI object takes ownership of the native handle. /// /// \param nativeHandle is the native handle to create PI queue from. /// \param queue is the PI queue created from the native handle. -pi_result piextQueueCreateWithNativeHandle(pi_native_handle nativeHandle, - pi_queue *queue); +__SYCL_EXPORT pi_result piextQueueCreateWithNativeHandle( + pi_native_handle nativeHandle, pi_queue *queue); // // Memory // -pi_result piMemBufferCreate(pi_context context, pi_mem_flags flags, size_t size, - void *host_ptr, pi_mem *ret_mem); - -pi_result piMemImageCreate(pi_context context, pi_mem_flags flags, - const pi_image_format *image_format, - const pi_image_desc *image_desc, void *host_ptr, - pi_mem *ret_mem); - -pi_result piMemGetInfo(pi_mem mem, - cl_mem_info param_name, // TODO: untie from OpenCL - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piMemBufferCreate(pi_context context, + pi_mem_flags flags, size_t size, + void *host_ptr, pi_mem *ret_mem); + +__SYCL_EXPORT pi_result piMemImageCreate(pi_context context, pi_mem_flags flags, + const pi_image_format *image_format, + const pi_image_desc *image_desc, + void *host_ptr, pi_mem *ret_mem); + +__SYCL_EXPORT pi_result piMemGetInfo( + pi_mem mem, + cl_mem_info param_name, // TODO: untie from OpenCL + size_t param_value_size, void *param_value, size_t *param_value_size_ret); -pi_result piMemImageGetInfo(pi_mem image, pi_image_info param_name, - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piMemImageGetInfo(pi_mem image, + pi_image_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret); -pi_result piMemRetain(pi_mem mem); +__SYCL_EXPORT pi_result piMemRetain(pi_mem mem); -pi_result piMemRelease(pi_mem mem); +__SYCL_EXPORT pi_result piMemRelease(pi_mem mem); -pi_result piMemBufferPartition(pi_mem buffer, pi_mem_flags flags, - pi_buffer_create_type buffer_create_type, - void *buffer_create_info, pi_mem *ret_mem); +__SYCL_EXPORT pi_result piMemBufferPartition( + pi_mem buffer, pi_mem_flags flags, pi_buffer_create_type buffer_create_type, + void *buffer_create_info, pi_mem *ret_mem); /// Gets the native handle of a PI mem object. /// /// \param mem is the PI mem to get the native handle of. /// \param nativeHandle is the native handle of mem. -pi_result piextMemGetNativeHandle(pi_mem mem, pi_native_handle *nativeHandle); +__SYCL_EXPORT pi_result piextMemGetNativeHandle(pi_mem mem, + pi_native_handle *nativeHandle); /// Creates PI mem object from a native handle. /// NOTE: The created PI object takes ownership of the native handle. /// /// \param nativeHandle is the native handle to create PI mem from. /// \param mem is the PI mem created from the native handle. -pi_result piextMemCreateWithNativeHandle(pi_native_handle nativeHandle, - pi_mem *mem); +__SYCL_EXPORT pi_result +piextMemCreateWithNativeHandle(pi_native_handle nativeHandle, pi_mem *mem); // // Program // -pi_result piProgramCreate(pi_context context, const void *il, size_t length, - pi_program *res_program); - -pi_result piclProgramCreateWithSource(pi_context context, pi_uint32 count, - const char **strings, - const size_t *lengths, - pi_program *ret_program); - -pi_result piclProgramCreateWithBinary(pi_context context, pi_uint32 num_devices, - const pi_device *device_list, - const size_t *lengths, - const unsigned char **binaries, - pi_int32 *binary_status, - pi_program *ret_program); - -pi_result piProgramGetInfo(pi_program program, pi_program_info param_name, - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); - -pi_result piProgramLink(pi_context context, pi_uint32 num_devices, - const pi_device *device_list, const char *options, - pi_uint32 num_input_programs, - const pi_program *input_programs, - void (*pfn_notify)(pi_program program, void *user_data), - void *user_data, pi_program *ret_program); - -pi_result piProgramCompile( +__SYCL_EXPORT pi_result piProgramCreate(pi_context context, const void *il, + size_t length, pi_program *res_program); + +__SYCL_EXPORT pi_result piclProgramCreateWithSource(pi_context context, + pi_uint32 count, + const char **strings, + const size_t *lengths, + pi_program *ret_program); + +__SYCL_EXPORT pi_result piclProgramCreateWithBinary( + pi_context context, pi_uint32 num_devices, const pi_device *device_list, + const size_t *lengths, const unsigned char **binaries, + pi_int32 *binary_status, pi_program *ret_program); + +__SYCL_EXPORT pi_result piProgramGetInfo(pi_program program, + pi_program_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret); + +__SYCL_EXPORT pi_result +piProgramLink(pi_context context, pi_uint32 num_devices, + const pi_device *device_list, const char *options, + pi_uint32 num_input_programs, const pi_program *input_programs, + void (*pfn_notify)(pi_program program, void *user_data), + void *user_data, pi_program *ret_program); + +__SYCL_EXPORT pi_result piProgramCompile( pi_program program, pi_uint32 num_devices, const pi_device *device_list, const char *options, pi_uint32 num_input_headers, const pi_program *input_headers, const char **header_include_names, void (*pfn_notify)(pi_program program, void *user_data), void *user_data); -pi_result piProgramBuild(pi_program program, pi_uint32 num_devices, - const pi_device *device_list, const char *options, - void (*pfn_notify)(pi_program program, - void *user_data), - void *user_data); +__SYCL_EXPORT pi_result piProgramBuild( + pi_program program, pi_uint32 num_devices, const pi_device *device_list, + const char *options, + void (*pfn_notify)(pi_program program, void *user_data), void *user_data); -pi_result piProgramGetBuildInfo( +__SYCL_EXPORT pi_result piProgramGetBuildInfo( pi_program program, pi_device device, cl_program_build_info param_name, // TODO: untie from OpenCL size_t param_value_size, void *param_value, size_t *param_value_size_ret); -pi_result piProgramRetain(pi_program program); +__SYCL_EXPORT pi_result piProgramRetain(pi_program program); -pi_result piProgramRelease(pi_program program); +__SYCL_EXPORT pi_result piProgramRelease(pi_program program); /// Sets a specialization constant to a specific value. /// @@ -983,25 +998,24 @@ pi_result piProgramRelease(pi_program program); /// \param spec_id integer ID of the constant /// \param spec_size size of the value /// \param spec_value bytes of the value -pi_result piextProgramSetSpecializationConstant(pi_program prog, - pi_uint32 spec_id, - size_t spec_size, - const void *spec_value); +__SYCL_EXPORT pi_result +piextProgramSetSpecializationConstant(pi_program prog, pi_uint32 spec_id, + size_t spec_size, const void *spec_value); /// Gets the native handle of a PI program object. /// /// \param program is the PI program to get the native handle of. /// \param nativeHandle is the native handle of program. -pi_result piextProgramGetNativeHandle(pi_program program, - pi_native_handle *nativeHandle); +__SYCL_EXPORT pi_result +piextProgramGetNativeHandle(pi_program program, pi_native_handle *nativeHandle); /// Creates PI program object from a native handle. /// NOTE: The created PI object takes ownership of the native handle. /// /// \param nativeHandle is the native handle to create PI program from. /// \param program is the PI program created from the native handle. -pi_result piextProgramCreateWithNativeHandle(pi_native_handle nativeHandle, - pi_program *program); +__SYCL_EXPORT pi_result piextProgramCreateWithNativeHandle( + pi_native_handle nativeHandle, pi_program *program); // // Kernel @@ -1016,30 +1030,34 @@ typedef enum { using pi_kernel_exec_info = _pi_kernel_exec_info; -pi_result piKernelCreate(pi_program program, const char *kernel_name, - pi_kernel *ret_kernel); +__SYCL_EXPORT pi_result piKernelCreate(pi_program program, + const char *kernel_name, + pi_kernel *ret_kernel); -pi_result piKernelSetArg(pi_kernel kernel, pi_uint32 arg_index, size_t arg_size, - const void *arg_value); +__SYCL_EXPORT pi_result piKernelSetArg(pi_kernel kernel, pi_uint32 arg_index, + size_t arg_size, const void *arg_value); -pi_result piKernelGetInfo(pi_kernel kernel, pi_kernel_info param_name, - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piKernelGetInfo(pi_kernel kernel, + pi_kernel_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret); -pi_result piKernelGetGroupInfo(pi_kernel kernel, pi_device device, - pi_kernel_group_info param_name, - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piKernelGetGroupInfo(pi_kernel kernel, pi_device device, + pi_kernel_group_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret); -pi_result piKernelGetSubGroupInfo( +__SYCL_EXPORT pi_result piKernelGetSubGroupInfo( pi_kernel kernel, pi_device device, cl_kernel_sub_group_info param_name, // TODO: untie from OpenCL size_t input_value_size, const void *input_value, size_t param_value_size, void *param_value, size_t *param_value_size_ret); -pi_result piKernelRetain(pi_kernel kernel); +__SYCL_EXPORT pi_result piKernelRetain(pi_kernel kernel); -pi_result piKernelRelease(pi_kernel kernel); +__SYCL_EXPORT pi_result piKernelRelease(pi_kernel kernel); /// Sets up pointer arguments for CL kernels. An extra indirection /// is required due to CL argument conventions. @@ -1048,8 +1066,10 @@ pi_result piKernelRelease(pi_kernel kernel); /// \param arg_index is the index of the kernel argument /// \param arg_size is the size in bytes of the argument (ignored in CL) /// \param arg_value is the pointer argument -pi_result piextKernelSetArgPointer(pi_kernel kernel, pi_uint32 arg_index, - size_t arg_size, const void *arg_value); +__SYCL_EXPORT pi_result piextKernelSetArgPointer(pi_kernel kernel, + pi_uint32 arg_index, + size_t arg_size, + const void *arg_value); /// API to set attributes controlling kernel execution /// @@ -1062,183 +1082,181 @@ pi_result piextKernelSetArgPointer(pi_kernel kernel, pi_uint32 arg_index, /// If param_name is PI_USM_INDIRECT_ACCESS, the value will be a ptr to /// the pi_bool value PI_TRUE /// If param_name is PI_USM_PTRS, the value will be an array of ptrs -pi_result piKernelSetExecInfo(pi_kernel kernel, pi_kernel_exec_info value_name, - size_t param_value_size, const void *param_value); +__SYCL_EXPORT pi_result piKernelSetExecInfo(pi_kernel kernel, + pi_kernel_exec_info value_name, + size_t param_value_size, + const void *param_value); // // Events // -pi_result piEventCreate(pi_context context, pi_event *ret_event); +__SYCL_EXPORT pi_result piEventCreate(pi_context context, pi_event *ret_event); -pi_result piEventGetInfo(pi_event event, - cl_event_info param_name, // TODO: untie from OpenCL - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piEventGetInfo( + pi_event event, + cl_event_info param_name, // TODO: untie from OpenCL + size_t param_value_size, void *param_value, size_t *param_value_size_ret); -pi_result piEventGetProfilingInfo(pi_event event, pi_profiling_info param_name, - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piEventGetProfilingInfo(pi_event event, + pi_profiling_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret); -pi_result piEventsWait(pi_uint32 num_events, const pi_event *event_list); +__SYCL_EXPORT pi_result piEventsWait(pi_uint32 num_events, + const pi_event *event_list); -pi_result piEventSetCallback(pi_event event, - pi_int32 command_exec_callback_type, - void (*pfn_notify)(pi_event event, - pi_int32 event_command_status, - void *user_data), - void *user_data); +__SYCL_EXPORT pi_result piEventSetCallback( + pi_event event, pi_int32 command_exec_callback_type, + void (*pfn_notify)(pi_event event, pi_int32 event_command_status, + void *user_data), + void *user_data); -pi_result piEventSetStatus(pi_event event, pi_int32 execution_status); +__SYCL_EXPORT pi_result piEventSetStatus(pi_event event, + pi_int32 execution_status); -pi_result piEventRetain(pi_event event); +__SYCL_EXPORT pi_result piEventRetain(pi_event event); -pi_result piEventRelease(pi_event event); +__SYCL_EXPORT pi_result piEventRelease(pi_event event); /// Gets the native handle of a PI event object. /// /// \param event is the PI event to get the native handle of. /// \param nativeHandle is the native handle of event. -pi_result piextEventGetNativeHandle(pi_event event, - pi_native_handle *nativeHandle); +__SYCL_EXPORT pi_result +piextEventGetNativeHandle(pi_event event, pi_native_handle *nativeHandle); /// Creates PI event object from a native handle. /// NOTE: The created PI object takes ownership of the native handle. /// /// \param nativeHandle is the native handle to create PI event from. /// \param event is the PI event created from the native handle. -pi_result piextEventCreateWithNativeHandle(pi_native_handle nativeHandle, - pi_event *event); +__SYCL_EXPORT pi_result piextEventCreateWithNativeHandle( + pi_native_handle nativeHandle, pi_event *event); // // Sampler // -pi_result piSamplerCreate(pi_context context, - const pi_sampler_properties *sampler_properties, - pi_sampler *result_sampler); +__SYCL_EXPORT pi_result piSamplerCreate( + pi_context context, const pi_sampler_properties *sampler_properties, + pi_sampler *result_sampler); -pi_result piSamplerGetInfo(pi_sampler sampler, pi_sampler_info param_name, - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piSamplerGetInfo(pi_sampler sampler, + pi_sampler_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret); -pi_result piSamplerRetain(pi_sampler sampler); +__SYCL_EXPORT pi_result piSamplerRetain(pi_sampler sampler); -pi_result piSamplerRelease(pi_sampler sampler); +__SYCL_EXPORT pi_result piSamplerRelease(pi_sampler sampler); // // Queue Commands // -pi_result piEnqueueKernelLaunch( +__SYCL_EXPORT pi_result piEnqueueKernelLaunch( pi_queue queue, pi_kernel kernel, pi_uint32 work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event); -pi_result -piEnqueueNativeKernel(pi_queue queue, void (*user_func)(void *), void *args, - size_t cb_args, pi_uint32 num_mem_objects, - const pi_mem *mem_list, const void **args_mem_loc, - pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, pi_event *event); +__SYCL_EXPORT pi_result piEnqueueNativeKernel( + pi_queue queue, void (*user_func)(void *), void *args, size_t cb_args, + pi_uint32 num_mem_objects, const pi_mem *mem_list, + const void **args_mem_loc, pi_uint32 num_events_in_wait_list, + const pi_event *event_wait_list, pi_event *event); + +__SYCL_EXPORT pi_result piEnqueueEventsWait(pi_queue command_queue, + pi_uint32 num_events_in_wait_list, + const pi_event *event_wait_list, + pi_event *event); + +__SYCL_EXPORT pi_result piEnqueueMemBufferRead( + pi_queue queue, pi_mem buffer, pi_bool blocking_read, size_t offset, + size_t size, void *ptr, pi_uint32 num_events_in_wait_list, + const pi_event *event_wait_list, pi_event *event); -pi_result piEnqueueEventsWait(pi_queue command_queue, - pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, pi_event *event); - -pi_result piEnqueueMemBufferRead(pi_queue queue, pi_mem buffer, - pi_bool blocking_read, size_t offset, - size_t size, void *ptr, - pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, - pi_event *event); - -pi_result -piEnqueueMemBufferReadRect(pi_queue command_queue, pi_mem buffer, - pi_bool blocking_read, const size_t *buffer_offset, - const size_t *host_offset, const size_t *region, - size_t buffer_row_pitch, size_t buffer_slice_pitch, - size_t host_row_pitch, size_t host_slice_pitch, - void *ptr, pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, pi_event *event); - -pi_result piEnqueueMemBufferWrite(pi_queue command_queue, pi_mem buffer, - pi_bool blocking_write, size_t offset, - size_t size, const void *ptr, - pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, - pi_event *event); - -pi_result -piEnqueueMemBufferWriteRect(pi_queue command_queue, pi_mem buffer, - pi_bool blocking_write, const size_t *buffer_offset, - const size_t *host_offset, const size_t *region, - size_t buffer_row_pitch, size_t buffer_slice_pitch, - size_t host_row_pitch, size_t host_slice_pitch, - const void *ptr, pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, pi_event *event); - -pi_result piEnqueueMemBufferCopy(pi_queue command_queue, pi_mem src_buffer, - pi_mem dst_buffer, size_t src_offset, - size_t dst_offset, size_t size, - pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, - pi_event *event); - -pi_result piEnqueueMemBufferCopyRect( +__SYCL_EXPORT pi_result piEnqueueMemBufferReadRect( + pi_queue command_queue, pi_mem buffer, pi_bool blocking_read, + const size_t *buffer_offset, const size_t *host_offset, + const size_t *region, size_t buffer_row_pitch, size_t buffer_slice_pitch, + size_t host_row_pitch, size_t host_slice_pitch, void *ptr, + pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, + pi_event *event); + +__SYCL_EXPORT pi_result +piEnqueueMemBufferWrite(pi_queue command_queue, pi_mem buffer, + pi_bool blocking_write, size_t offset, size_t size, + const void *ptr, pi_uint32 num_events_in_wait_list, + const pi_event *event_wait_list, pi_event *event); + +__SYCL_EXPORT pi_result piEnqueueMemBufferWriteRect( + pi_queue command_queue, pi_mem buffer, pi_bool blocking_write, + const size_t *buffer_offset, const size_t *host_offset, + const size_t *region, size_t buffer_row_pitch, size_t buffer_slice_pitch, + size_t host_row_pitch, size_t host_slice_pitch, const void *ptr, + pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, + pi_event *event); + +__SYCL_EXPORT pi_result +piEnqueueMemBufferCopy(pi_queue command_queue, pi_mem src_buffer, + pi_mem dst_buffer, size_t src_offset, size_t dst_offset, + size_t size, pi_uint32 num_events_in_wait_list, + const pi_event *event_wait_list, pi_event *event); + +__SYCL_EXPORT pi_result piEnqueueMemBufferCopyRect( pi_queue command_queue, pi_mem src_buffer, pi_mem dst_buffer, const size_t *src_origin, const size_t *dst_origin, const size_t *region, size_t src_row_pitch, size_t src_slice_pitch, size_t dst_row_pitch, size_t dst_slice_pitch, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event); -pi_result piEnqueueMemBufferFill(pi_queue command_queue, pi_mem buffer, - const void *pattern, size_t pattern_size, - size_t offset, size_t size, - pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, - pi_event *event); - -pi_result piEnqueueMemImageRead(pi_queue command_queue, pi_mem image, - pi_bool blocking_read, const size_t *origin, - const size_t *region, size_t row_pitch, - size_t slice_pitch, void *ptr, - pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, - pi_event *event); - -pi_result piEnqueueMemImageWrite(pi_queue command_queue, pi_mem image, - pi_bool blocking_write, const size_t *origin, - const size_t *region, size_t input_row_pitch, - size_t input_slice_pitch, const void *ptr, - pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, - pi_event *event); - -pi_result piEnqueueMemImageCopy(pi_queue command_queue, pi_mem src_image, - pi_mem dst_image, const size_t *src_origin, - const size_t *dst_origin, const size_t *region, - pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, - pi_event *event); - -pi_result piEnqueueMemImageFill(pi_queue command_queue, pi_mem image, - const void *fill_color, const size_t *origin, - const size_t *region, - pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, - pi_event *event); - -pi_result piEnqueueMemBufferMap( +__SYCL_EXPORT pi_result +piEnqueueMemBufferFill(pi_queue command_queue, pi_mem buffer, + const void *pattern, size_t pattern_size, size_t offset, + size_t size, pi_uint32 num_events_in_wait_list, + const pi_event *event_wait_list, pi_event *event); + +__SYCL_EXPORT pi_result piEnqueueMemImageRead( + pi_queue command_queue, pi_mem image, pi_bool blocking_read, + const size_t *origin, const size_t *region, size_t row_pitch, + size_t slice_pitch, void *ptr, pi_uint32 num_events_in_wait_list, + const pi_event *event_wait_list, pi_event *event); + +__SYCL_EXPORT pi_result piEnqueueMemImageWrite( + pi_queue command_queue, pi_mem image, pi_bool blocking_write, + const size_t *origin, const size_t *region, size_t input_row_pitch, + size_t input_slice_pitch, const void *ptr, + pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, + pi_event *event); + +__SYCL_EXPORT pi_result piEnqueueMemImageCopy( + pi_queue command_queue, pi_mem src_image, pi_mem dst_image, + const size_t *src_origin, const size_t *dst_origin, const size_t *region, + pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, + pi_event *event); + +__SYCL_EXPORT pi_result +piEnqueueMemImageFill(pi_queue command_queue, pi_mem image, + const void *fill_color, const size_t *origin, + const size_t *region, pi_uint32 num_events_in_wait_list, + const pi_event *event_wait_list, pi_event *event); + +__SYCL_EXPORT pi_result piEnqueueMemBufferMap( pi_queue command_queue, pi_mem buffer, pi_bool blocking_map, cl_map_flags map_flags, // TODO: untie from OpenCL size_t offset, size_t size, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event, void **ret_map); -pi_result piEnqueueMemUnmap(pi_queue command_queue, pi_mem memobj, - void *mapped_ptr, pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, pi_event *event); +__SYCL_EXPORT pi_result piEnqueueMemUnmap(pi_queue command_queue, pi_mem memobj, + void *mapped_ptr, + pi_uint32 num_events_in_wait_list, + const pi_event *event_wait_list, + pi_event *event); -pi_result piextKernelSetArgMemObj(pi_kernel kernel, pi_uint32 arg_index, - const pi_mem *arg_value); +__SYCL_EXPORT pi_result piextKernelSetArgMemObj(pi_kernel kernel, + pi_uint32 arg_index, + const pi_mem *arg_value); /// // USM @@ -1299,9 +1317,9 @@ using pi_usm_migration_flags = _pi_usm_migration_flags; /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -pi_result piextUSMHostAlloc(void **result_ptr, pi_context context, - pi_usm_mem_properties *properties, size_t size, - pi_uint32 alignment); +__SYCL_EXPORT pi_result piextUSMHostAlloc(void **result_ptr, pi_context context, + pi_usm_mem_properties *properties, + size_t size, pi_uint32 alignment); /// Allocates device memory /// @@ -1311,10 +1329,11 @@ pi_result piextUSMHostAlloc(void **result_ptr, pi_context context, /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -pi_result piextUSMDeviceAlloc(void **result_ptr, pi_context context, - pi_device device, - pi_usm_mem_properties *properties, size_t size, - pi_uint32 alignment); +__SYCL_EXPORT pi_result piextUSMDeviceAlloc(void **result_ptr, + pi_context context, + pi_device device, + pi_usm_mem_properties *properties, + size_t size, pi_uint32 alignment); /// Allocates memory accessible on both host and device /// @@ -1324,16 +1343,17 @@ pi_result piextUSMDeviceAlloc(void **result_ptr, pi_context context, /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -pi_result piextUSMSharedAlloc(void **result_ptr, pi_context context, - pi_device device, - pi_usm_mem_properties *properties, size_t size, - pi_uint32 alignment); +__SYCL_EXPORT pi_result piextUSMSharedAlloc(void **result_ptr, + pi_context context, + pi_device device, + pi_usm_mem_properties *properties, + size_t size, pi_uint32 alignment); /// Frees allocated USM memory /// /// \param context is the pi_context of the allocation /// \param ptr is the memory to be freed -pi_result piextUSMFree(pi_context context, void *ptr); +__SYCL_EXPORT pi_result piextUSMFree(pi_context context, void *ptr); /// USM Memset API /// @@ -1346,10 +1366,11 @@ pi_result piextUSMFree(pi_context context, void *ptr); /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -pi_result piextUSMEnqueueMemset(pi_queue queue, void *ptr, pi_int32 value, - size_t count, pi_uint32 num_events_in_waitlist, - const pi_event *events_waitlist, - pi_event *event); +__SYCL_EXPORT pi_result piextUSMEnqueueMemset(pi_queue queue, void *ptr, + pi_int32 value, size_t count, + pi_uint32 num_events_in_waitlist, + const pi_event *events_waitlist, + pi_event *event); /// USM Memcpy API /// @@ -1361,11 +1382,12 @@ pi_result piextUSMEnqueueMemset(pi_queue queue, void *ptr, pi_int32 value, /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -pi_result piextUSMEnqueueMemcpy(pi_queue queue, pi_bool blocking, void *dst_ptr, - const void *src_ptr, size_t size, - pi_uint32 num_events_in_waitlist, - const pi_event *events_waitlist, - pi_event *event); +__SYCL_EXPORT pi_result piextUSMEnqueueMemcpy(pi_queue queue, pi_bool blocking, + void *dst_ptr, + const void *src_ptr, size_t size, + pi_uint32 num_events_in_waitlist, + const pi_event *events_waitlist, + pi_event *event); /// Hint to migrate memory to the device /// @@ -1376,11 +1398,10 @@ pi_result piextUSMEnqueueMemcpy(pi_queue queue, pi_bool blocking, void *dst_ptr, /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -pi_result piextUSMEnqueuePrefetch(pi_queue queue, const void *ptr, size_t size, - pi_usm_migration_flags flags, - pi_uint32 num_events_in_waitlist, - const pi_event *events_waitlist, - pi_event *event); +__SYCL_EXPORT pi_result piextUSMEnqueuePrefetch( + pi_queue queue, const void *ptr, size_t size, pi_usm_migration_flags flags, + pi_uint32 num_events_in_waitlist, const pi_event *events_waitlist, + pi_event *event); /// USM Memadvise API /// @@ -1390,8 +1411,9 @@ pi_result piextUSMEnqueuePrefetch(pi_queue queue, const void *ptr, size_t size, /// \param advice is device specific advice /// \param event is the event that represents this operation // USM memadvise API to govern behavior of automatic migration mechanisms -pi_result piextUSMEnqueueMemAdvise(pi_queue queue, const void *ptr, - size_t length, int advice, pi_event *event); +__SYCL_EXPORT pi_result piextUSMEnqueueMemAdvise(pi_queue queue, + const void *ptr, size_t length, + int advice, pi_event *event); /// API to query information about USM allocated pointers /// Valid Queries: @@ -1409,10 +1431,9 @@ pi_result piextUSMEnqueueMemAdvise(pi_queue queue, const void *ptr, /// \param param_value_size is the size of the result in bytes /// \param param_value is the result /// \param param_value_ret is how many bytes were written -pi_result piextUSMGetMemAllocInfo(pi_context context, const void *ptr, - pi_mem_info param_name, - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piextUSMGetMemAllocInfo( + pi_context context, const void *ptr, pi_mem_info param_name, + size_t param_value_size, void *param_value, size_t *param_value_size_ret); struct _pi_plugin { // PI version supported by host passed to the plugin. The Plugin diff --git a/sycl/plugins/ld-version-script.txt b/sycl/plugins/ld-version-script.txt new file mode 100644 index 0000000000000..1ad2c6d5f8390 --- /dev/null +++ b/sycl/plugins/ld-version-script.txt @@ -0,0 +1,10 @@ +{ + /* in CMakelists.txt, we pass -fvisibility=hidden compiler flag */ + /* This file is used to give exception of the hidden visibility */ + /* Export only pi* function symbols which are individually marked 'default' visibility */ + + global: pi*; + + /* all other symbols are local scope, meaning not exported */ + local: *; +}; diff --git a/sycl/plugins/opencl/CMakeLists.txt b/sycl/plugins/opencl/CMakeLists.txt index b085d53ba8175..b5621e1127ca0 100644 --- a/sycl/plugins/opencl/CMakeLists.txt +++ b/sycl/plugins/opencl/CMakeLists.txt @@ -9,9 +9,16 @@ #TODO: remove dependency on pi.hpp in sycl project. #TODO: Currently, the pi.hpp header is common between sycl and plugin library sources. #This can be changed by copying the pi.hpp file in the plugins project. +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/../../source/version.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/version.rc + @ONLY) + +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) add_library(pi_opencl SHARED "${sycl_inc_dir}/CL/sycl/detail/pi.h" "pi_opencl.cpp" + ${CMAKE_CURRENT_BINARY_DIR}/version.rc ) add_dependencies(pi_opencl @@ -26,14 +33,37 @@ set_target_properties(pi_opencl PROPERTIES LINKER_LANGUAGE CXX) #preprocessor definitions for compiling a target's sources. We do not need it for pi_opencl target_include_directories(pi_opencl PRIVATE "${sycl_inc_dir}") -#link pi_opencl with OpenCL headers and ICD Loader. -target_link_libraries( pi_opencl +if (MSVC) + target_compile_definitions(pi_opencl PRIVATE __SYCL_BUILD_SYCL_DLL) + target_link_libraries(pi_opencl PRIVATE shlwapi) + target_link_libraries( pi_opencl PRIVATE OpenCL::Headers PRIVATE ${OpenCL_LIBRARIES} -) + ) +else() + # we set the visibility of all symbols 'hidden' by default. + # In *.cpp files, we set exported symbols with visibility==default individually + target_compile_options(pi_opencl PUBLIC -fvisibility=hidden) + + # This script file is used to allow exporting pi* symbols only. + # All other symbols are regarded as local (hidden) + set(linker_script "${CMAKE_CURRENT_SOURCE_DIR}/../ld-version-script.txt") + + #link pi_opencl with OpenCL headers and ICD Loader. + target_link_libraries( pi_opencl + PRIVATE OpenCL::Headers + PRIVATE ${OpenCL_LIBRARIES} + # Filter symbols based on the scope defined in the script file, + # and export pi* function symbols in the library. + PRIVATE "-Wl,--version-script=${linker_script}" + ) +endif() add_common_options(pi_opencl) +set_target_properties(pi_opencl PROPERTIES + VERSION ${SYCL_VERSION_STRING} + SOVERSION ${SYCL_MAJOR_VERSION}) install(TARGETS pi_opencl LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT pi_opencl RUNTIME DESTINATION "bin" COMPONENT pi_opencl) diff --git a/sycl/plugins/opencl/pi_opencl.cpp b/sycl/plugins/opencl/pi_opencl.cpp index 733322fe0f577..35c4b884af252 100644 --- a/sycl/plugins/opencl/pi_opencl.cpp +++ b/sycl/plugins/opencl/pi_opencl.cpp @@ -15,6 +15,7 @@ /// \ingroup sycl_pi_ocl #include "CL/opencl.h" +#include #include #include @@ -161,11 +162,12 @@ static pi_result USMSetIndirectAccess(pi_kernel kernel) { extern "C" { // Convenience macro makes source code search easier -#define OCL(pi_api) Ocl##pi_api +#define OCL(pi_api) pi_api // Example of a PI interface that does not map exactly to an OpenCL one. -pi_result OCL(piPlatformsGet)(pi_uint32 num_entries, pi_platform *platforms, - pi_uint32 *num_platforms) { +__SYCL_EXPORT pi_result OCL(piPlatformsGet)(pi_uint32 num_entries, + pi_platform *platforms, + pi_uint32 *num_platforms) { cl_int result = clGetPlatformIDs(cast(num_entries), cast(platforms), cast(num_platforms)); @@ -180,9 +182,11 @@ pi_result OCL(piPlatformsGet)(pi_uint32 num_entries, pi_platform *platforms, } // Example of a PI interface that does not map exactly to an OpenCL one. -pi_result OCL(piDevicesGet)(pi_platform platform, pi_device_type device_type, - pi_uint32 num_entries, pi_device *devices, - pi_uint32 *num_devices) { +__SYCL_EXPORT pi_result OCL(piDevicesGet)(pi_platform platform, + pi_device_type device_type, + pi_uint32 num_entries, + pi_device *devices, + pi_uint32 *num_devices) { cl_int result = clGetDeviceIDs( cast(platform), cast(device_type), cast(num_entries), cast(devices), @@ -197,10 +201,9 @@ pi_result OCL(piDevicesGet)(pi_platform platform, pi_device_type device_type, return cast(result); } -pi_result OCL(piextDeviceSelectBinary)(pi_device device, - pi_device_binary *images, - pi_uint32 num_images, - pi_uint32 *selected_image_ind) { +__SYCL_EXPORT pi_result OCL(piextDeviceSelectBinary)( + pi_device device, pi_device_binary *images, pi_uint32 num_images, + pi_uint32 *selected_image_ind) { // TODO: this is a bare-bones implementation for choosing a device image // that would be compatible with the targeted device. An AOT-compiled @@ -269,15 +272,16 @@ pi_result OCL(piextDeviceSelectBinary)(pi_device device, return PI_INVALID_BINARY; } -pi_result OCL(piextDeviceCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_device *piDevice) { +__SYCL_EXPORT pi_result OCL(piextDeviceCreateWithNativeHandle)( + pi_native_handle nativeHandle, pi_device *piDevice) { assert(piDevice != nullptr); *piDevice = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piQueueCreate)(pi_context context, pi_device device, - pi_queue_properties properties, pi_queue *queue) { +__SYCL_EXPORT pi_result OCL(piQueueCreate)(pi_context context, pi_device device, + pi_queue_properties properties, + pi_queue *queue) { assert(queue && "piQueueCreate failed, queue argument is null"); cl_platform_id curPlatform; @@ -316,15 +320,16 @@ pi_result OCL(piQueueCreate)(pi_context context, pi_device device, return cast(ret_err); } -pi_result OCL(piextQueueCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_queue *piQueue) { +__SYCL_EXPORT pi_result OCL(piextQueueCreateWithNativeHandle)( + pi_native_handle nativeHandle, pi_queue *piQueue) { assert(piQueue != nullptr); *piQueue = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piProgramCreate)(pi_context context, const void *il, - size_t length, pi_program *res_program) { +__SYCL_EXPORT pi_result OCL(piProgramCreate)(pi_context context, const void *il, + size_t length, + pi_program *res_program) { size_t deviceCount; @@ -401,16 +406,16 @@ pi_result OCL(piProgramCreate)(pi_context context, const void *il, return err; } -pi_result OCL(piextProgramCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_program *piProgram) { +__SYCL_EXPORT pi_result OCL(piextProgramCreateWithNativeHandle)( + pi_native_handle nativeHandle, pi_program *piProgram) { assert(piProgram != nullptr); *piProgram = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piSamplerCreate)(pi_context context, - const pi_sampler_properties *sampler_properties, - pi_sampler *result_sampler) { +__SYCL_EXPORT pi_result OCL(piSamplerCreate)( + pi_context context, const pi_sampler_properties *sampler_properties, + pi_sampler *result_sampler) { // Initialize properties according to OpenCL 2.1 spec. pi_result error_code; pi_bool normalizedCoords = PI_TRUE; @@ -439,17 +444,17 @@ pi_result OCL(piSamplerCreate)(pi_context context, return error_code; } -pi_result OCL(piextKernelSetArgMemObj)(pi_kernel kernel, pi_uint32 arg_index, - const pi_mem *arg_value) { +__SYCL_EXPORT pi_result OCL(piextKernelSetArgMemObj)(pi_kernel kernel, + pi_uint32 arg_index, + const pi_mem *arg_value) { return cast( clSetKernelArg(cast(kernel), cast(arg_index), sizeof(arg_value), cast(arg_value))); } -pi_result OCL(piextGetDeviceFunctionPointer)(pi_device device, - pi_program program, - const char *func_name, - pi_uint64 *function_pointer_ret) { +__SYCL_EXPORT pi_result OCL(piextGetDeviceFunctionPointer)( + pi_device device, pi_program program, const char *func_name, + pi_uint64 *function_pointer_ret) { pi_platform platform; cl_int ret_err = clGetDeviceInfo(cast(device), PI_DEVICE_INFO_PLATFORM, @@ -484,12 +489,12 @@ pi_result OCL(piextGetDeviceFunctionPointer)(pi_device device, function_pointer_ret)); } -pi_result OCL(piContextCreate)(const pi_context_properties *properties, - pi_uint32 num_devices, const pi_device *devices, - void (*pfn_notify)(const char *errinfo, - const void *private_info, - size_t cb, void *user_data1), - void *user_data, pi_context *retcontext) { +__SYCL_EXPORT pi_result OCL(piContextCreate)( + const pi_context_properties *properties, pi_uint32 num_devices, + const pi_device *devices, + void (*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, + void *user_data1), + void *user_data, pi_context *retcontext) { pi_result ret = PI_INVALID_OPERATION; *retcontext = cast( clCreateContext(properties, cast(num_devices), @@ -499,15 +504,17 @@ pi_result OCL(piContextCreate)(const pi_context_properties *properties, return ret; } -pi_result OCL(piextContextCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_context *piContext) { +__SYCL_EXPORT pi_result OCL(piextContextCreateWithNativeHandle)( + pi_native_handle nativeHandle, pi_context *piContext) { assert(piContext != nullptr); *piContext = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piMemBufferCreate)(pi_context context, pi_mem_flags flags, - size_t size, void *host_ptr, pi_mem *ret_mem) { +__SYCL_EXPORT pi_result OCL(piMemBufferCreate)(pi_context context, + pi_mem_flags flags, size_t size, + void *host_ptr, + pi_mem *ret_mem) { pi_result ret_err = PI_INVALID_OPERATION; *ret_mem = cast(clCreateBuffer(cast(context), cast(flags), size, @@ -516,10 +523,9 @@ pi_result OCL(piMemBufferCreate)(pi_context context, pi_mem_flags flags, return ret_err; } -pi_result OCL(piMemImageCreate)(pi_context context, pi_mem_flags flags, - const pi_image_format *image_format, - const pi_image_desc *image_desc, void *host_ptr, - pi_mem *ret_mem) { +__SYCL_EXPORT pi_result OCL(piMemImageCreate)( + pi_context context, pi_mem_flags flags, const pi_image_format *image_format, + const pi_image_desc *image_desc, void *host_ptr, pi_mem *ret_mem) { pi_result ret_err = PI_INVALID_OPERATION; *ret_mem = cast( clCreateImage(cast(context), cast(flags), @@ -530,9 +536,9 @@ pi_result OCL(piMemImageCreate)(pi_context context, pi_mem_flags flags, return ret_err; } -pi_result OCL(piMemBufferPartition)(pi_mem buffer, pi_mem_flags flags, - pi_buffer_create_type buffer_create_type, - void *buffer_create_info, pi_mem *ret_mem) { +__SYCL_EXPORT pi_result OCL(piMemBufferPartition)( + pi_mem buffer, pi_mem_flags flags, pi_buffer_create_type buffer_create_type, + void *buffer_create_info, pi_mem *ret_mem) { pi_result ret_err = PI_INVALID_OPERATION; *ret_mem = cast( @@ -542,17 +548,16 @@ pi_result OCL(piMemBufferPartition)(pi_mem buffer, pi_mem_flags flags, return ret_err; } -pi_result OCL(piextMemCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_mem *piMem) { +__SYCL_EXPORT pi_result OCL(piextMemCreateWithNativeHandle)( + pi_native_handle nativeHandle, pi_mem *piMem) { assert(piMem != nullptr); *piMem = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piclProgramCreateWithSource)(pi_context context, pi_uint32 count, - const char **strings, - const size_t *lengths, - pi_program *ret_program) { +__SYCL_EXPORT pi_result OCL(piclProgramCreateWithSource)( + pi_context context, pi_uint32 count, const char **strings, + const size_t *lengths, pi_program *ret_program) { pi_result ret_err = PI_INVALID_OPERATION; *ret_program = cast( @@ -561,7 +566,7 @@ pi_result OCL(piclProgramCreateWithSource)(pi_context context, pi_uint32 count, return ret_err; } -pi_result OCL(piclProgramCreateWithBinary)( +__SYCL_EXPORT pi_result OCL(piclProgramCreateWithBinary)( pi_context context, pi_uint32 num_devices, const pi_device *device_list, const size_t *lengths, const unsigned char **binaries, pi_int32 *binary_status, pi_program *ret_program) { @@ -574,13 +579,12 @@ pi_result OCL(piclProgramCreateWithBinary)( return ret_err; } -pi_result OCL(piProgramLink)(pi_context context, pi_uint32 num_devices, - const pi_device *device_list, const char *options, - pi_uint32 num_input_programs, - const pi_program *input_programs, - void (*pfn_notify)(pi_program program, - void *user_data), - void *user_data, pi_program *ret_program) { +__SYCL_EXPORT pi_result OCL(piProgramLink)( + pi_context context, pi_uint32 num_devices, const pi_device *device_list, + const char *options, pi_uint32 num_input_programs, + const pi_program *input_programs, + void (*pfn_notify)(pi_program program, void *user_data), void *user_data, + pi_program *ret_program) { pi_result ret_err = PI_INVALID_OPERATION; *ret_program = cast( @@ -593,8 +597,9 @@ pi_result OCL(piProgramLink)(pi_context context, pi_uint32 num_devices, return ret_err; } -pi_result OCL(piKernelCreate)(pi_program program, const char *kernel_name, - pi_kernel *ret_kernel) { +__SYCL_EXPORT pi_result OCL(piKernelCreate)(pi_program program, + const char *kernel_name, + pi_kernel *ret_kernel) { pi_result ret_err = PI_INVALID_OPERATION; *ret_kernel = cast(clCreateKernel( @@ -602,7 +607,8 @@ pi_result OCL(piKernelCreate)(pi_program program, const char *kernel_name, return ret_err; } -pi_result OCL(piEventCreate)(pi_context context, pi_event *ret_event) { +__SYCL_EXPORT pi_result OCL(piEventCreate)(pi_context context, + pi_event *ret_event) { pi_result ret_err = PI_INVALID_OPERATION; *ret_event = cast( @@ -610,14 +616,14 @@ pi_result OCL(piEventCreate)(pi_context context, pi_event *ret_event) { return ret_err; } -pi_result OCL(piextEventCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_event *piEvent) { +__SYCL_EXPORT pi_result OCL(piextEventCreateWithNativeHandle)( + pi_native_handle nativeHandle, pi_event *piEvent) { assert(piEvent != nullptr); *piEvent = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piEnqueueMemBufferMap)( +__SYCL_EXPORT pi_result OCL(piEnqueueMemBufferMap)( pi_queue command_queue, pi_mem buffer, pi_bool blocking_map, cl_map_flags map_flags, // TODO: untie from OpenCL size_t offset, size_t size, pi_uint32 num_events_in_wait_list, @@ -644,9 +650,9 @@ pi_result OCL(piEnqueueMemBufferMap)( /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -pi_result OCL(piextUSMHostAlloc)(void **result_ptr, pi_context context, - pi_usm_mem_properties *properties, size_t size, - pi_uint32 alignment) { +__SYCL_EXPORT pi_result OCL(piextUSMHostAlloc)( + void **result_ptr, pi_context context, pi_usm_mem_properties *properties, + size_t size, pi_uint32 alignment) { void *Ptr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -675,10 +681,9 @@ pi_result OCL(piextUSMHostAlloc)(void **result_ptr, pi_context context, /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -pi_result OCL(piextUSMDeviceAlloc)(void **result_ptr, pi_context context, - pi_device device, - pi_usm_mem_properties *properties, - size_t size, pi_uint32 alignment) { +__SYCL_EXPORT pi_result OCL(piextUSMDeviceAlloc)( + void **result_ptr, pi_context context, pi_device device, + pi_usm_mem_properties *properties, size_t size, pi_uint32 alignment) { void *Ptr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -708,10 +713,9 @@ pi_result OCL(piextUSMDeviceAlloc)(void **result_ptr, pi_context context, /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -pi_result OCL(piextUSMSharedAlloc)(void **result_ptr, pi_context context, - pi_device device, - pi_usm_mem_properties *properties, - size_t size, pi_uint32 alignment) { +__SYCL_EXPORT pi_result OCL(piextUSMSharedAlloc)( + void **result_ptr, pi_context context, pi_device device, + pi_usm_mem_properties *properties, size_t size, pi_uint32 alignment) { void *Ptr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -737,7 +741,7 @@ pi_result OCL(piextUSMSharedAlloc)(void **result_ptr, pi_context context, /// /// \param context is the pi_context of the allocation /// \param ptr is the memory to be freed -pi_result OCL(piextUSMFree)(pi_context context, void *ptr) { +__SYCL_EXPORT pi_result OCL(piextUSMFree)(pi_context context, void *ptr) { clMemFreeINTEL_fn FuncPtr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -758,9 +762,10 @@ pi_result OCL(piextUSMFree)(pi_context context, void *ptr) { /// \param arg_index is the index of the kernel argument /// \param arg_size is the size in bytes of the argument (ignored in CL) /// \param arg_value is the pointer argument -pi_result OCL(piextKernelSetArgPointer)(pi_kernel kernel, pi_uint32 arg_index, - size_t arg_size, - const void *arg_value) { +__SYCL_EXPORT pi_result OCL(piextKernelSetArgPointer)(pi_kernel kernel, + pi_uint32 arg_index, + size_t arg_size, + const void *arg_value) { // Size is unused in CL as pointer args are passed by value. @@ -799,11 +804,10 @@ pi_result OCL(piextKernelSetArgPointer)(pi_kernel kernel, pi_uint32 arg_index, /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -pi_result OCL(piextUSMEnqueueMemset)(pi_queue queue, void *ptr, pi_int32 value, - size_t count, - pi_uint32 num_events_in_waitlist, - const pi_event *events_waitlist, - pi_event *event) { +__SYCL_EXPORT pi_result +OCL(piextUSMEnqueueMemset)(pi_queue queue, void *ptr, pi_int32 value, + size_t count, pi_uint32 num_events_in_waitlist, + const pi_event *events_waitlist, pi_event *event) { // Have to look up the context from the kernel cl_context CLContext; @@ -839,12 +843,10 @@ pi_result OCL(piextUSMEnqueueMemset)(pi_queue queue, void *ptr, pi_int32 value, /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -pi_result OCL(piextUSMEnqueueMemcpy)(pi_queue queue, pi_bool blocking, - void *dst_ptr, const void *src_ptr, - size_t size, - pi_uint32 num_events_in_waitlist, - const pi_event *events_waitlist, - pi_event *event) { +__SYCL_EXPORT pi_result OCL(piextUSMEnqueueMemcpy)( + pi_queue queue, pi_bool blocking, void *dst_ptr, const void *src_ptr, + size_t size, pi_uint32 num_events_in_waitlist, + const pi_event *events_waitlist, pi_event *event) { // Have to look up the context from the kernel cl_context CLContext; @@ -879,12 +881,10 @@ pi_result OCL(piextUSMEnqueueMemcpy)(pi_queue queue, pi_bool blocking, /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -pi_result OCL(piextUSMEnqueuePrefetch)(pi_queue queue, const void *ptr, - size_t size, - pi_usm_migration_flags flags, - pi_uint32 num_events_in_waitlist, - const pi_event *events_waitlist, - pi_event *event) { +__SYCL_EXPORT pi_result OCL(piextUSMEnqueuePrefetch)( + pi_queue queue, const void *ptr, size_t size, pi_usm_migration_flags flags, + pi_uint32 num_events_in_waitlist, const pi_event *events_waitlist, + pi_event *event) { return cast(clEnqueueMarkerWithWaitList( cast(queue), num_events_in_waitlist, @@ -924,9 +924,10 @@ pi_result OCL(piextUSMEnqueuePrefetch)(pi_queue queue, const void *ptr, /// \param advice is device specific advice /// \param event is the event that represents this operation // USM memadvise API to govern behavior of automatic migration mechanisms -pi_result OCL(piextUSMEnqueueMemAdvise)(pi_queue queue, const void *ptr, - size_t length, int advice, - pi_event *event) { +__SYCL_EXPORT pi_result OCL(piextUSMEnqueueMemAdvise)(pi_queue queue, + const void *ptr, + size_t length, int advice, + pi_event *event) { return cast( clEnqueueMarkerWithWaitList(cast(queue), 0, nullptr, @@ -976,11 +977,9 @@ pi_result OCL(piextUSMEnqueueMemAdvise)(pi_queue queue, const void *ptr, /// \param param_value_size is the size of the result in bytes /// \param param_value is the result /// \param param_value_ret is how many bytes were written -pi_result OCL(piextUSMGetMemAllocInfo)(pi_context context, const void *ptr, - pi_mem_info param_name, - size_t param_value_size, - void *param_value, - size_t *param_value_size_ret) { +__SYCL_EXPORT pi_result OCL(piextUSMGetMemAllocInfo)( + pi_context context, const void *ptr, pi_mem_info param_name, + size_t param_value_size, void *param_value, size_t *param_value_size_ret) { clGetMemAllocInfoINTEL_fn FuncPtr = nullptr; pi_result RetVal = @@ -1007,10 +1006,10 @@ pi_result OCL(piextUSMGetMemAllocInfo)(pi_context context, const void *ptr, /// If param_name is PI_USM_INDIRECT_ACCESS, the value will be a ptr to /// the pi_bool value PI_TRUE /// If param_name is PI_USM_PTRS, the value will be an array of ptrs -pi_result OCL(piKernelSetExecInfo)(pi_kernel kernel, - pi_kernel_exec_info param_name, - size_t param_value_size, - const void *param_value) { +__SYCL_EXPORT pi_result OCL(piKernelSetExecInfo)(pi_kernel kernel, + pi_kernel_exec_info param_name, + size_t param_value_size, + const void *param_value) { if (param_name == PI_USM_INDIRECT_ACCESS && *(static_cast(param_value)) == PI_TRUE) { return USMSetIndirectAccess(kernel); @@ -1024,7 +1023,7 @@ typedef CL_API_ENTRY cl_int(CL_API_CALL *clSetProgramSpecializationConstant_fn)( cl_program program, cl_uint spec_id, size_t spec_size, const void *spec_value); -static pi_result OCL(piextProgramSetSpecializationConstantImpl)( +__SYCL_EXPORT pi_result OCL(piextProgramSetSpecializationConstantImpl)( pi_program prog, unsigned int spec_id, size_t spec_size, const void *spec_value) { cl_program ClProg = cast(prog); @@ -1052,14 +1051,14 @@ static pi_result OCL(piextProgramSetSpecializationConstantImpl)( /// \param nativeHandle is a pointer to be set to the native handle /// /// PI_SUCCESS -pi_result OCL(piextGetNativeHandle)(void *piObj, - pi_native_handle *nativeHandle) { +__SYCL_EXPORT pi_result +OCL(piextGetNativeHandle)(void *piObj, pi_native_handle *nativeHandle) { assert(nativeHandle != nullptr); *nativeHandle = reinterpret_cast(piObj); return PI_SUCCESS; } -pi_result piPluginInit(pi_plugin *PluginInit) { +__SYCL_EXPORT pi_result piPluginInit(pi_plugin *PluginInit) { int CompareVersions = strcmp(PluginInit->PiVersion, SupportedVersion); if (CompareVersions < 0) { // PI interface supports lower version of PI. From a24bd7950a2cde733b60edff4f9fc912c1dca117 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Mon, 4 May 2020 14:54:59 -0700 Subject: [PATCH 20/32] [SYCL] Export only *pi symbols in libpi_opencl.so Cleaned up some unnecessary versioning code Changed library scope from SHARED to MODULE to limit its usage Moved duplicate code out of condition Signed-off-by: Byoungro So --- sycl/include/CL/sycl/detail/pi.h | 2 +- sycl/plugins/opencl/CMakeLists.txt | 26 ++++++++++---------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index ab0bd9440cbfc..46e1ee426abd4 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -46,7 +46,7 @@ // elsewhere, e.g. in the pi_opencl, but constants/enums mapping is now // done here, for efficiency and simplicity. // -#include "export.hpp" +#include #include #include #include diff --git a/sycl/plugins/opencl/CMakeLists.txt b/sycl/plugins/opencl/CMakeLists.txt index b5621e1127ca0..535fd491a3421 100644 --- a/sycl/plugins/opencl/CMakeLists.txt +++ b/sycl/plugins/opencl/CMakeLists.txt @@ -9,16 +9,14 @@ #TODO: remove dependency on pi.hpp in sycl project. #TODO: Currently, the pi.hpp header is common between sycl and plugin library sources. #This can be changed by copying the pi.hpp file in the plugins project. -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/../../source/version.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - @ONLY) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -add_library(pi_opencl SHARED + +# We chose MODULE type because libpi_opencl.so should never be linked dynamically to a target. +# MODULE will limit this library to be used to load symbols via dllopen only +add_library(pi_opencl MODULE "${sycl_inc_dir}/CL/sycl/detail/pi.h" "pi_opencl.cpp" - ${CMAKE_CURRENT_BINARY_DIR}/version.rc ) add_dependencies(pi_opencl @@ -33,13 +31,14 @@ set_target_properties(pi_opencl PROPERTIES LINKER_LANGUAGE CXX) #preprocessor definitions for compiling a target's sources. We do not need it for pi_opencl target_include_directories(pi_opencl PRIVATE "${sycl_inc_dir}") +target_link_libraries( pi_opencl + PRIVATE OpenCL::Headers + PRIVATE ${OpenCL_LIBRARIES} +) if (MSVC) + # by defining __SYCL_BUILD_SYCL_DLL, we can use __declspec(dllexport) + # which are individually tagged for all pi* symbols in pi_opencl.cpp target_compile_definitions(pi_opencl PRIVATE __SYCL_BUILD_SYCL_DLL) - target_link_libraries(pi_opencl PRIVATE shlwapi) - target_link_libraries( pi_opencl - PRIVATE OpenCL::Headers - PRIVATE ${OpenCL_LIBRARIES} - ) else() # we set the visibility of all symbols 'hidden' by default. # In *.cpp files, we set exported symbols with visibility==default individually @@ -51,8 +50,6 @@ else() #link pi_opencl with OpenCL headers and ICD Loader. target_link_libraries( pi_opencl - PRIVATE OpenCL::Headers - PRIVATE ${OpenCL_LIBRARIES} # Filter symbols based on the scope defined in the script file, # and export pi* function symbols in the library. PRIVATE "-Wl,--version-script=${linker_script}" @@ -61,9 +58,6 @@ endif() add_common_options(pi_opencl) -set_target_properties(pi_opencl PROPERTIES - VERSION ${SYCL_VERSION_STRING} - SOVERSION ${SYCL_MAJOR_VERSION}) install(TARGETS pi_opencl LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT pi_opencl RUNTIME DESTINATION "bin" COMPONENT pi_opencl) From 89a1cc80e24943dd013303aa6ba7c4eaf5ff9551 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Mon, 4 May 2020 15:01:32 -0700 Subject: [PATCH 21/32] moved down include to conform to clang style Signed-off-by: Byoungro So --- sycl/include/CL/sycl/detail/pi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index 46e1ee426abd4..9755c99ce94bc 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -46,9 +46,9 @@ // elsewhere, e.g. in the pi_opencl, but constants/enums mapping is now // done here, for efficiency and simplicity. // -#include #include #include +#include #include #ifdef __cplusplus From f44700680d80883420c59d1d9b1fb5804051f518 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Tue, 5 May 2020 15:46:09 -0700 Subject: [PATCH 22/32] removed __SYCL_EXPORT in pi_opencl.cpp because we already attached it in pi.h Signed-off-by: Byoungro So --- sycl/plugins/opencl/CMakeLists.txt | 6 +- sycl/plugins/opencl/pi_opencl.cpp | 225 +++++++++++++++-------------- 2 files changed, 116 insertions(+), 115 deletions(-) diff --git a/sycl/plugins/opencl/CMakeLists.txt b/sycl/plugins/opencl/CMakeLists.txt index 535fd491a3421..85096b7d99f28 100644 --- a/sycl/plugins/opencl/CMakeLists.txt +++ b/sycl/plugins/opencl/CMakeLists.txt @@ -13,7 +13,7 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) # We chose MODULE type because libpi_opencl.so should never be linked dynamically to a target. -# MODULE will limit this library to be used to load symbols via dllopen only +# MODULE will limit this library to be used to load symbols via dlopen only add_library(pi_opencl MODULE "${sycl_inc_dir}/CL/sycl/detail/pi.h" "pi_opencl.cpp" @@ -37,11 +37,11 @@ target_link_libraries( pi_opencl ) if (MSVC) # by defining __SYCL_BUILD_SYCL_DLL, we can use __declspec(dllexport) - # which are individually tagged for all pi* symbols in pi_opencl.cpp + # which are individually tagged for all pi* symbols in pi.h target_compile_definitions(pi_opencl PRIVATE __SYCL_BUILD_SYCL_DLL) else() # we set the visibility of all symbols 'hidden' by default. - # In *.cpp files, we set exported symbols with visibility==default individually + # In pi.h file, we set exported symbols with visibility==default individually target_compile_options(pi_opencl PUBLIC -fvisibility=hidden) # This script file is used to allow exporting pi* symbols only. diff --git a/sycl/plugins/opencl/pi_opencl.cpp b/sycl/plugins/opencl/pi_opencl.cpp index 35c4b884af252..2bf2f3b5a39c1 100644 --- a/sycl/plugins/opencl/pi_opencl.cpp +++ b/sycl/plugins/opencl/pi_opencl.cpp @@ -15,7 +15,6 @@ /// \ingroup sycl_pi_ocl #include "CL/opencl.h" -#include #include #include @@ -165,9 +164,8 @@ extern "C" { #define OCL(pi_api) pi_api // Example of a PI interface that does not map exactly to an OpenCL one. -__SYCL_EXPORT pi_result OCL(piPlatformsGet)(pi_uint32 num_entries, - pi_platform *platforms, - pi_uint32 *num_platforms) { +pi_result OCL(piPlatformsGet)(pi_uint32 num_entries, pi_platform *platforms, + pi_uint32 *num_platforms) { cl_int result = clGetPlatformIDs(cast(num_entries), cast(platforms), cast(num_platforms)); @@ -182,11 +180,9 @@ __SYCL_EXPORT pi_result OCL(piPlatformsGet)(pi_uint32 num_entries, } // Example of a PI interface that does not map exactly to an OpenCL one. -__SYCL_EXPORT pi_result OCL(piDevicesGet)(pi_platform platform, - pi_device_type device_type, - pi_uint32 num_entries, - pi_device *devices, - pi_uint32 *num_devices) { +pi_result OCL(piDevicesGet)(pi_platform platform, pi_device_type device_type, + pi_uint32 num_entries, pi_device *devices, + pi_uint32 *num_devices) { cl_int result = clGetDeviceIDs( cast(platform), cast(device_type), cast(num_entries), cast(devices), @@ -201,9 +197,10 @@ __SYCL_EXPORT pi_result OCL(piDevicesGet)(pi_platform platform, return cast(result); } -__SYCL_EXPORT pi_result OCL(piextDeviceSelectBinary)( - pi_device device, pi_device_binary *images, pi_uint32 num_images, - pi_uint32 *selected_image_ind) { +pi_result OCL(piextDeviceSelectBinary)(pi_device device, + pi_device_binary *images, + pi_uint32 num_images, + pi_uint32 *selected_image_ind) { // TODO: this is a bare-bones implementation for choosing a device image // that would be compatible with the targeted device. An AOT-compiled @@ -272,16 +269,15 @@ __SYCL_EXPORT pi_result OCL(piextDeviceSelectBinary)( return PI_INVALID_BINARY; } -__SYCL_EXPORT pi_result OCL(piextDeviceCreateWithNativeHandle)( - pi_native_handle nativeHandle, pi_device *piDevice) { +pi_result OCL(piextDeviceCreateWithNativeHandle)(pi_native_handle nativeHandle, + pi_device *piDevice) { assert(piDevice != nullptr); *piDevice = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -__SYCL_EXPORT pi_result OCL(piQueueCreate)(pi_context context, pi_device device, - pi_queue_properties properties, - pi_queue *queue) { +pi_result OCL(piQueueCreate)(pi_context context, pi_device device, + pi_queue_properties properties, pi_queue *queue) { assert(queue && "piQueueCreate failed, queue argument is null"); cl_platform_id curPlatform; @@ -320,16 +316,15 @@ __SYCL_EXPORT pi_result OCL(piQueueCreate)(pi_context context, pi_device device, return cast(ret_err); } -__SYCL_EXPORT pi_result OCL(piextQueueCreateWithNativeHandle)( - pi_native_handle nativeHandle, pi_queue *piQueue) { +pi_result OCL(piextQueueCreateWithNativeHandle)(pi_native_handle nativeHandle, + pi_queue *piQueue) { assert(piQueue != nullptr); *piQueue = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -__SYCL_EXPORT pi_result OCL(piProgramCreate)(pi_context context, const void *il, - size_t length, - pi_program *res_program) { +pi_result OCL(piProgramCreate)(pi_context context, const void *il, + size_t length, pi_program *res_program) { size_t deviceCount; @@ -406,16 +401,16 @@ __SYCL_EXPORT pi_result OCL(piProgramCreate)(pi_context context, const void *il, return err; } -__SYCL_EXPORT pi_result OCL(piextProgramCreateWithNativeHandle)( - pi_native_handle nativeHandle, pi_program *piProgram) { +pi_result OCL(piextProgramCreateWithNativeHandle)(pi_native_handle nativeHandle, + pi_program *piProgram) { assert(piProgram != nullptr); *piProgram = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -__SYCL_EXPORT pi_result OCL(piSamplerCreate)( - pi_context context, const pi_sampler_properties *sampler_properties, - pi_sampler *result_sampler) { +pi_result OCL(piSamplerCreate)(pi_context context, + const pi_sampler_properties *sampler_properties, + pi_sampler *result_sampler) { // Initialize properties according to OpenCL 2.1 spec. pi_result error_code; pi_bool normalizedCoords = PI_TRUE; @@ -444,17 +439,17 @@ __SYCL_EXPORT pi_result OCL(piSamplerCreate)( return error_code; } -__SYCL_EXPORT pi_result OCL(piextKernelSetArgMemObj)(pi_kernel kernel, - pi_uint32 arg_index, - const pi_mem *arg_value) { +pi_result OCL(piextKernelSetArgMemObj)(pi_kernel kernel, pi_uint32 arg_index, + const pi_mem *arg_value) { return cast( clSetKernelArg(cast(kernel), cast(arg_index), sizeof(arg_value), cast(arg_value))); } -__SYCL_EXPORT pi_result OCL(piextGetDeviceFunctionPointer)( - pi_device device, pi_program program, const char *func_name, - pi_uint64 *function_pointer_ret) { +pi_result OCL(piextGetDeviceFunctionPointer)(pi_device device, + pi_program program, + const char *func_name, + pi_uint64 *function_pointer_ret) { pi_platform platform; cl_int ret_err = clGetDeviceInfo(cast(device), PI_DEVICE_INFO_PLATFORM, @@ -489,12 +484,12 @@ __SYCL_EXPORT pi_result OCL(piextGetDeviceFunctionPointer)( function_pointer_ret)); } -__SYCL_EXPORT pi_result OCL(piContextCreate)( - const pi_context_properties *properties, pi_uint32 num_devices, - const pi_device *devices, - void (*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, - void *user_data1), - void *user_data, pi_context *retcontext) { +pi_result OCL(piContextCreate)(const pi_context_properties *properties, + pi_uint32 num_devices, const pi_device *devices, + void (*pfn_notify)(const char *errinfo, + const void *private_info, + size_t cb, void *user_data1), + void *user_data, pi_context *retcontext) { pi_result ret = PI_INVALID_OPERATION; *retcontext = cast( clCreateContext(properties, cast(num_devices), @@ -504,17 +499,15 @@ __SYCL_EXPORT pi_result OCL(piContextCreate)( return ret; } -__SYCL_EXPORT pi_result OCL(piextContextCreateWithNativeHandle)( - pi_native_handle nativeHandle, pi_context *piContext) { +pi_result OCL(piextContextCreateWithNativeHandle)(pi_native_handle nativeHandle, + pi_context *piContext) { assert(piContext != nullptr); *piContext = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -__SYCL_EXPORT pi_result OCL(piMemBufferCreate)(pi_context context, - pi_mem_flags flags, size_t size, - void *host_ptr, - pi_mem *ret_mem) { +pi_result OCL(piMemBufferCreate)(pi_context context, pi_mem_flags flags, + size_t size, void *host_ptr, pi_mem *ret_mem) { pi_result ret_err = PI_INVALID_OPERATION; *ret_mem = cast(clCreateBuffer(cast(context), cast(flags), size, @@ -523,9 +516,10 @@ __SYCL_EXPORT pi_result OCL(piMemBufferCreate)(pi_context context, return ret_err; } -__SYCL_EXPORT pi_result OCL(piMemImageCreate)( - pi_context context, pi_mem_flags flags, const pi_image_format *image_format, - const pi_image_desc *image_desc, void *host_ptr, pi_mem *ret_mem) { +pi_result OCL(piMemImageCreate)(pi_context context, pi_mem_flags flags, + const pi_image_format *image_format, + const pi_image_desc *image_desc, void *host_ptr, + pi_mem *ret_mem) { pi_result ret_err = PI_INVALID_OPERATION; *ret_mem = cast( clCreateImage(cast(context), cast(flags), @@ -536,9 +530,9 @@ __SYCL_EXPORT pi_result OCL(piMemImageCreate)( return ret_err; } -__SYCL_EXPORT pi_result OCL(piMemBufferPartition)( - pi_mem buffer, pi_mem_flags flags, pi_buffer_create_type buffer_create_type, - void *buffer_create_info, pi_mem *ret_mem) { +pi_result OCL(piMemBufferPartition)(pi_mem buffer, pi_mem_flags flags, + pi_buffer_create_type buffer_create_type, + void *buffer_create_info, pi_mem *ret_mem) { pi_result ret_err = PI_INVALID_OPERATION; *ret_mem = cast( @@ -548,16 +542,17 @@ __SYCL_EXPORT pi_result OCL(piMemBufferPartition)( return ret_err; } -__SYCL_EXPORT pi_result OCL(piextMemCreateWithNativeHandle)( - pi_native_handle nativeHandle, pi_mem *piMem) { +pi_result OCL(piextMemCreateWithNativeHandle)(pi_native_handle nativeHandle, + pi_mem *piMem) { assert(piMem != nullptr); *piMem = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -__SYCL_EXPORT pi_result OCL(piclProgramCreateWithSource)( - pi_context context, pi_uint32 count, const char **strings, - const size_t *lengths, pi_program *ret_program) { +pi_result OCL(piclProgramCreateWithSource)(pi_context context, pi_uint32 count, + const char **strings, + const size_t *lengths, + pi_program *ret_program) { pi_result ret_err = PI_INVALID_OPERATION; *ret_program = cast( @@ -566,7 +561,7 @@ __SYCL_EXPORT pi_result OCL(piclProgramCreateWithSource)( return ret_err; } -__SYCL_EXPORT pi_result OCL(piclProgramCreateWithBinary)( +pi_result OCL(piclProgramCreateWithBinary)( pi_context context, pi_uint32 num_devices, const pi_device *device_list, const size_t *lengths, const unsigned char **binaries, pi_int32 *binary_status, pi_program *ret_program) { @@ -579,12 +574,13 @@ __SYCL_EXPORT pi_result OCL(piclProgramCreateWithBinary)( return ret_err; } -__SYCL_EXPORT pi_result OCL(piProgramLink)( - pi_context context, pi_uint32 num_devices, const pi_device *device_list, - const char *options, pi_uint32 num_input_programs, - const pi_program *input_programs, - void (*pfn_notify)(pi_program program, void *user_data), void *user_data, - pi_program *ret_program) { +pi_result OCL(piProgramLink)(pi_context context, pi_uint32 num_devices, + const pi_device *device_list, const char *options, + pi_uint32 num_input_programs, + const pi_program *input_programs, + void (*pfn_notify)(pi_program program, + void *user_data), + void *user_data, pi_program *ret_program) { pi_result ret_err = PI_INVALID_OPERATION; *ret_program = cast( @@ -597,9 +593,8 @@ __SYCL_EXPORT pi_result OCL(piProgramLink)( return ret_err; } -__SYCL_EXPORT pi_result OCL(piKernelCreate)(pi_program program, - const char *kernel_name, - pi_kernel *ret_kernel) { +pi_result OCL(piKernelCreate)(pi_program program, const char *kernel_name, + pi_kernel *ret_kernel) { pi_result ret_err = PI_INVALID_OPERATION; *ret_kernel = cast(clCreateKernel( @@ -607,8 +602,7 @@ __SYCL_EXPORT pi_result OCL(piKernelCreate)(pi_program program, return ret_err; } -__SYCL_EXPORT pi_result OCL(piEventCreate)(pi_context context, - pi_event *ret_event) { +pi_result OCL(piEventCreate)(pi_context context, pi_event *ret_event) { pi_result ret_err = PI_INVALID_OPERATION; *ret_event = cast( @@ -616,14 +610,14 @@ __SYCL_EXPORT pi_result OCL(piEventCreate)(pi_context context, return ret_err; } -__SYCL_EXPORT pi_result OCL(piextEventCreateWithNativeHandle)( - pi_native_handle nativeHandle, pi_event *piEvent) { +pi_result OCL(piextEventCreateWithNativeHandle)(pi_native_handle nativeHandle, + pi_event *piEvent) { assert(piEvent != nullptr); *piEvent = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -__SYCL_EXPORT pi_result OCL(piEnqueueMemBufferMap)( +pi_result OCL(piEnqueueMemBufferMap)( pi_queue command_queue, pi_mem buffer, pi_bool blocking_map, cl_map_flags map_flags, // TODO: untie from OpenCL size_t offset, size_t size, pi_uint32 num_events_in_wait_list, @@ -650,9 +644,9 @@ __SYCL_EXPORT pi_result OCL(piEnqueueMemBufferMap)( /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -__SYCL_EXPORT pi_result OCL(piextUSMHostAlloc)( - void **result_ptr, pi_context context, pi_usm_mem_properties *properties, - size_t size, pi_uint32 alignment) { +pi_result OCL(piextUSMHostAlloc)(void **result_ptr, pi_context context, + pi_usm_mem_properties *properties, size_t size, + pi_uint32 alignment) { void *Ptr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -681,9 +675,10 @@ __SYCL_EXPORT pi_result OCL(piextUSMHostAlloc)( /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -__SYCL_EXPORT pi_result OCL(piextUSMDeviceAlloc)( - void **result_ptr, pi_context context, pi_device device, - pi_usm_mem_properties *properties, size_t size, pi_uint32 alignment) { +pi_result OCL(piextUSMDeviceAlloc)(void **result_ptr, pi_context context, + pi_device device, + pi_usm_mem_properties *properties, + size_t size, pi_uint32 alignment) { void *Ptr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -713,9 +708,10 @@ __SYCL_EXPORT pi_result OCL(piextUSMDeviceAlloc)( /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -__SYCL_EXPORT pi_result OCL(piextUSMSharedAlloc)( - void **result_ptr, pi_context context, pi_device device, - pi_usm_mem_properties *properties, size_t size, pi_uint32 alignment) { +pi_result OCL(piextUSMSharedAlloc)(void **result_ptr, pi_context context, + pi_device device, + pi_usm_mem_properties *properties, + size_t size, pi_uint32 alignment) { void *Ptr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -741,7 +737,7 @@ __SYCL_EXPORT pi_result OCL(piextUSMSharedAlloc)( /// /// \param context is the pi_context of the allocation /// \param ptr is the memory to be freed -__SYCL_EXPORT pi_result OCL(piextUSMFree)(pi_context context, void *ptr) { +pi_result OCL(piextUSMFree)(pi_context context, void *ptr) { clMemFreeINTEL_fn FuncPtr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -762,10 +758,9 @@ __SYCL_EXPORT pi_result OCL(piextUSMFree)(pi_context context, void *ptr) { /// \param arg_index is the index of the kernel argument /// \param arg_size is the size in bytes of the argument (ignored in CL) /// \param arg_value is the pointer argument -__SYCL_EXPORT pi_result OCL(piextKernelSetArgPointer)(pi_kernel kernel, - pi_uint32 arg_index, - size_t arg_size, - const void *arg_value) { +pi_result OCL(piextKernelSetArgPointer)(pi_kernel kernel, pi_uint32 arg_index, + size_t arg_size, + const void *arg_value) { // Size is unused in CL as pointer args are passed by value. @@ -804,10 +799,11 @@ __SYCL_EXPORT pi_result OCL(piextKernelSetArgPointer)(pi_kernel kernel, /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -__SYCL_EXPORT pi_result -OCL(piextUSMEnqueueMemset)(pi_queue queue, void *ptr, pi_int32 value, - size_t count, pi_uint32 num_events_in_waitlist, - const pi_event *events_waitlist, pi_event *event) { +pi_result OCL(piextUSMEnqueueMemset)(pi_queue queue, void *ptr, pi_int32 value, + size_t count, + pi_uint32 num_events_in_waitlist, + const pi_event *events_waitlist, + pi_event *event) { // Have to look up the context from the kernel cl_context CLContext; @@ -843,10 +839,12 @@ OCL(piextUSMEnqueueMemset)(pi_queue queue, void *ptr, pi_int32 value, /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -__SYCL_EXPORT pi_result OCL(piextUSMEnqueueMemcpy)( - pi_queue queue, pi_bool blocking, void *dst_ptr, const void *src_ptr, - size_t size, pi_uint32 num_events_in_waitlist, - const pi_event *events_waitlist, pi_event *event) { +pi_result OCL(piextUSMEnqueueMemcpy)(pi_queue queue, pi_bool blocking, + void *dst_ptr, const void *src_ptr, + size_t size, + pi_uint32 num_events_in_waitlist, + const pi_event *events_waitlist, + pi_event *event) { // Have to look up the context from the kernel cl_context CLContext; @@ -881,10 +879,12 @@ __SYCL_EXPORT pi_result OCL(piextUSMEnqueueMemcpy)( /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -__SYCL_EXPORT pi_result OCL(piextUSMEnqueuePrefetch)( - pi_queue queue, const void *ptr, size_t size, pi_usm_migration_flags flags, - pi_uint32 num_events_in_waitlist, const pi_event *events_waitlist, - pi_event *event) { +pi_result OCL(piextUSMEnqueuePrefetch)(pi_queue queue, const void *ptr, + size_t size, + pi_usm_migration_flags flags, + pi_uint32 num_events_in_waitlist, + const pi_event *events_waitlist, + pi_event *event) { return cast(clEnqueueMarkerWithWaitList( cast(queue), num_events_in_waitlist, @@ -924,10 +924,9 @@ __SYCL_EXPORT pi_result OCL(piextUSMEnqueuePrefetch)( /// \param advice is device specific advice /// \param event is the event that represents this operation // USM memadvise API to govern behavior of automatic migration mechanisms -__SYCL_EXPORT pi_result OCL(piextUSMEnqueueMemAdvise)(pi_queue queue, - const void *ptr, - size_t length, int advice, - pi_event *event) { +pi_result OCL(piextUSMEnqueueMemAdvise)(pi_queue queue, const void *ptr, + size_t length, int advice, + pi_event *event) { return cast( clEnqueueMarkerWithWaitList(cast(queue), 0, nullptr, @@ -977,9 +976,11 @@ __SYCL_EXPORT pi_result OCL(piextUSMEnqueueMemAdvise)(pi_queue queue, /// \param param_value_size is the size of the result in bytes /// \param param_value is the result /// \param param_value_ret is how many bytes were written -__SYCL_EXPORT pi_result OCL(piextUSMGetMemAllocInfo)( - pi_context context, const void *ptr, pi_mem_info param_name, - size_t param_value_size, void *param_value, size_t *param_value_size_ret) { +pi_result OCL(piextUSMGetMemAllocInfo)(pi_context context, const void *ptr, + pi_mem_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret) { clGetMemAllocInfoINTEL_fn FuncPtr = nullptr; pi_result RetVal = @@ -1006,10 +1007,10 @@ __SYCL_EXPORT pi_result OCL(piextUSMGetMemAllocInfo)( /// If param_name is PI_USM_INDIRECT_ACCESS, the value will be a ptr to /// the pi_bool value PI_TRUE /// If param_name is PI_USM_PTRS, the value will be an array of ptrs -__SYCL_EXPORT pi_result OCL(piKernelSetExecInfo)(pi_kernel kernel, - pi_kernel_exec_info param_name, - size_t param_value_size, - const void *param_value) { +pi_result OCL(piKernelSetExecInfo)(pi_kernel kernel, + pi_kernel_exec_info param_name, + size_t param_value_size, + const void *param_value) { if (param_name == PI_USM_INDIRECT_ACCESS && *(static_cast(param_value)) == PI_TRUE) { return USMSetIndirectAccess(kernel); @@ -1023,7 +1024,7 @@ typedef CL_API_ENTRY cl_int(CL_API_CALL *clSetProgramSpecializationConstant_fn)( cl_program program, cl_uint spec_id, size_t spec_size, const void *spec_value); -__SYCL_EXPORT pi_result OCL(piextProgramSetSpecializationConstantImpl)( +pi_result OCL(piextProgramSetSpecializationConstantImpl)( pi_program prog, unsigned int spec_id, size_t spec_size, const void *spec_value) { cl_program ClProg = cast(prog); @@ -1051,14 +1052,14 @@ __SYCL_EXPORT pi_result OCL(piextProgramSetSpecializationConstantImpl)( /// \param nativeHandle is a pointer to be set to the native handle /// /// PI_SUCCESS -__SYCL_EXPORT pi_result -OCL(piextGetNativeHandle)(void *piObj, pi_native_handle *nativeHandle) { +pi_result OCL(piextGetNativeHandle)(void *piObj, + pi_native_handle *nativeHandle) { assert(nativeHandle != nullptr); *nativeHandle = reinterpret_cast(piObj); return PI_SUCCESS; } -__SYCL_EXPORT pi_result piPluginInit(pi_plugin *PluginInit) { +pi_result piPluginInit(pi_plugin *PluginInit) { int CompareVersions = strcmp(PluginInit->PiVersion, SupportedVersion); if (CompareVersions < 0) { // PI interface supports lower version of PI. From 4c49f50da1ab1dab4f9afc535352072f92c29512 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Thu, 7 May 2020 16:41:11 -0700 Subject: [PATCH 23/32] match signatures of pi_opencl.cpp with pi.h Also, added regression test for checking pi* export symbols Signed-off-by: Byoungro So --- sycl/plugins/opencl/pi_opencl.cpp | 345 +++++++++--------- .../regression/pi_opencl_symbol_check.cpp | 6 + .../regression/pi_opencl_symbol_check.txt | 42 +++ 3 files changed, 225 insertions(+), 168 deletions(-) create mode 100644 sycl/test/regression/pi_opencl_symbol_check.cpp create mode 100644 sycl/test/regression/pi_opencl_symbol_check.txt diff --git a/sycl/plugins/opencl/pi_opencl.cpp b/sycl/plugins/opencl/pi_opencl.cpp index 2bf2f3b5a39c1..bac966c863bed 100644 --- a/sycl/plugins/opencl/pi_opencl.cpp +++ b/sycl/plugins/opencl/pi_opencl.cpp @@ -160,12 +160,9 @@ static pi_result USMSetIndirectAccess(pi_kernel kernel) { extern "C" { -// Convenience macro makes source code search easier -#define OCL(pi_api) pi_api - // Example of a PI interface that does not map exactly to an OpenCL one. -pi_result OCL(piPlatformsGet)(pi_uint32 num_entries, pi_platform *platforms, - pi_uint32 *num_platforms) { +pi_result piPlatformsGet(pi_uint32 num_entries, pi_platform *platforms, + pi_uint32 *num_platforms) { cl_int result = clGetPlatformIDs(cast(num_entries), cast(platforms), cast(num_platforms)); @@ -180,9 +177,9 @@ pi_result OCL(piPlatformsGet)(pi_uint32 num_entries, pi_platform *platforms, } // Example of a PI interface that does not map exactly to an OpenCL one. -pi_result OCL(piDevicesGet)(pi_platform platform, pi_device_type device_type, - pi_uint32 num_entries, pi_device *devices, - pi_uint32 *num_devices) { +pi_result piDevicesGet(pi_platform platform, pi_device_type device_type, + pi_uint32 num_entries, pi_device *devices, + pi_uint32 *num_devices) { cl_int result = clGetDeviceIDs( cast(platform), cast(device_type), cast(num_entries), cast(devices), @@ -197,10 +194,9 @@ pi_result OCL(piDevicesGet)(pi_platform platform, pi_device_type device_type, return cast(result); } -pi_result OCL(piextDeviceSelectBinary)(pi_device device, - pi_device_binary *images, - pi_uint32 num_images, - pi_uint32 *selected_image_ind) { +pi_result piextDeviceSelectBinary(pi_device device, pi_device_binary *images, + pi_uint32 num_images, + pi_uint32 *selected_image_ind) { // TODO: this is a bare-bones implementation for choosing a device image // that would be compatible with the targeted device. An AOT-compiled @@ -269,15 +265,15 @@ pi_result OCL(piextDeviceSelectBinary)(pi_device device, return PI_INVALID_BINARY; } -pi_result OCL(piextDeviceCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_device *piDevice) { +pi_result piextDeviceCreateWithNativeHandle(pi_native_handle nativeHandle, + pi_device *piDevice) { assert(piDevice != nullptr); *piDevice = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piQueueCreate)(pi_context context, pi_device device, - pi_queue_properties properties, pi_queue *queue) { +pi_result piQueueCreate(pi_context context, pi_device device, + pi_queue_properties properties, pi_queue *queue) { assert(queue && "piQueueCreate failed, queue argument is null"); cl_platform_id curPlatform; @@ -316,15 +312,15 @@ pi_result OCL(piQueueCreate)(pi_context context, pi_device device, return cast(ret_err); } -pi_result OCL(piextQueueCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_queue *piQueue) { +pi_result piextQueueCreateWithNativeHandle(pi_native_handle nativeHandle, + pi_queue *piQueue) { assert(piQueue != nullptr); *piQueue = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piProgramCreate)(pi_context context, const void *il, - size_t length, pi_program *res_program) { +pi_result piProgramCreate(pi_context context, const void *il, size_t length, + pi_program *res_program) { size_t deviceCount; @@ -401,16 +397,16 @@ pi_result OCL(piProgramCreate)(pi_context context, const void *il, return err; } -pi_result OCL(piextProgramCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_program *piProgram) { +pi_result piextProgramCreateWithNativeHandle(pi_native_handle nativeHandle, + pi_program *piProgram) { assert(piProgram != nullptr); *piProgram = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piSamplerCreate)(pi_context context, - const pi_sampler_properties *sampler_properties, - pi_sampler *result_sampler) { +pi_result piSamplerCreate(pi_context context, + const pi_sampler_properties *sampler_properties, + pi_sampler *result_sampler) { // Initialize properties according to OpenCL 2.1 spec. pi_result error_code; pi_bool normalizedCoords = PI_TRUE; @@ -439,17 +435,16 @@ pi_result OCL(piSamplerCreate)(pi_context context, return error_code; } -pi_result OCL(piextKernelSetArgMemObj)(pi_kernel kernel, pi_uint32 arg_index, - const pi_mem *arg_value) { +pi_result piextKernelSetArgMemObj(pi_kernel kernel, pi_uint32 arg_index, + const pi_mem *arg_value) { return cast( clSetKernelArg(cast(kernel), cast(arg_index), sizeof(arg_value), cast(arg_value))); } -pi_result OCL(piextGetDeviceFunctionPointer)(pi_device device, - pi_program program, - const char *func_name, - pi_uint64 *function_pointer_ret) { +pi_result piextGetDeviceFunctionPointer(pi_device device, pi_program program, + const char *func_name, + pi_uint64 *function_pointer_ret) { pi_platform platform; cl_int ret_err = clGetDeviceInfo(cast(device), PI_DEVICE_INFO_PLATFORM, @@ -484,12 +479,12 @@ pi_result OCL(piextGetDeviceFunctionPointer)(pi_device device, function_pointer_ret)); } -pi_result OCL(piContextCreate)(const pi_context_properties *properties, - pi_uint32 num_devices, const pi_device *devices, - void (*pfn_notify)(const char *errinfo, - const void *private_info, - size_t cb, void *user_data1), - void *user_data, pi_context *retcontext) { +pi_result piContextCreate(const pi_context_properties *properties, + pi_uint32 num_devices, const pi_device *devices, + void (*pfn_notify)(const char *errinfo, + const void *private_info, + size_t cb, void *user_data1), + void *user_data, pi_context *retcontext) { pi_result ret = PI_INVALID_OPERATION; *retcontext = cast( clCreateContext(properties, cast(num_devices), @@ -499,15 +494,15 @@ pi_result OCL(piContextCreate)(const pi_context_properties *properties, return ret; } -pi_result OCL(piextContextCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_context *piContext) { +pi_result piextContextCreateWithNativeHandle(pi_native_handle nativeHandle, + pi_context *piContext) { assert(piContext != nullptr); *piContext = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piMemBufferCreate)(pi_context context, pi_mem_flags flags, - size_t size, void *host_ptr, pi_mem *ret_mem) { +pi_result piMemBufferCreate(pi_context context, pi_mem_flags flags, size_t size, + void *host_ptr, pi_mem *ret_mem) { pi_result ret_err = PI_INVALID_OPERATION; *ret_mem = cast(clCreateBuffer(cast(context), cast(flags), size, @@ -516,10 +511,10 @@ pi_result OCL(piMemBufferCreate)(pi_context context, pi_mem_flags flags, return ret_err; } -pi_result OCL(piMemImageCreate)(pi_context context, pi_mem_flags flags, - const pi_image_format *image_format, - const pi_image_desc *image_desc, void *host_ptr, - pi_mem *ret_mem) { +pi_result piMemImageCreate(pi_context context, pi_mem_flags flags, + const pi_image_format *image_format, + const pi_image_desc *image_desc, void *host_ptr, + pi_mem *ret_mem) { pi_result ret_err = PI_INVALID_OPERATION; *ret_mem = cast( clCreateImage(cast(context), cast(flags), @@ -530,9 +525,9 @@ pi_result OCL(piMemImageCreate)(pi_context context, pi_mem_flags flags, return ret_err; } -pi_result OCL(piMemBufferPartition)(pi_mem buffer, pi_mem_flags flags, - pi_buffer_create_type buffer_create_type, - void *buffer_create_info, pi_mem *ret_mem) { +pi_result piMemBufferPartition(pi_mem buffer, pi_mem_flags flags, + pi_buffer_create_type buffer_create_type, + void *buffer_create_info, pi_mem *ret_mem) { pi_result ret_err = PI_INVALID_OPERATION; *ret_mem = cast( @@ -542,17 +537,17 @@ pi_result OCL(piMemBufferPartition)(pi_mem buffer, pi_mem_flags flags, return ret_err; } -pi_result OCL(piextMemCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_mem *piMem) { +pi_result piextMemCreateWithNativeHandle(pi_native_handle nativeHandle, + pi_mem *piMem) { assert(piMem != nullptr); *piMem = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piclProgramCreateWithSource)(pi_context context, pi_uint32 count, - const char **strings, - const size_t *lengths, - pi_program *ret_program) { +pi_result piclProgramCreateWithSource(pi_context context, pi_uint32 count, + const char **strings, + const size_t *lengths, + pi_program *ret_program) { pi_result ret_err = PI_INVALID_OPERATION; *ret_program = cast( @@ -561,10 +556,12 @@ pi_result OCL(piclProgramCreateWithSource)(pi_context context, pi_uint32 count, return ret_err; } -pi_result OCL(piclProgramCreateWithBinary)( - pi_context context, pi_uint32 num_devices, const pi_device *device_list, - const size_t *lengths, const unsigned char **binaries, - pi_int32 *binary_status, pi_program *ret_program) { +pi_result piclProgramCreateWithBinary(pi_context context, pi_uint32 num_devices, + const pi_device *device_list, + const size_t *lengths, + const unsigned char **binaries, + pi_int32 *binary_status, + pi_program *ret_program) { pi_result ret_err = PI_INVALID_OPERATION; *ret_program = cast(clCreateProgramWithBinary( @@ -574,13 +571,12 @@ pi_result OCL(piclProgramCreateWithBinary)( return ret_err; } -pi_result OCL(piProgramLink)(pi_context context, pi_uint32 num_devices, - const pi_device *device_list, const char *options, - pi_uint32 num_input_programs, - const pi_program *input_programs, - void (*pfn_notify)(pi_program program, - void *user_data), - void *user_data, pi_program *ret_program) { +pi_result piProgramLink(pi_context context, pi_uint32 num_devices, + const pi_device *device_list, const char *options, + pi_uint32 num_input_programs, + const pi_program *input_programs, + void (*pfn_notify)(pi_program program, void *user_data), + void *user_data, pi_program *ret_program) { pi_result ret_err = PI_INVALID_OPERATION; *ret_program = cast( @@ -593,8 +589,8 @@ pi_result OCL(piProgramLink)(pi_context context, pi_uint32 num_devices, return ret_err; } -pi_result OCL(piKernelCreate)(pi_program program, const char *kernel_name, - pi_kernel *ret_kernel) { +pi_result piKernelCreate(pi_program program, const char *kernel_name, + pi_kernel *ret_kernel) { pi_result ret_err = PI_INVALID_OPERATION; *ret_kernel = cast(clCreateKernel( @@ -602,7 +598,7 @@ pi_result OCL(piKernelCreate)(pi_program program, const char *kernel_name, return ret_err; } -pi_result OCL(piEventCreate)(pi_context context, pi_event *ret_event) { +pi_result piEventCreate(pi_context context, pi_event *ret_event) { pi_result ret_err = PI_INVALID_OPERATION; *ret_event = cast( @@ -610,14 +606,14 @@ pi_result OCL(piEventCreate)(pi_context context, pi_event *ret_event) { return ret_err; } -pi_result OCL(piextEventCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_event *piEvent) { +pi_result piextEventCreateWithNativeHandle(pi_native_handle nativeHandle, + pi_event *piEvent) { assert(piEvent != nullptr); *piEvent = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piEnqueueMemBufferMap)( +pi_result piEnqueueMemBufferMap( pi_queue command_queue, pi_mem buffer, pi_bool blocking_map, cl_map_flags map_flags, // TODO: untie from OpenCL size_t offset, size_t size, pi_uint32 num_events_in_wait_list, @@ -644,9 +640,9 @@ pi_result OCL(piEnqueueMemBufferMap)( /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -pi_result OCL(piextUSMHostAlloc)(void **result_ptr, pi_context context, - pi_usm_mem_properties *properties, size_t size, - pi_uint32 alignment) { +pi_result piextUSMHostAlloc(void **result_ptr, pi_context context, + pi_usm_mem_properties *properties, size_t size, + pi_uint32 alignment) { void *Ptr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -675,10 +671,10 @@ pi_result OCL(piextUSMHostAlloc)(void **result_ptr, pi_context context, /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -pi_result OCL(piextUSMDeviceAlloc)(void **result_ptr, pi_context context, - pi_device device, - pi_usm_mem_properties *properties, - size_t size, pi_uint32 alignment) { +pi_result piextUSMDeviceAlloc(void **result_ptr, pi_context context, + pi_device device, + pi_usm_mem_properties *properties, size_t size, + pi_uint32 alignment) { void *Ptr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -708,10 +704,10 @@ pi_result OCL(piextUSMDeviceAlloc)(void **result_ptr, pi_context context, /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -pi_result OCL(piextUSMSharedAlloc)(void **result_ptr, pi_context context, - pi_device device, - pi_usm_mem_properties *properties, - size_t size, pi_uint32 alignment) { +pi_result piextUSMSharedAlloc(void **result_ptr, pi_context context, + pi_device device, + pi_usm_mem_properties *properties, size_t size, + pi_uint32 alignment) { void *Ptr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -737,7 +733,7 @@ pi_result OCL(piextUSMSharedAlloc)(void **result_ptr, pi_context context, /// /// \param context is the pi_context of the allocation /// \param ptr is the memory to be freed -pi_result OCL(piextUSMFree)(pi_context context, void *ptr) { +pi_result piextUSMFree(pi_context context, void *ptr) { clMemFreeINTEL_fn FuncPtr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -758,9 +754,8 @@ pi_result OCL(piextUSMFree)(pi_context context, void *ptr) { /// \param arg_index is the index of the kernel argument /// \param arg_size is the size in bytes of the argument (ignored in CL) /// \param arg_value is the pointer argument -pi_result OCL(piextKernelSetArgPointer)(pi_kernel kernel, pi_uint32 arg_index, - size_t arg_size, - const void *arg_value) { +pi_result piextKernelSetArgPointer(pi_kernel kernel, pi_uint32 arg_index, + size_t arg_size, const void *arg_value) { // Size is unused in CL as pointer args are passed by value. @@ -799,11 +794,10 @@ pi_result OCL(piextKernelSetArgPointer)(pi_kernel kernel, pi_uint32 arg_index, /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -pi_result OCL(piextUSMEnqueueMemset)(pi_queue queue, void *ptr, pi_int32 value, - size_t count, - pi_uint32 num_events_in_waitlist, - const pi_event *events_waitlist, - pi_event *event) { +pi_result piextUSMEnqueueMemset(pi_queue queue, void *ptr, pi_int32 value, + size_t count, pi_uint32 num_events_in_waitlist, + const pi_event *events_waitlist, + pi_event *event) { // Have to look up the context from the kernel cl_context CLContext; @@ -839,12 +833,11 @@ pi_result OCL(piextUSMEnqueueMemset)(pi_queue queue, void *ptr, pi_int32 value, /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -pi_result OCL(piextUSMEnqueueMemcpy)(pi_queue queue, pi_bool blocking, - void *dst_ptr, const void *src_ptr, - size_t size, - pi_uint32 num_events_in_waitlist, - const pi_event *events_waitlist, - pi_event *event) { +pi_result piextUSMEnqueueMemcpy(pi_queue queue, pi_bool blocking, void *dst_ptr, + const void *src_ptr, size_t size, + pi_uint32 num_events_in_waitlist, + const pi_event *events_waitlist, + pi_event *event) { // Have to look up the context from the kernel cl_context CLContext; @@ -879,12 +872,11 @@ pi_result OCL(piextUSMEnqueueMemcpy)(pi_queue queue, pi_bool blocking, /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -pi_result OCL(piextUSMEnqueuePrefetch)(pi_queue queue, const void *ptr, - size_t size, - pi_usm_migration_flags flags, - pi_uint32 num_events_in_waitlist, - const pi_event *events_waitlist, - pi_event *event) { +pi_result piextUSMEnqueuePrefetch(pi_queue queue, const void *ptr, size_t size, + pi_usm_migration_flags flags, + pi_uint32 num_events_in_waitlist, + const pi_event *events_waitlist, + pi_event *event) { return cast(clEnqueueMarkerWithWaitList( cast(queue), num_events_in_waitlist, @@ -924,9 +916,8 @@ pi_result OCL(piextUSMEnqueuePrefetch)(pi_queue queue, const void *ptr, /// \param advice is device specific advice /// \param event is the event that represents this operation // USM memadvise API to govern behavior of automatic migration mechanisms -pi_result OCL(piextUSMEnqueueMemAdvise)(pi_queue queue, const void *ptr, - size_t length, int advice, - pi_event *event) { +pi_result piextUSMEnqueueMemAdvise(pi_queue queue, const void *ptr, + size_t length, int advice, pi_event *event) { return cast( clEnqueueMarkerWithWaitList(cast(queue), 0, nullptr, @@ -976,11 +967,10 @@ pi_result OCL(piextUSMEnqueueMemAdvise)(pi_queue queue, const void *ptr, /// \param param_value_size is the size of the result in bytes /// \param param_value is the result /// \param param_value_ret is how many bytes were written -pi_result OCL(piextUSMGetMemAllocInfo)(pi_context context, const void *ptr, - pi_mem_info param_name, - size_t param_value_size, - void *param_value, - size_t *param_value_size_ret) { +pi_result piextUSMGetMemAllocInfo(pi_context context, const void *ptr, + pi_mem_info param_name, + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) { clGetMemAllocInfoINTEL_fn FuncPtr = nullptr; pi_result RetVal = @@ -1007,10 +997,9 @@ pi_result OCL(piextUSMGetMemAllocInfo)(pi_context context, const void *ptr, /// If param_name is PI_USM_INDIRECT_ACCESS, the value will be a ptr to /// the pi_bool value PI_TRUE /// If param_name is PI_USM_PTRS, the value will be an array of ptrs -pi_result OCL(piKernelSetExecInfo)(pi_kernel kernel, - pi_kernel_exec_info param_name, - size_t param_value_size, - const void *param_value) { +pi_result piKernelSetExecInfo(pi_kernel kernel, pi_kernel_exec_info param_name, + size_t param_value_size, + const void *param_value) { if (param_name == PI_USM_INDIRECT_ACCESS && *(static_cast(param_value)) == PI_TRUE) { return USMSetIndirectAccess(kernel); @@ -1024,9 +1013,10 @@ typedef CL_API_ENTRY cl_int(CL_API_CALL *clSetProgramSpecializationConstant_fn)( cl_program program, cl_uint spec_id, size_t spec_size, const void *spec_value); -pi_result OCL(piextProgramSetSpecializationConstantImpl)( - pi_program prog, unsigned int spec_id, size_t spec_size, - const void *spec_value) { +pi_result piextProgramSetSpecializationConstant(pi_program prog, + pi_uint32 spec_id, + size_t spec_size, + const void *spec_value) { cl_program ClProg = cast(prog); cl_context Ctx = nullptr; size_t RetSize = 0; @@ -1052,13 +1042,37 @@ pi_result OCL(piextProgramSetSpecializationConstantImpl)( /// \param nativeHandle is a pointer to be set to the native handle /// /// PI_SUCCESS -pi_result OCL(piextGetNativeHandle)(void *piObj, - pi_native_handle *nativeHandle) { +static pi_result piextGetNativeHandle(void *piObj, + pi_native_handle *nativeHandle) { assert(nativeHandle != nullptr); *nativeHandle = reinterpret_cast(piObj); return PI_SUCCESS; } +pi_result piextDeviceGetNativeHandle(pi_device device, + pi_native_handle *nativeHandle) { + return piextGetNativeHandle(device, nativeHandle); +} + +pi_result piextContextGetNativeHandle(pi_context context, + pi_native_handle *nativeHandle) { + return piextGetNativeHandle(context, nativeHandle); +} + +pi_result piextQueueGetNativeHandle(pi_queue queue, + pi_native_handle *nativeHandle) { + return piextGetNativeHandle(queue, nativeHandle); +} + +pi_result piextMemGetNativeHandle(pi_mem mem, pi_native_handle *nativeHandle) { + return piextGetNativeHandle(mem, nativeHandle); +} + +pi_result piextProgramGetNativeHandle(pi_program program, + pi_native_handle *nativeHandle) { + return piextGetNativeHandle(program, nativeHandle); +} + pi_result piPluginInit(pi_plugin *PluginInit) { int CompareVersions = strcmp(PluginInit->PiVersion, SupportedVersion); if (CompareVersions < 0) { @@ -1074,74 +1088,70 @@ pi_result piPluginInit(pi_plugin *PluginInit) { (PluginInit->PiFunctionTable).pi_api = (decltype(&::pi_api))(&ocl_api); // Platform - _PI_CL(piPlatformsGet, OCL(piPlatformsGet)) + _PI_CL(piPlatformsGet, piPlatformsGet) _PI_CL(piPlatformGetInfo, clGetPlatformInfo) // Device - _PI_CL(piDevicesGet, OCL(piDevicesGet)) + _PI_CL(piDevicesGet, piDevicesGet) _PI_CL(piDeviceGetInfo, clGetDeviceInfo) _PI_CL(piDevicePartition, clCreateSubDevices) _PI_CL(piDeviceRetain, clRetainDevice) _PI_CL(piDeviceRelease, clReleaseDevice) - _PI_CL(piextDeviceSelectBinary, OCL(piextDeviceSelectBinary)) - _PI_CL(piextGetDeviceFunctionPointer, OCL(piextGetDeviceFunctionPointer)) - _PI_CL(piextDeviceGetNativeHandle, OCL(piextGetNativeHandle)) - _PI_CL(piextDeviceCreateWithNativeHandle, - OCL(piextDeviceCreateWithNativeHandle)) + _PI_CL(piextDeviceSelectBinary, piextDeviceSelectBinary) + _PI_CL(piextGetDeviceFunctionPointer, piextGetDeviceFunctionPointer) + _PI_CL(piextDeviceGetNativeHandle, piextDeviceGetNativeHandle) + _PI_CL(piextDeviceCreateWithNativeHandle, piextDeviceCreateWithNativeHandle) // Context - _PI_CL(piContextCreate, OCL(piContextCreate)) + _PI_CL(piContextCreate, piContextCreate) _PI_CL(piContextGetInfo, clGetContextInfo) _PI_CL(piContextRetain, clRetainContext) _PI_CL(piContextRelease, clReleaseContext) - _PI_CL(piextContextGetNativeHandle, OCL(piextGetNativeHandle)) - _PI_CL(piextContextCreateWithNativeHandle, - OCL(piextContextCreateWithNativeHandle)) + _PI_CL(piextContextGetNativeHandle, piextContextGetNativeHandle) + _PI_CL(piextContextCreateWithNativeHandle, piextContextCreateWithNativeHandle) // Queue - _PI_CL(piQueueCreate, OCL(piQueueCreate)) + _PI_CL(piQueueCreate, piQueueCreate) _PI_CL(piQueueGetInfo, clGetCommandQueueInfo) _PI_CL(piQueueFinish, clFinish) _PI_CL(piQueueRetain, clRetainCommandQueue) _PI_CL(piQueueRelease, clReleaseCommandQueue) - _PI_CL(piextQueueGetNativeHandle, OCL(piextGetNativeHandle)) - _PI_CL(piextQueueCreateWithNativeHandle, - OCL(piextQueueCreateWithNativeHandle)) + _PI_CL(piextQueueGetNativeHandle, piextQueueGetNativeHandle) + _PI_CL(piextQueueCreateWithNativeHandle, piextQueueCreateWithNativeHandle) // Memory - _PI_CL(piMemBufferCreate, OCL(piMemBufferCreate)) - _PI_CL(piMemImageCreate, OCL(piMemImageCreate)) + _PI_CL(piMemBufferCreate, piMemBufferCreate) + _PI_CL(piMemImageCreate, piMemImageCreate) _PI_CL(piMemGetInfo, clGetMemObjectInfo) _PI_CL(piMemImageGetInfo, clGetImageInfo) _PI_CL(piMemRetain, clRetainMemObject) _PI_CL(piMemRelease, clReleaseMemObject) - _PI_CL(piMemBufferPartition, OCL(piMemBufferPartition)) - _PI_CL(piextMemGetNativeHandle, OCL(piextGetNativeHandle)) - _PI_CL(piextMemCreateWithNativeHandle, OCL(piextMemCreateWithNativeHandle)) + _PI_CL(piMemBufferPartition, piMemBufferPartition) + _PI_CL(piextMemGetNativeHandle, piextMemGetNativeHandle) + _PI_CL(piextMemCreateWithNativeHandle, piextMemCreateWithNativeHandle) // Program - _PI_CL(piProgramCreate, OCL(piProgramCreate)) - _PI_CL(piclProgramCreateWithSource, OCL(piclProgramCreateWithSource)) - _PI_CL(piclProgramCreateWithBinary, OCL(piclProgramCreateWithBinary)) + _PI_CL(piProgramCreate, piProgramCreate) + _PI_CL(piclProgramCreateWithSource, piclProgramCreateWithSource) + _PI_CL(piclProgramCreateWithBinary, piclProgramCreateWithBinary) _PI_CL(piProgramGetInfo, clGetProgramInfo) _PI_CL(piProgramCompile, clCompileProgram) _PI_CL(piProgramBuild, clBuildProgram) - _PI_CL(piProgramLink, OCL(piProgramLink)) + _PI_CL(piProgramLink, piProgramLink) _PI_CL(piProgramGetBuildInfo, clGetProgramBuildInfo) _PI_CL(piProgramRetain, clRetainProgram) _PI_CL(piProgramRelease, clReleaseProgram) _PI_CL(piextProgramSetSpecializationConstant, - OCL(piextProgramSetSpecializationConstantImpl)) - _PI_CL(piextProgramGetNativeHandle, OCL(piextGetNativeHandle)) - _PI_CL(piextProgramCreateWithNativeHandle, - OCL(piextProgramCreateWithNativeHandle)) + piextProgramSetSpecializationConstant) + _PI_CL(piextProgramGetNativeHandle, piextProgramGetNativeHandle) + _PI_CL(piextProgramCreateWithNativeHandle, piextProgramCreateWithNativeHandle) // Kernel - _PI_CL(piKernelCreate, OCL(piKernelCreate)) + _PI_CL(piKernelCreate, piKernelCreate) _PI_CL(piKernelSetArg, clSetKernelArg) _PI_CL(piKernelGetInfo, clGetKernelInfo) _PI_CL(piKernelGetGroupInfo, clGetKernelWorkGroupInfo) _PI_CL(piKernelGetSubGroupInfo, clGetKernelSubGroupInfo) _PI_CL(piKernelRetain, clRetainKernel) _PI_CL(piKernelRelease, clReleaseKernel) - _PI_CL(piKernelSetExecInfo, OCL(piKernelSetExecInfo)) - _PI_CL(piextKernelSetArgPointer, OCL(piextKernelSetArgPointer)) + _PI_CL(piKernelSetExecInfo, piKernelSetExecInfo) + _PI_CL(piextKernelSetArgPointer, piextKernelSetArgPointer) // Event - _PI_CL(piEventCreate, OCL(piEventCreate)) + _PI_CL(piEventCreate, piEventCreate) _PI_CL(piEventGetInfo, clGetEventInfo) _PI_CL(piEventGetProfilingInfo, clGetEventProfilingInfo) _PI_CL(piEventsWait, clWaitForEvents) @@ -1149,11 +1159,10 @@ pi_result piPluginInit(pi_plugin *PluginInit) { _PI_CL(piEventSetStatus, clSetUserEventStatus) _PI_CL(piEventRetain, clRetainEvent) _PI_CL(piEventRelease, clReleaseEvent) - _PI_CL(piextEventGetNativeHandle, OCL(piextGetNativeHandle)) - _PI_CL(piextEventCreateWithNativeHandle, - OCL(piextEventCreateWithNativeHandle)) + _PI_CL(piextEventGetNativeHandle, piextGetNativeHandle) + _PI_CL(piextEventCreateWithNativeHandle, piextEventCreateWithNativeHandle) // Sampler - _PI_CL(piSamplerCreate, OCL(piSamplerCreate)) + _PI_CL(piSamplerCreate, piSamplerCreate) _PI_CL(piSamplerGetInfo, clGetSamplerInfo) _PI_CL(piSamplerRetain, clRetainSampler) _PI_CL(piSamplerRelease, clReleaseSampler) @@ -1172,20 +1181,20 @@ pi_result piPluginInit(pi_plugin *PluginInit) { _PI_CL(piEnqueueMemImageWrite, clEnqueueWriteImage) _PI_CL(piEnqueueMemImageCopy, clEnqueueCopyImage) _PI_CL(piEnqueueMemImageFill, clEnqueueFillImage) - _PI_CL(piEnqueueMemBufferMap, OCL(piEnqueueMemBufferMap)) + _PI_CL(piEnqueueMemBufferMap, piEnqueueMemBufferMap) _PI_CL(piEnqueueMemUnmap, clEnqueueUnmapMemObject) // USM - _PI_CL(piextUSMHostAlloc, OCL(piextUSMHostAlloc)) - _PI_CL(piextUSMDeviceAlloc, OCL(piextUSMDeviceAlloc)) - _PI_CL(piextUSMSharedAlloc, OCL(piextUSMSharedAlloc)) - _PI_CL(piextUSMFree, OCL(piextUSMFree)) - _PI_CL(piextUSMEnqueueMemset, OCL(piextUSMEnqueueMemset)) - _PI_CL(piextUSMEnqueueMemcpy, OCL(piextUSMEnqueueMemcpy)) - _PI_CL(piextUSMEnqueuePrefetch, OCL(piextUSMEnqueuePrefetch)) - _PI_CL(piextUSMEnqueueMemAdvise, OCL(piextUSMEnqueueMemAdvise)) - _PI_CL(piextUSMGetMemAllocInfo, OCL(piextUSMGetMemAllocInfo)) - - _PI_CL(piextKernelSetArgMemObj, OCL(piextKernelSetArgMemObj)) + _PI_CL(piextUSMHostAlloc, piextUSMHostAlloc) + _PI_CL(piextUSMDeviceAlloc, piextUSMDeviceAlloc) + _PI_CL(piextUSMSharedAlloc, piextUSMSharedAlloc) + _PI_CL(piextUSMFree, piextUSMFree) + _PI_CL(piextUSMEnqueueMemset, piextUSMEnqueueMemset) + _PI_CL(piextUSMEnqueueMemcpy, piextUSMEnqueueMemcpy) + _PI_CL(piextUSMEnqueuePrefetch, piextUSMEnqueuePrefetch) + _PI_CL(piextUSMEnqueueMemAdvise, piextUSMEnqueueMemAdvise) + _PI_CL(piextUSMGetMemAllocInfo, piextUSMGetMemAllocInfo) + + _PI_CL(piextKernelSetArgMemObj, piextKernelSetArgMemObj) #undef _PI_CL diff --git a/sycl/test/regression/pi_opencl_symbol_check.cpp b/sycl/test/regression/pi_opencl_symbol_check.cpp new file mode 100644 index 0000000000000..b0a02acbf68d7 --- /dev/null +++ b/sycl/test/regression/pi_opencl_symbol_check.cpp @@ -0,0 +1,6 @@ +// RUN: env LLVM_BIN_PATH=%llvm_build_bin_dir python %sycl_tools_src_dir/abi_check.py --mode check_symbols --reference %S/pi_opencl_symbol_check.txt %sycl_libs_dir/libpi_opencl.so +// expected-no-diagnostics +// +//===----------------------------------------------------------------------===// +// This test checks if there is any change in export symbols in libpi_opencl.so +//===----------------------------------------------------------------------===// diff --git a/sycl/test/regression/pi_opencl_symbol_check.txt b/sycl/test/regression/pi_opencl_symbol_check.txt new file mode 100644 index 0000000000000..96479adc27616 --- /dev/null +++ b/sycl/test/regression/pi_opencl_symbol_check.txt @@ -0,0 +1,42 @@ +piContextCreate +piDevicesGet +piEnqueueMemBufferMap +piEventCreate +piKernelCreate +piKernelSetExecInfo +piMemBufferCreate +piMemBufferPartition +piMemImageCreate +piPlatformsGet +piPluginInit +piProgramCreate +piProgramLink +piQueueCreate +piSamplerCreate +piclProgramCreateWithBinary +piclProgramCreateWithSource +piextContextCreateWithNativeHandle +piextContextGetNativeHandle +piextDeviceCreateWithNativeHandle +piextDeviceSelectBinary +piextDeviceGetNativeHandle +piextEventCreateWithNativeHandle +piextGetDeviceFunctionPointer +piextProgramGetNativeHandle +piextKernelSetArgMemObj +piextKernelSetArgPointer +piextMemCreateWithNativeHandle +piextMemGetNativeHandle +piextProgramCreateWithNativeHandle +piextProgramSetSpecializationConstant +piextQueueCreateWithNativeHandle +piextQueueGetNativeHandle +piextUSMDeviceAlloc +piextUSMEnqueueMemAdvise +piextUSMEnqueueMemcpy +piextUSMEnqueueMemset +piextUSMEnqueuePrefetch +piextUSMFree +piextUSMGetMemAllocInfo +piextUSMHostAlloc +piextUSMSharedAlloc \ No newline at end of file From 7128d4cc4fc764c7156d91fe0238dae2e4647231 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Mon, 4 May 2020 11:39:17 -0700 Subject: [PATCH 24/32] [SYCL] Export only pi* symbols in libpi_opencl.so Changed symbols from Oclpi* to pi* Set -fvisibility=hidden by default to hide all symbols. version script tells only pi* symbols are global. Signed-off-by: Byoungro So --- sycl/include/CL/sycl/detail/pi.h | 617 +++++++++++++++-------------- sycl/plugins/ld-version-script.txt | 10 + sycl/plugins/opencl/CMakeLists.txt | 36 +- sycl/plugins/opencl/pi_opencl.cpp | 227 ++++++----- 4 files changed, 475 insertions(+), 415 deletions(-) create mode 100644 sycl/plugins/ld-version-script.txt diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index f44b74292b664..a360f724422ae 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -46,6 +46,7 @@ // elsewhere, e.g. in the pi_opencl, but constants/enums mapping is now // done here, for efficiency and simplicity. +#include "export.hpp" #include #include #include @@ -751,56 +752,62 @@ using pi_plugin = _pi_plugin; // populate the PI Version it supports, update targets field and populate // PiFunctionTable with Supported APIs. The pointers are in a predetermined // order in pi.def file. -pi_result piPluginInit(pi_plugin *plugin_info); +__SYCL_EXPORT pi_result piPluginInit(pi_plugin *plugin_info); // // Platform // -pi_result piPlatformsGet(pi_uint32 num_entries, pi_platform *platforms, - pi_uint32 *num_platforms); +__SYCL_EXPORT pi_result piPlatformsGet(pi_uint32 num_entries, + pi_platform *platforms, + pi_uint32 *num_platforms); -pi_result piPlatformGetInfo(pi_platform platform, pi_platform_info param_name, - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piPlatformGetInfo(pi_platform platform, + pi_platform_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret); -pi_result piDevicesGet(pi_platform platform, pi_device_type device_type, - pi_uint32 num_entries, pi_device *devices, - pi_uint32 *num_devices); +__SYCL_EXPORT pi_result piDevicesGet(pi_platform platform, + pi_device_type device_type, + pi_uint32 num_entries, pi_device *devices, + pi_uint32 *num_devices); -pi_result piDeviceGetInfo(pi_device device, pi_device_info param_name, - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piDeviceGetInfo(pi_device device, + pi_device_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret); -pi_result piDeviceRetain(pi_device device); +__SYCL_EXPORT pi_result piDeviceRetain(pi_device device); -pi_result piDeviceRelease(pi_device device); +__SYCL_EXPORT pi_result piDeviceRelease(pi_device device); -pi_result piDevicePartition(pi_device device, - const pi_device_partition_property *properties, - pi_uint32 num_devices, pi_device *out_devices, - pi_uint32 *out_num_devices); +__SYCL_EXPORT pi_result piDevicePartition( + pi_device device, const pi_device_partition_property *properties, + pi_uint32 num_devices, pi_device *out_devices, pi_uint32 *out_num_devices); /// Gets the native handle of a PI device object. /// /// \param device is the PI device to get the native handle of. /// \param nativeHandle is the native handle of device. -pi_result piextDeviceGetNativeHandle(pi_device device, - pi_native_handle *nativeHandle); +__SYCL_EXPORT pi_result +piextDeviceGetNativeHandle(pi_device device, pi_native_handle *nativeHandle); /// Creates PI device object from a native handle. /// NOTE: The created PI object takes ownership of the native handle. /// /// \param nativeHandle is the native handle to create PI device from. /// \param device is the PI device created from the native handle. -pi_result piextDeviceCreateWithNativeHandle(pi_native_handle nativeHandle, - pi_device *device); +__SYCL_EXPORT pi_result piextDeviceCreateWithNativeHandle( + pi_native_handle nativeHandle, pi_device *device); /// Selects the most appropriate device binary based on runtime information /// and the IR characteristics. /// -pi_result piextDeviceSelectBinary(pi_device device, pi_device_binary *binaries, - pi_uint32 num_binaries, - pi_uint32 *selected_binary_ind); +__SYCL_EXPORT pi_result piextDeviceSelectBinary(pi_device device, + pi_device_binary *binaries, + pi_uint32 num_binaries, + pi_uint32 *selected_binary_ind); /// Retrieves a device function pointer to a user-defined function /// \arg \c function_name. \arg \c function_pointer_ret is set to 0 if query @@ -810,172 +817,180 @@ pi_result piextDeviceSelectBinary(pi_device device, pi_device_binary *binaries, /// must present in the list of devices returned by \c get_device method for /// \arg \c program. /// -pi_result piextGetDeviceFunctionPointer(pi_device device, pi_program program, - const char *function_name, - pi_uint64 *function_pointer_ret); +__SYCL_EXPORT pi_result piextGetDeviceFunctionPointer( + pi_device device, pi_program program, const char *function_name, + pi_uint64 *function_pointer_ret); // // Context // -pi_result piContextCreate(const pi_context_properties *properties, - pi_uint32 num_devices, const pi_device *devices, - void (*pfn_notify)(const char *errinfo, - const void *private_info, - size_t cb, void *user_data), - void *user_data, pi_context *ret_context); +__SYCL_EXPORT pi_result piContextCreate( + const pi_context_properties *properties, pi_uint32 num_devices, + const pi_device *devices, + void (*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, + void *user_data), + void *user_data, pi_context *ret_context); -pi_result piContextGetInfo(pi_context context, pi_context_info param_name, - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piContextGetInfo(pi_context context, + pi_context_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret); -pi_result piContextRetain(pi_context context); +__SYCL_EXPORT pi_result piContextRetain(pi_context context); -pi_result piContextRelease(pi_context context); +__SYCL_EXPORT pi_result piContextRelease(pi_context context); typedef void (*pi_context_extended_deleter)(void *user_data); -pi_result piextContextSetExtendedDeleter(pi_context context, - pi_context_extended_deleter func, - void *user_data); +__SYCL_EXPORT pi_result piextContextSetExtendedDeleter( + pi_context context, pi_context_extended_deleter func, void *user_data); /// Gets the native handle of a PI context object. /// /// \param context is the PI context to get the native handle of. /// \param nativeHandle is the native handle of context. -pi_result piextContextGetNativeHandle(pi_context context, - pi_native_handle *nativeHandle); +__SYCL_EXPORT pi_result +piextContextGetNativeHandle(pi_context context, pi_native_handle *nativeHandle); /// Creates PI context object from a native handle. /// NOTE: The created PI object takes ownership of the native handle. /// /// \param nativeHandle is the native handle to create PI context from. /// \param context is the PI context created from the native handle. -pi_result piextContextCreateWithNativeHandle(pi_native_handle nativeHandle, - pi_context *context); +__SYCL_EXPORT pi_result piextContextCreateWithNativeHandle( + pi_native_handle nativeHandle, pi_context *context); // // Queue // -pi_result piQueueCreate(pi_context context, pi_device device, - pi_queue_properties properties, pi_queue *queue); +__SYCL_EXPORT pi_result piQueueCreate(pi_context context, pi_device device, + pi_queue_properties properties, + pi_queue *queue); -pi_result piQueueGetInfo(pi_queue command_queue, pi_queue_info param_name, - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piQueueGetInfo(pi_queue command_queue, + pi_queue_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret); -pi_result piQueueRetain(pi_queue command_queue); +__SYCL_EXPORT pi_result piQueueRetain(pi_queue command_queue); -pi_result piQueueRelease(pi_queue command_queue); +__SYCL_EXPORT pi_result piQueueRelease(pi_queue command_queue); -pi_result piQueueFinish(pi_queue command_queue); +__SYCL_EXPORT pi_result piQueueFinish(pi_queue command_queue); /// Gets the native handle of a PI queue object. /// /// \param queue is the PI queue to get the native handle of. /// \param nativeHandle is the native handle of queue. -pi_result piextQueueGetNativeHandle(pi_queue queue, - pi_native_handle *nativeHandle); +__SYCL_EXPORT pi_result +piextQueueGetNativeHandle(pi_queue queue, pi_native_handle *nativeHandle); /// Creates PI queue object from a native handle. /// NOTE: The created PI object takes ownership of the native handle. /// /// \param nativeHandle is the native handle to create PI queue from. /// \param queue is the PI queue created from the native handle. -pi_result piextQueueCreateWithNativeHandle(pi_native_handle nativeHandle, - pi_queue *queue); +__SYCL_EXPORT pi_result piextQueueCreateWithNativeHandle( + pi_native_handle nativeHandle, pi_queue *queue); // // Memory // -pi_result piMemBufferCreate(pi_context context, pi_mem_flags flags, size_t size, - void *host_ptr, pi_mem *ret_mem); - -pi_result piMemImageCreate(pi_context context, pi_mem_flags flags, - const pi_image_format *image_format, - const pi_image_desc *image_desc, void *host_ptr, - pi_mem *ret_mem); - -pi_result piMemGetInfo(pi_mem mem, - cl_mem_info param_name, // TODO: untie from OpenCL - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piMemBufferCreate(pi_context context, + pi_mem_flags flags, size_t size, + void *host_ptr, pi_mem *ret_mem); + +__SYCL_EXPORT pi_result piMemImageCreate(pi_context context, pi_mem_flags flags, + const pi_image_format *image_format, + const pi_image_desc *image_desc, + void *host_ptr, pi_mem *ret_mem); + +__SYCL_EXPORT pi_result piMemGetInfo( + pi_mem mem, + cl_mem_info param_name, // TODO: untie from OpenCL + size_t param_value_size, void *param_value, size_t *param_value_size_ret); -pi_result piMemImageGetInfo(pi_mem image, pi_image_info param_name, - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piMemImageGetInfo(pi_mem image, + pi_image_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret); -pi_result piMemRetain(pi_mem mem); +__SYCL_EXPORT pi_result piMemRetain(pi_mem mem); -pi_result piMemRelease(pi_mem mem); +__SYCL_EXPORT pi_result piMemRelease(pi_mem mem); -pi_result piMemBufferPartition(pi_mem buffer, pi_mem_flags flags, - pi_buffer_create_type buffer_create_type, - void *buffer_create_info, pi_mem *ret_mem); +__SYCL_EXPORT pi_result piMemBufferPartition( + pi_mem buffer, pi_mem_flags flags, pi_buffer_create_type buffer_create_type, + void *buffer_create_info, pi_mem *ret_mem); /// Gets the native handle of a PI mem object. /// /// \param mem is the PI mem to get the native handle of. /// \param nativeHandle is the native handle of mem. -pi_result piextMemGetNativeHandle(pi_mem mem, pi_native_handle *nativeHandle); +__SYCL_EXPORT pi_result piextMemGetNativeHandle(pi_mem mem, + pi_native_handle *nativeHandle); /// Creates PI mem object from a native handle. /// NOTE: The created PI object takes ownership of the native handle. /// /// \param nativeHandle is the native handle to create PI mem from. /// \param mem is the PI mem created from the native handle. -pi_result piextMemCreateWithNativeHandle(pi_native_handle nativeHandle, - pi_mem *mem); +__SYCL_EXPORT pi_result +piextMemCreateWithNativeHandle(pi_native_handle nativeHandle, pi_mem *mem); // // Program // -pi_result piProgramCreate(pi_context context, const void *il, size_t length, - pi_program *res_program); - -pi_result piclProgramCreateWithSource(pi_context context, pi_uint32 count, - const char **strings, - const size_t *lengths, - pi_program *ret_program); - -pi_result piclProgramCreateWithBinary(pi_context context, pi_uint32 num_devices, - const pi_device *device_list, - const size_t *lengths, - const unsigned char **binaries, - pi_int32 *binary_status, - pi_program *ret_program); - -pi_result piProgramGetInfo(pi_program program, pi_program_info param_name, - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); - -pi_result piProgramLink(pi_context context, pi_uint32 num_devices, - const pi_device *device_list, const char *options, - pi_uint32 num_input_programs, - const pi_program *input_programs, - void (*pfn_notify)(pi_program program, void *user_data), - void *user_data, pi_program *ret_program); - -pi_result piProgramCompile( +__SYCL_EXPORT pi_result piProgramCreate(pi_context context, const void *il, + size_t length, pi_program *res_program); + +__SYCL_EXPORT pi_result piclProgramCreateWithSource(pi_context context, + pi_uint32 count, + const char **strings, + const size_t *lengths, + pi_program *ret_program); + +__SYCL_EXPORT pi_result piclProgramCreateWithBinary( + pi_context context, pi_uint32 num_devices, const pi_device *device_list, + const size_t *lengths, const unsigned char **binaries, + pi_int32 *binary_status, pi_program *ret_program); + +__SYCL_EXPORT pi_result piProgramGetInfo(pi_program program, + pi_program_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret); + +__SYCL_EXPORT pi_result +piProgramLink(pi_context context, pi_uint32 num_devices, + const pi_device *device_list, const char *options, + pi_uint32 num_input_programs, const pi_program *input_programs, + void (*pfn_notify)(pi_program program, void *user_data), + void *user_data, pi_program *ret_program); + +__SYCL_EXPORT pi_result piProgramCompile( pi_program program, pi_uint32 num_devices, const pi_device *device_list, const char *options, pi_uint32 num_input_headers, const pi_program *input_headers, const char **header_include_names, void (*pfn_notify)(pi_program program, void *user_data), void *user_data); -pi_result piProgramBuild(pi_program program, pi_uint32 num_devices, - const pi_device *device_list, const char *options, - void (*pfn_notify)(pi_program program, - void *user_data), - void *user_data); +__SYCL_EXPORT pi_result piProgramBuild( + pi_program program, pi_uint32 num_devices, const pi_device *device_list, + const char *options, + void (*pfn_notify)(pi_program program, void *user_data), void *user_data); -pi_result piProgramGetBuildInfo( +__SYCL_EXPORT pi_result piProgramGetBuildInfo( pi_program program, pi_device device, cl_program_build_info param_name, // TODO: untie from OpenCL size_t param_value_size, void *param_value, size_t *param_value_size_ret); -pi_result piProgramRetain(pi_program program); +__SYCL_EXPORT pi_result piProgramRetain(pi_program program); -pi_result piProgramRelease(pi_program program); +__SYCL_EXPORT pi_result piProgramRelease(pi_program program); /// Sets a specialization constant to a specific value. /// @@ -983,25 +998,24 @@ pi_result piProgramRelease(pi_program program); /// \param spec_id integer ID of the constant /// \param spec_size size of the value /// \param spec_value bytes of the value -pi_result piextProgramSetSpecializationConstant(pi_program prog, - pi_uint32 spec_id, - size_t spec_size, - const void *spec_value); +__SYCL_EXPORT pi_result +piextProgramSetSpecializationConstant(pi_program prog, pi_uint32 spec_id, + size_t spec_size, const void *spec_value); /// Gets the native handle of a PI program object. /// /// \param program is the PI program to get the native handle of. /// \param nativeHandle is the native handle of program. -pi_result piextProgramGetNativeHandle(pi_program program, - pi_native_handle *nativeHandle); +__SYCL_EXPORT pi_result +piextProgramGetNativeHandle(pi_program program, pi_native_handle *nativeHandle); /// Creates PI program object from a native handle. /// NOTE: The created PI object takes ownership of the native handle. /// /// \param nativeHandle is the native handle to create PI program from. /// \param program is the PI program created from the native handle. -pi_result piextProgramCreateWithNativeHandle(pi_native_handle nativeHandle, - pi_program *program); +__SYCL_EXPORT pi_result piextProgramCreateWithNativeHandle( + pi_native_handle nativeHandle, pi_program *program); // // Kernel @@ -1016,30 +1030,34 @@ typedef enum { using pi_kernel_exec_info = _pi_kernel_exec_info; -pi_result piKernelCreate(pi_program program, const char *kernel_name, - pi_kernel *ret_kernel); +__SYCL_EXPORT pi_result piKernelCreate(pi_program program, + const char *kernel_name, + pi_kernel *ret_kernel); -pi_result piKernelSetArg(pi_kernel kernel, pi_uint32 arg_index, size_t arg_size, - const void *arg_value); +__SYCL_EXPORT pi_result piKernelSetArg(pi_kernel kernel, pi_uint32 arg_index, + size_t arg_size, const void *arg_value); -pi_result piKernelGetInfo(pi_kernel kernel, pi_kernel_info param_name, - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piKernelGetInfo(pi_kernel kernel, + pi_kernel_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret); -pi_result piKernelGetGroupInfo(pi_kernel kernel, pi_device device, - pi_kernel_group_info param_name, - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piKernelGetGroupInfo(pi_kernel kernel, pi_device device, + pi_kernel_group_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret); -pi_result piKernelGetSubGroupInfo( +__SYCL_EXPORT pi_result piKernelGetSubGroupInfo( pi_kernel kernel, pi_device device, cl_kernel_sub_group_info param_name, // TODO: untie from OpenCL size_t input_value_size, const void *input_value, size_t param_value_size, void *param_value, size_t *param_value_size_ret); -pi_result piKernelRetain(pi_kernel kernel); +__SYCL_EXPORT pi_result piKernelRetain(pi_kernel kernel); -pi_result piKernelRelease(pi_kernel kernel); +__SYCL_EXPORT pi_result piKernelRelease(pi_kernel kernel); /// Sets up pointer arguments for CL kernels. An extra indirection /// is required due to CL argument conventions. @@ -1048,8 +1066,10 @@ pi_result piKernelRelease(pi_kernel kernel); /// \param arg_index is the index of the kernel argument /// \param arg_size is the size in bytes of the argument (ignored in CL) /// \param arg_value is the pointer argument -pi_result piextKernelSetArgPointer(pi_kernel kernel, pi_uint32 arg_index, - size_t arg_size, const void *arg_value); +__SYCL_EXPORT pi_result piextKernelSetArgPointer(pi_kernel kernel, + pi_uint32 arg_index, + size_t arg_size, + const void *arg_value); /// API to set attributes controlling kernel execution /// @@ -1062,183 +1082,181 @@ pi_result piextKernelSetArgPointer(pi_kernel kernel, pi_uint32 arg_index, /// If param_name is PI_USM_INDIRECT_ACCESS, the value will be a ptr to /// the pi_bool value PI_TRUE /// If param_name is PI_USM_PTRS, the value will be an array of ptrs -pi_result piKernelSetExecInfo(pi_kernel kernel, pi_kernel_exec_info value_name, - size_t param_value_size, const void *param_value); +__SYCL_EXPORT pi_result piKernelSetExecInfo(pi_kernel kernel, + pi_kernel_exec_info value_name, + size_t param_value_size, + const void *param_value); // // Events // -pi_result piEventCreate(pi_context context, pi_event *ret_event); +__SYCL_EXPORT pi_result piEventCreate(pi_context context, pi_event *ret_event); -pi_result piEventGetInfo(pi_event event, - cl_event_info param_name, // TODO: untie from OpenCL - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piEventGetInfo( + pi_event event, + cl_event_info param_name, // TODO: untie from OpenCL + size_t param_value_size, void *param_value, size_t *param_value_size_ret); -pi_result piEventGetProfilingInfo(pi_event event, pi_profiling_info param_name, - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piEventGetProfilingInfo(pi_event event, + pi_profiling_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret); -pi_result piEventsWait(pi_uint32 num_events, const pi_event *event_list); +__SYCL_EXPORT pi_result piEventsWait(pi_uint32 num_events, + const pi_event *event_list); -pi_result piEventSetCallback(pi_event event, - pi_int32 command_exec_callback_type, - void (*pfn_notify)(pi_event event, - pi_int32 event_command_status, - void *user_data), - void *user_data); +__SYCL_EXPORT pi_result piEventSetCallback( + pi_event event, pi_int32 command_exec_callback_type, + void (*pfn_notify)(pi_event event, pi_int32 event_command_status, + void *user_data), + void *user_data); -pi_result piEventSetStatus(pi_event event, pi_int32 execution_status); +__SYCL_EXPORT pi_result piEventSetStatus(pi_event event, + pi_int32 execution_status); -pi_result piEventRetain(pi_event event); +__SYCL_EXPORT pi_result piEventRetain(pi_event event); -pi_result piEventRelease(pi_event event); +__SYCL_EXPORT pi_result piEventRelease(pi_event event); /// Gets the native handle of a PI event object. /// /// \param event is the PI event to get the native handle of. /// \param nativeHandle is the native handle of event. -pi_result piextEventGetNativeHandle(pi_event event, - pi_native_handle *nativeHandle); +__SYCL_EXPORT pi_result +piextEventGetNativeHandle(pi_event event, pi_native_handle *nativeHandle); /// Creates PI event object from a native handle. /// NOTE: The created PI object takes ownership of the native handle. /// /// \param nativeHandle is the native handle to create PI event from. /// \param event is the PI event created from the native handle. -pi_result piextEventCreateWithNativeHandle(pi_native_handle nativeHandle, - pi_event *event); +__SYCL_EXPORT pi_result piextEventCreateWithNativeHandle( + pi_native_handle nativeHandle, pi_event *event); // // Sampler // -pi_result piSamplerCreate(pi_context context, - const pi_sampler_properties *sampler_properties, - pi_sampler *result_sampler); +__SYCL_EXPORT pi_result piSamplerCreate( + pi_context context, const pi_sampler_properties *sampler_properties, + pi_sampler *result_sampler); -pi_result piSamplerGetInfo(pi_sampler sampler, pi_sampler_info param_name, - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piSamplerGetInfo(pi_sampler sampler, + pi_sampler_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret); -pi_result piSamplerRetain(pi_sampler sampler); +__SYCL_EXPORT pi_result piSamplerRetain(pi_sampler sampler); -pi_result piSamplerRelease(pi_sampler sampler); +__SYCL_EXPORT pi_result piSamplerRelease(pi_sampler sampler); // // Queue Commands // -pi_result piEnqueueKernelLaunch( +__SYCL_EXPORT pi_result piEnqueueKernelLaunch( pi_queue queue, pi_kernel kernel, pi_uint32 work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event); -pi_result -piEnqueueNativeKernel(pi_queue queue, void (*user_func)(void *), void *args, - size_t cb_args, pi_uint32 num_mem_objects, - const pi_mem *mem_list, const void **args_mem_loc, - pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, pi_event *event); +__SYCL_EXPORT pi_result piEnqueueNativeKernel( + pi_queue queue, void (*user_func)(void *), void *args, size_t cb_args, + pi_uint32 num_mem_objects, const pi_mem *mem_list, + const void **args_mem_loc, pi_uint32 num_events_in_wait_list, + const pi_event *event_wait_list, pi_event *event); + +__SYCL_EXPORT pi_result piEnqueueEventsWait(pi_queue command_queue, + pi_uint32 num_events_in_wait_list, + const pi_event *event_wait_list, + pi_event *event); + +__SYCL_EXPORT pi_result piEnqueueMemBufferRead( + pi_queue queue, pi_mem buffer, pi_bool blocking_read, size_t offset, + size_t size, void *ptr, pi_uint32 num_events_in_wait_list, + const pi_event *event_wait_list, pi_event *event); -pi_result piEnqueueEventsWait(pi_queue command_queue, - pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, pi_event *event); - -pi_result piEnqueueMemBufferRead(pi_queue queue, pi_mem buffer, - pi_bool blocking_read, size_t offset, - size_t size, void *ptr, - pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, - pi_event *event); - -pi_result -piEnqueueMemBufferReadRect(pi_queue command_queue, pi_mem buffer, - pi_bool blocking_read, const size_t *buffer_offset, - const size_t *host_offset, const size_t *region, - size_t buffer_row_pitch, size_t buffer_slice_pitch, - size_t host_row_pitch, size_t host_slice_pitch, - void *ptr, pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, pi_event *event); - -pi_result piEnqueueMemBufferWrite(pi_queue command_queue, pi_mem buffer, - pi_bool blocking_write, size_t offset, - size_t size, const void *ptr, - pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, - pi_event *event); - -pi_result -piEnqueueMemBufferWriteRect(pi_queue command_queue, pi_mem buffer, - pi_bool blocking_write, const size_t *buffer_offset, - const size_t *host_offset, const size_t *region, - size_t buffer_row_pitch, size_t buffer_slice_pitch, - size_t host_row_pitch, size_t host_slice_pitch, - const void *ptr, pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, pi_event *event); - -pi_result piEnqueueMemBufferCopy(pi_queue command_queue, pi_mem src_buffer, - pi_mem dst_buffer, size_t src_offset, - size_t dst_offset, size_t size, - pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, - pi_event *event); - -pi_result piEnqueueMemBufferCopyRect( +__SYCL_EXPORT pi_result piEnqueueMemBufferReadRect( + pi_queue command_queue, pi_mem buffer, pi_bool blocking_read, + const size_t *buffer_offset, const size_t *host_offset, + const size_t *region, size_t buffer_row_pitch, size_t buffer_slice_pitch, + size_t host_row_pitch, size_t host_slice_pitch, void *ptr, + pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, + pi_event *event); + +__SYCL_EXPORT pi_result +piEnqueueMemBufferWrite(pi_queue command_queue, pi_mem buffer, + pi_bool blocking_write, size_t offset, size_t size, + const void *ptr, pi_uint32 num_events_in_wait_list, + const pi_event *event_wait_list, pi_event *event); + +__SYCL_EXPORT pi_result piEnqueueMemBufferWriteRect( + pi_queue command_queue, pi_mem buffer, pi_bool blocking_write, + const size_t *buffer_offset, const size_t *host_offset, + const size_t *region, size_t buffer_row_pitch, size_t buffer_slice_pitch, + size_t host_row_pitch, size_t host_slice_pitch, const void *ptr, + pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, + pi_event *event); + +__SYCL_EXPORT pi_result +piEnqueueMemBufferCopy(pi_queue command_queue, pi_mem src_buffer, + pi_mem dst_buffer, size_t src_offset, size_t dst_offset, + size_t size, pi_uint32 num_events_in_wait_list, + const pi_event *event_wait_list, pi_event *event); + +__SYCL_EXPORT pi_result piEnqueueMemBufferCopyRect( pi_queue command_queue, pi_mem src_buffer, pi_mem dst_buffer, const size_t *src_origin, const size_t *dst_origin, const size_t *region, size_t src_row_pitch, size_t src_slice_pitch, size_t dst_row_pitch, size_t dst_slice_pitch, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event); -pi_result piEnqueueMemBufferFill(pi_queue command_queue, pi_mem buffer, - const void *pattern, size_t pattern_size, - size_t offset, size_t size, - pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, - pi_event *event); - -pi_result piEnqueueMemImageRead(pi_queue command_queue, pi_mem image, - pi_bool blocking_read, const size_t *origin, - const size_t *region, size_t row_pitch, - size_t slice_pitch, void *ptr, - pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, - pi_event *event); - -pi_result piEnqueueMemImageWrite(pi_queue command_queue, pi_mem image, - pi_bool blocking_write, const size_t *origin, - const size_t *region, size_t input_row_pitch, - size_t input_slice_pitch, const void *ptr, - pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, - pi_event *event); - -pi_result piEnqueueMemImageCopy(pi_queue command_queue, pi_mem src_image, - pi_mem dst_image, const size_t *src_origin, - const size_t *dst_origin, const size_t *region, - pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, - pi_event *event); - -pi_result piEnqueueMemImageFill(pi_queue command_queue, pi_mem image, - const void *fill_color, const size_t *origin, - const size_t *region, - pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, - pi_event *event); - -pi_result piEnqueueMemBufferMap( +__SYCL_EXPORT pi_result +piEnqueueMemBufferFill(pi_queue command_queue, pi_mem buffer, + const void *pattern, size_t pattern_size, size_t offset, + size_t size, pi_uint32 num_events_in_wait_list, + const pi_event *event_wait_list, pi_event *event); + +__SYCL_EXPORT pi_result piEnqueueMemImageRead( + pi_queue command_queue, pi_mem image, pi_bool blocking_read, + const size_t *origin, const size_t *region, size_t row_pitch, + size_t slice_pitch, void *ptr, pi_uint32 num_events_in_wait_list, + const pi_event *event_wait_list, pi_event *event); + +__SYCL_EXPORT pi_result piEnqueueMemImageWrite( + pi_queue command_queue, pi_mem image, pi_bool blocking_write, + const size_t *origin, const size_t *region, size_t input_row_pitch, + size_t input_slice_pitch, const void *ptr, + pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, + pi_event *event); + +__SYCL_EXPORT pi_result piEnqueueMemImageCopy( + pi_queue command_queue, pi_mem src_image, pi_mem dst_image, + const size_t *src_origin, const size_t *dst_origin, const size_t *region, + pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, + pi_event *event); + +__SYCL_EXPORT pi_result +piEnqueueMemImageFill(pi_queue command_queue, pi_mem image, + const void *fill_color, const size_t *origin, + const size_t *region, pi_uint32 num_events_in_wait_list, + const pi_event *event_wait_list, pi_event *event); + +__SYCL_EXPORT pi_result piEnqueueMemBufferMap( pi_queue command_queue, pi_mem buffer, pi_bool blocking_map, cl_map_flags map_flags, // TODO: untie from OpenCL size_t offset, size_t size, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event, void **ret_map); -pi_result piEnqueueMemUnmap(pi_queue command_queue, pi_mem memobj, - void *mapped_ptr, pi_uint32 num_events_in_wait_list, - const pi_event *event_wait_list, pi_event *event); +__SYCL_EXPORT pi_result piEnqueueMemUnmap(pi_queue command_queue, pi_mem memobj, + void *mapped_ptr, + pi_uint32 num_events_in_wait_list, + const pi_event *event_wait_list, + pi_event *event); -pi_result piextKernelSetArgMemObj(pi_kernel kernel, pi_uint32 arg_index, - const pi_mem *arg_value); +__SYCL_EXPORT pi_result piextKernelSetArgMemObj(pi_kernel kernel, + pi_uint32 arg_index, + const pi_mem *arg_value); /// // USM @@ -1299,9 +1317,9 @@ using pi_usm_migration_flags = _pi_usm_migration_flags; /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -pi_result piextUSMHostAlloc(void **result_ptr, pi_context context, - pi_usm_mem_properties *properties, size_t size, - pi_uint32 alignment); +__SYCL_EXPORT pi_result piextUSMHostAlloc(void **result_ptr, pi_context context, + pi_usm_mem_properties *properties, + size_t size, pi_uint32 alignment); /// Allocates device memory /// @@ -1311,10 +1329,11 @@ pi_result piextUSMHostAlloc(void **result_ptr, pi_context context, /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -pi_result piextUSMDeviceAlloc(void **result_ptr, pi_context context, - pi_device device, - pi_usm_mem_properties *properties, size_t size, - pi_uint32 alignment); +__SYCL_EXPORT pi_result piextUSMDeviceAlloc(void **result_ptr, + pi_context context, + pi_device device, + pi_usm_mem_properties *properties, + size_t size, pi_uint32 alignment); /// Allocates memory accessible on both host and device /// @@ -1324,16 +1343,17 @@ pi_result piextUSMDeviceAlloc(void **result_ptr, pi_context context, /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -pi_result piextUSMSharedAlloc(void **result_ptr, pi_context context, - pi_device device, - pi_usm_mem_properties *properties, size_t size, - pi_uint32 alignment); +__SYCL_EXPORT pi_result piextUSMSharedAlloc(void **result_ptr, + pi_context context, + pi_device device, + pi_usm_mem_properties *properties, + size_t size, pi_uint32 alignment); /// Frees allocated USM memory /// /// \param context is the pi_context of the allocation /// \param ptr is the memory to be freed -pi_result piextUSMFree(pi_context context, void *ptr); +__SYCL_EXPORT pi_result piextUSMFree(pi_context context, void *ptr); /// USM Memset API /// @@ -1346,10 +1366,11 @@ pi_result piextUSMFree(pi_context context, void *ptr); /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -pi_result piextUSMEnqueueMemset(pi_queue queue, void *ptr, pi_int32 value, - size_t count, pi_uint32 num_events_in_waitlist, - const pi_event *events_waitlist, - pi_event *event); +__SYCL_EXPORT pi_result piextUSMEnqueueMemset(pi_queue queue, void *ptr, + pi_int32 value, size_t count, + pi_uint32 num_events_in_waitlist, + const pi_event *events_waitlist, + pi_event *event); /// USM Memcpy API /// @@ -1361,11 +1382,12 @@ pi_result piextUSMEnqueueMemset(pi_queue queue, void *ptr, pi_int32 value, /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -pi_result piextUSMEnqueueMemcpy(pi_queue queue, pi_bool blocking, void *dst_ptr, - const void *src_ptr, size_t size, - pi_uint32 num_events_in_waitlist, - const pi_event *events_waitlist, - pi_event *event); +__SYCL_EXPORT pi_result piextUSMEnqueueMemcpy(pi_queue queue, pi_bool blocking, + void *dst_ptr, + const void *src_ptr, size_t size, + pi_uint32 num_events_in_waitlist, + const pi_event *events_waitlist, + pi_event *event); /// Hint to migrate memory to the device /// @@ -1376,11 +1398,10 @@ pi_result piextUSMEnqueueMemcpy(pi_queue queue, pi_bool blocking, void *dst_ptr, /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -pi_result piextUSMEnqueuePrefetch(pi_queue queue, const void *ptr, size_t size, - pi_usm_migration_flags flags, - pi_uint32 num_events_in_waitlist, - const pi_event *events_waitlist, - pi_event *event); +__SYCL_EXPORT pi_result piextUSMEnqueuePrefetch( + pi_queue queue, const void *ptr, size_t size, pi_usm_migration_flags flags, + pi_uint32 num_events_in_waitlist, const pi_event *events_waitlist, + pi_event *event); /// USM Memadvise API /// @@ -1390,8 +1411,9 @@ pi_result piextUSMEnqueuePrefetch(pi_queue queue, const void *ptr, size_t size, /// \param advice is device specific advice /// \param event is the event that represents this operation // USM memadvise API to govern behavior of automatic migration mechanisms -pi_result piextUSMEnqueueMemAdvise(pi_queue queue, const void *ptr, - size_t length, int advice, pi_event *event); +__SYCL_EXPORT pi_result piextUSMEnqueueMemAdvise(pi_queue queue, + const void *ptr, size_t length, + int advice, pi_event *event); /// API to query information about USM allocated pointers /// Valid Queries: @@ -1409,10 +1431,9 @@ pi_result piextUSMEnqueueMemAdvise(pi_queue queue, const void *ptr, /// \param param_value_size is the size of the result in bytes /// \param param_value is the result /// \param param_value_ret is how many bytes were written -pi_result piextUSMGetMemAllocInfo(pi_context context, const void *ptr, - pi_mem_info param_name, - size_t param_value_size, void *param_value, - size_t *param_value_size_ret); +__SYCL_EXPORT pi_result piextUSMGetMemAllocInfo( + pi_context context, const void *ptr, pi_mem_info param_name, + size_t param_value_size, void *param_value, size_t *param_value_size_ret); struct _pi_plugin { // PI version supported by host passed to the plugin. The Plugin diff --git a/sycl/plugins/ld-version-script.txt b/sycl/plugins/ld-version-script.txt new file mode 100644 index 0000000000000..1ad2c6d5f8390 --- /dev/null +++ b/sycl/plugins/ld-version-script.txt @@ -0,0 +1,10 @@ +{ + /* in CMakelists.txt, we pass -fvisibility=hidden compiler flag */ + /* This file is used to give exception of the hidden visibility */ + /* Export only pi* function symbols which are individually marked 'default' visibility */ + + global: pi*; + + /* all other symbols are local scope, meaning not exported */ + local: *; +}; diff --git a/sycl/plugins/opencl/CMakeLists.txt b/sycl/plugins/opencl/CMakeLists.txt index b085d53ba8175..b5621e1127ca0 100644 --- a/sycl/plugins/opencl/CMakeLists.txt +++ b/sycl/plugins/opencl/CMakeLists.txt @@ -9,9 +9,16 @@ #TODO: remove dependency on pi.hpp in sycl project. #TODO: Currently, the pi.hpp header is common between sycl and plugin library sources. #This can be changed by copying the pi.hpp file in the plugins project. +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/../../source/version.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/version.rc + @ONLY) + +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) add_library(pi_opencl SHARED "${sycl_inc_dir}/CL/sycl/detail/pi.h" "pi_opencl.cpp" + ${CMAKE_CURRENT_BINARY_DIR}/version.rc ) add_dependencies(pi_opencl @@ -26,14 +33,37 @@ set_target_properties(pi_opencl PROPERTIES LINKER_LANGUAGE CXX) #preprocessor definitions for compiling a target's sources. We do not need it for pi_opencl target_include_directories(pi_opencl PRIVATE "${sycl_inc_dir}") -#link pi_opencl with OpenCL headers and ICD Loader. -target_link_libraries( pi_opencl +if (MSVC) + target_compile_definitions(pi_opencl PRIVATE __SYCL_BUILD_SYCL_DLL) + target_link_libraries(pi_opencl PRIVATE shlwapi) + target_link_libraries( pi_opencl PRIVATE OpenCL::Headers PRIVATE ${OpenCL_LIBRARIES} -) + ) +else() + # we set the visibility of all symbols 'hidden' by default. + # In *.cpp files, we set exported symbols with visibility==default individually + target_compile_options(pi_opencl PUBLIC -fvisibility=hidden) + + # This script file is used to allow exporting pi* symbols only. + # All other symbols are regarded as local (hidden) + set(linker_script "${CMAKE_CURRENT_SOURCE_DIR}/../ld-version-script.txt") + + #link pi_opencl with OpenCL headers and ICD Loader. + target_link_libraries( pi_opencl + PRIVATE OpenCL::Headers + PRIVATE ${OpenCL_LIBRARIES} + # Filter symbols based on the scope defined in the script file, + # and export pi* function symbols in the library. + PRIVATE "-Wl,--version-script=${linker_script}" + ) +endif() add_common_options(pi_opencl) +set_target_properties(pi_opencl PROPERTIES + VERSION ${SYCL_VERSION_STRING} + SOVERSION ${SYCL_MAJOR_VERSION}) install(TARGETS pi_opencl LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT pi_opencl RUNTIME DESTINATION "bin" COMPONENT pi_opencl) diff --git a/sycl/plugins/opencl/pi_opencl.cpp b/sycl/plugins/opencl/pi_opencl.cpp index 67e0e98935543..3dc45b56ecfd0 100644 --- a/sycl/plugins/opencl/pi_opencl.cpp +++ b/sycl/plugins/opencl/pi_opencl.cpp @@ -15,6 +15,7 @@ /// \ingroup sycl_pi_ocl #include +#include #include #include @@ -161,11 +162,12 @@ static pi_result USMSetIndirectAccess(pi_kernel kernel) { extern "C" { // Convenience macro makes source code search easier -#define OCL(pi_api) Ocl##pi_api +#define OCL(pi_api) pi_api // Example of a PI interface that does not map exactly to an OpenCL one. -pi_result OCL(piPlatformsGet)(pi_uint32 num_entries, pi_platform *platforms, - pi_uint32 *num_platforms) { +__SYCL_EXPORT pi_result OCL(piPlatformsGet)(pi_uint32 num_entries, + pi_platform *platforms, + pi_uint32 *num_platforms) { cl_int result = clGetPlatformIDs(cast(num_entries), cast(platforms), cast(num_platforms)); @@ -180,9 +182,11 @@ pi_result OCL(piPlatformsGet)(pi_uint32 num_entries, pi_platform *platforms, } // Example of a PI interface that does not map exactly to an OpenCL one. -pi_result OCL(piDevicesGet)(pi_platform platform, pi_device_type device_type, - pi_uint32 num_entries, pi_device *devices, - pi_uint32 *num_devices) { +__SYCL_EXPORT pi_result OCL(piDevicesGet)(pi_platform platform, + pi_device_type device_type, + pi_uint32 num_entries, + pi_device *devices, + pi_uint32 *num_devices) { cl_int result = clGetDeviceIDs( cast(platform), cast(device_type), cast(num_entries), cast(devices), @@ -197,10 +201,9 @@ pi_result OCL(piDevicesGet)(pi_platform platform, pi_device_type device_type, return cast(result); } -pi_result OCL(piextDeviceSelectBinary)(pi_device device, - pi_device_binary *images, - pi_uint32 num_images, - pi_uint32 *selected_image_ind) { +__SYCL_EXPORT pi_result OCL(piextDeviceSelectBinary)( + pi_device device, pi_device_binary *images, pi_uint32 num_images, + pi_uint32 *selected_image_ind) { // TODO: this is a bare-bones implementation for choosing a device image // that would be compatible with the targeted device. An AOT-compiled @@ -269,15 +272,16 @@ pi_result OCL(piextDeviceSelectBinary)(pi_device device, return PI_INVALID_BINARY; } -pi_result OCL(piextDeviceCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_device *piDevice) { +__SYCL_EXPORT pi_result OCL(piextDeviceCreateWithNativeHandle)( + pi_native_handle nativeHandle, pi_device *piDevice) { assert(piDevice != nullptr); *piDevice = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piQueueCreate)(pi_context context, pi_device device, - pi_queue_properties properties, pi_queue *queue) { +__SYCL_EXPORT pi_result OCL(piQueueCreate)(pi_context context, pi_device device, + pi_queue_properties properties, + pi_queue *queue) { assert(queue && "piQueueCreate failed, queue argument is null"); cl_platform_id curPlatform; @@ -316,15 +320,16 @@ pi_result OCL(piQueueCreate)(pi_context context, pi_device device, return cast(ret_err); } -pi_result OCL(piextQueueCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_queue *piQueue) { +__SYCL_EXPORT pi_result OCL(piextQueueCreateWithNativeHandle)( + pi_native_handle nativeHandle, pi_queue *piQueue) { assert(piQueue != nullptr); *piQueue = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piProgramCreate)(pi_context context, const void *il, - size_t length, pi_program *res_program) { +__SYCL_EXPORT pi_result OCL(piProgramCreate)(pi_context context, const void *il, + size_t length, + pi_program *res_program) { size_t deviceCount; @@ -401,16 +406,16 @@ pi_result OCL(piProgramCreate)(pi_context context, const void *il, return err; } -pi_result OCL(piextProgramCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_program *piProgram) { +__SYCL_EXPORT pi_result OCL(piextProgramCreateWithNativeHandle)( + pi_native_handle nativeHandle, pi_program *piProgram) { assert(piProgram != nullptr); *piProgram = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piSamplerCreate)(pi_context context, - const pi_sampler_properties *sampler_properties, - pi_sampler *result_sampler) { +__SYCL_EXPORT pi_result OCL(piSamplerCreate)( + pi_context context, const pi_sampler_properties *sampler_properties, + pi_sampler *result_sampler) { // Initialize properties according to OpenCL 2.1 spec. pi_result error_code; pi_bool normalizedCoords = PI_TRUE; @@ -439,17 +444,17 @@ pi_result OCL(piSamplerCreate)(pi_context context, return error_code; } -pi_result OCL(piextKernelSetArgMemObj)(pi_kernel kernel, pi_uint32 arg_index, - const pi_mem *arg_value) { +__SYCL_EXPORT pi_result OCL(piextKernelSetArgMemObj)(pi_kernel kernel, + pi_uint32 arg_index, + const pi_mem *arg_value) { return cast( clSetKernelArg(cast(kernel), cast(arg_index), sizeof(arg_value), cast(arg_value))); } -pi_result OCL(piextGetDeviceFunctionPointer)(pi_device device, - pi_program program, - const char *func_name, - pi_uint64 *function_pointer_ret) { +__SYCL_EXPORT pi_result OCL(piextGetDeviceFunctionPointer)( + pi_device device, pi_program program, const char *func_name, + pi_uint64 *function_pointer_ret) { pi_platform platform; cl_int ret_err = clGetDeviceInfo(cast(device), PI_DEVICE_INFO_PLATFORM, @@ -484,12 +489,12 @@ pi_result OCL(piextGetDeviceFunctionPointer)(pi_device device, function_pointer_ret)); } -pi_result OCL(piContextCreate)(const pi_context_properties *properties, - pi_uint32 num_devices, const pi_device *devices, - void (*pfn_notify)(const char *errinfo, - const void *private_info, - size_t cb, void *user_data1), - void *user_data, pi_context *retcontext) { +__SYCL_EXPORT pi_result OCL(piContextCreate)( + const pi_context_properties *properties, pi_uint32 num_devices, + const pi_device *devices, + void (*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, + void *user_data1), + void *user_data, pi_context *retcontext) { pi_result ret = PI_INVALID_OPERATION; *retcontext = cast( clCreateContext(properties, cast(num_devices), @@ -499,15 +504,17 @@ pi_result OCL(piContextCreate)(const pi_context_properties *properties, return ret; } -pi_result OCL(piextContextCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_context *piContext) { +__SYCL_EXPORT pi_result OCL(piextContextCreateWithNativeHandle)( + pi_native_handle nativeHandle, pi_context *piContext) { assert(piContext != nullptr); *piContext = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piMemBufferCreate)(pi_context context, pi_mem_flags flags, - size_t size, void *host_ptr, pi_mem *ret_mem) { +__SYCL_EXPORT pi_result OCL(piMemBufferCreate)(pi_context context, + pi_mem_flags flags, size_t size, + void *host_ptr, + pi_mem *ret_mem) { pi_result ret_err = PI_INVALID_OPERATION; *ret_mem = cast(clCreateBuffer(cast(context), cast(flags), size, @@ -516,10 +523,9 @@ pi_result OCL(piMemBufferCreate)(pi_context context, pi_mem_flags flags, return ret_err; } -pi_result OCL(piMemImageCreate)(pi_context context, pi_mem_flags flags, - const pi_image_format *image_format, - const pi_image_desc *image_desc, void *host_ptr, - pi_mem *ret_mem) { +__SYCL_EXPORT pi_result OCL(piMemImageCreate)( + pi_context context, pi_mem_flags flags, const pi_image_format *image_format, + const pi_image_desc *image_desc, void *host_ptr, pi_mem *ret_mem) { pi_result ret_err = PI_INVALID_OPERATION; *ret_mem = cast( clCreateImage(cast(context), cast(flags), @@ -530,9 +536,9 @@ pi_result OCL(piMemImageCreate)(pi_context context, pi_mem_flags flags, return ret_err; } -pi_result OCL(piMemBufferPartition)(pi_mem buffer, pi_mem_flags flags, - pi_buffer_create_type buffer_create_type, - void *buffer_create_info, pi_mem *ret_mem) { +__SYCL_EXPORT pi_result OCL(piMemBufferPartition)( + pi_mem buffer, pi_mem_flags flags, pi_buffer_create_type buffer_create_type, + void *buffer_create_info, pi_mem *ret_mem) { pi_result ret_err = PI_INVALID_OPERATION; *ret_mem = cast( @@ -542,17 +548,16 @@ pi_result OCL(piMemBufferPartition)(pi_mem buffer, pi_mem_flags flags, return ret_err; } -pi_result OCL(piextMemCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_mem *piMem) { +__SYCL_EXPORT pi_result OCL(piextMemCreateWithNativeHandle)( + pi_native_handle nativeHandle, pi_mem *piMem) { assert(piMem != nullptr); *piMem = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piclProgramCreateWithSource)(pi_context context, pi_uint32 count, - const char **strings, - const size_t *lengths, - pi_program *ret_program) { +__SYCL_EXPORT pi_result OCL(piclProgramCreateWithSource)( + pi_context context, pi_uint32 count, const char **strings, + const size_t *lengths, pi_program *ret_program) { pi_result ret_err = PI_INVALID_OPERATION; *ret_program = cast( @@ -561,7 +566,7 @@ pi_result OCL(piclProgramCreateWithSource)(pi_context context, pi_uint32 count, return ret_err; } -pi_result OCL(piclProgramCreateWithBinary)( +__SYCL_EXPORT pi_result OCL(piclProgramCreateWithBinary)( pi_context context, pi_uint32 num_devices, const pi_device *device_list, const size_t *lengths, const unsigned char **binaries, pi_int32 *binary_status, pi_program *ret_program) { @@ -574,13 +579,12 @@ pi_result OCL(piclProgramCreateWithBinary)( return ret_err; } -pi_result OCL(piProgramLink)(pi_context context, pi_uint32 num_devices, - const pi_device *device_list, const char *options, - pi_uint32 num_input_programs, - const pi_program *input_programs, - void (*pfn_notify)(pi_program program, - void *user_data), - void *user_data, pi_program *ret_program) { +__SYCL_EXPORT pi_result OCL(piProgramLink)( + pi_context context, pi_uint32 num_devices, const pi_device *device_list, + const char *options, pi_uint32 num_input_programs, + const pi_program *input_programs, + void (*pfn_notify)(pi_program program, void *user_data), void *user_data, + pi_program *ret_program) { pi_result ret_err = PI_INVALID_OPERATION; *ret_program = cast( @@ -593,8 +597,9 @@ pi_result OCL(piProgramLink)(pi_context context, pi_uint32 num_devices, return ret_err; } -pi_result OCL(piKernelCreate)(pi_program program, const char *kernel_name, - pi_kernel *ret_kernel) { +__SYCL_EXPORT pi_result OCL(piKernelCreate)(pi_program program, + const char *kernel_name, + pi_kernel *ret_kernel) { pi_result ret_err = PI_INVALID_OPERATION; *ret_kernel = cast(clCreateKernel( @@ -602,7 +607,8 @@ pi_result OCL(piKernelCreate)(pi_program program, const char *kernel_name, return ret_err; } -pi_result OCL(piEventCreate)(pi_context context, pi_event *ret_event) { +__SYCL_EXPORT pi_result OCL(piEventCreate)(pi_context context, + pi_event *ret_event) { pi_result ret_err = PI_INVALID_OPERATION; *ret_event = cast( @@ -610,14 +616,14 @@ pi_result OCL(piEventCreate)(pi_context context, pi_event *ret_event) { return ret_err; } -pi_result OCL(piextEventCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_event *piEvent) { +__SYCL_EXPORT pi_result OCL(piextEventCreateWithNativeHandle)( + pi_native_handle nativeHandle, pi_event *piEvent) { assert(piEvent != nullptr); *piEvent = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piEnqueueMemBufferMap)( +__SYCL_EXPORT pi_result OCL(piEnqueueMemBufferMap)( pi_queue command_queue, pi_mem buffer, pi_bool blocking_map, cl_map_flags map_flags, // TODO: untie from OpenCL size_t offset, size_t size, pi_uint32 num_events_in_wait_list, @@ -644,9 +650,9 @@ pi_result OCL(piEnqueueMemBufferMap)( /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -pi_result OCL(piextUSMHostAlloc)(void **result_ptr, pi_context context, - pi_usm_mem_properties *properties, size_t size, - pi_uint32 alignment) { +__SYCL_EXPORT pi_result OCL(piextUSMHostAlloc)( + void **result_ptr, pi_context context, pi_usm_mem_properties *properties, + size_t size, pi_uint32 alignment) { void *Ptr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -675,10 +681,9 @@ pi_result OCL(piextUSMHostAlloc)(void **result_ptr, pi_context context, /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -pi_result OCL(piextUSMDeviceAlloc)(void **result_ptr, pi_context context, - pi_device device, - pi_usm_mem_properties *properties, - size_t size, pi_uint32 alignment) { +__SYCL_EXPORT pi_result OCL(piextUSMDeviceAlloc)( + void **result_ptr, pi_context context, pi_device device, + pi_usm_mem_properties *properties, size_t size, pi_uint32 alignment) { void *Ptr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -708,10 +713,9 @@ pi_result OCL(piextUSMDeviceAlloc)(void **result_ptr, pi_context context, /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -pi_result OCL(piextUSMSharedAlloc)(void **result_ptr, pi_context context, - pi_device device, - pi_usm_mem_properties *properties, - size_t size, pi_uint32 alignment) { +__SYCL_EXPORT pi_result OCL(piextUSMSharedAlloc)( + void **result_ptr, pi_context context, pi_device device, + pi_usm_mem_properties *properties, size_t size, pi_uint32 alignment) { void *Ptr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -737,7 +741,7 @@ pi_result OCL(piextUSMSharedAlloc)(void **result_ptr, pi_context context, /// /// \param context is the pi_context of the allocation /// \param ptr is the memory to be freed -pi_result OCL(piextUSMFree)(pi_context context, void *ptr) { +__SYCL_EXPORT pi_result OCL(piextUSMFree)(pi_context context, void *ptr) { clMemFreeINTEL_fn FuncPtr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -758,9 +762,10 @@ pi_result OCL(piextUSMFree)(pi_context context, void *ptr) { /// \param arg_index is the index of the kernel argument /// \param arg_size is the size in bytes of the argument (ignored in CL) /// \param arg_value is the pointer argument -pi_result OCL(piextKernelSetArgPointer)(pi_kernel kernel, pi_uint32 arg_index, - size_t arg_size, - const void *arg_value) { +__SYCL_EXPORT pi_result OCL(piextKernelSetArgPointer)(pi_kernel kernel, + pi_uint32 arg_index, + size_t arg_size, + const void *arg_value) { // Size is unused in CL as pointer args are passed by value. @@ -799,11 +804,10 @@ pi_result OCL(piextKernelSetArgPointer)(pi_kernel kernel, pi_uint32 arg_index, /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -pi_result OCL(piextUSMEnqueueMemset)(pi_queue queue, void *ptr, pi_int32 value, - size_t count, - pi_uint32 num_events_in_waitlist, - const pi_event *events_waitlist, - pi_event *event) { +__SYCL_EXPORT pi_result +OCL(piextUSMEnqueueMemset)(pi_queue queue, void *ptr, pi_int32 value, + size_t count, pi_uint32 num_events_in_waitlist, + const pi_event *events_waitlist, pi_event *event) { // Have to look up the context from the kernel cl_context CLContext; @@ -839,12 +843,10 @@ pi_result OCL(piextUSMEnqueueMemset)(pi_queue queue, void *ptr, pi_int32 value, /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -pi_result OCL(piextUSMEnqueueMemcpy)(pi_queue queue, pi_bool blocking, - void *dst_ptr, const void *src_ptr, - size_t size, - pi_uint32 num_events_in_waitlist, - const pi_event *events_waitlist, - pi_event *event) { +__SYCL_EXPORT pi_result OCL(piextUSMEnqueueMemcpy)( + pi_queue queue, pi_bool blocking, void *dst_ptr, const void *src_ptr, + size_t size, pi_uint32 num_events_in_waitlist, + const pi_event *events_waitlist, pi_event *event) { // Have to look up the context from the kernel cl_context CLContext; @@ -879,12 +881,10 @@ pi_result OCL(piextUSMEnqueueMemcpy)(pi_queue queue, pi_bool blocking, /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -pi_result OCL(piextUSMEnqueuePrefetch)(pi_queue queue, const void *ptr, - size_t size, - pi_usm_migration_flags flags, - pi_uint32 num_events_in_waitlist, - const pi_event *events_waitlist, - pi_event *event) { +__SYCL_EXPORT pi_result OCL(piextUSMEnqueuePrefetch)( + pi_queue queue, const void *ptr, size_t size, pi_usm_migration_flags flags, + pi_uint32 num_events_in_waitlist, const pi_event *events_waitlist, + pi_event *event) { return cast(clEnqueueMarkerWithWaitList( cast(queue), num_events_in_waitlist, @@ -924,9 +924,10 @@ pi_result OCL(piextUSMEnqueuePrefetch)(pi_queue queue, const void *ptr, /// \param advice is device specific advice /// \param event is the event that represents this operation // USM memadvise API to govern behavior of automatic migration mechanisms -pi_result OCL(piextUSMEnqueueMemAdvise)(pi_queue queue, const void *ptr, - size_t length, int advice, - pi_event *event) { +__SYCL_EXPORT pi_result OCL(piextUSMEnqueueMemAdvise)(pi_queue queue, + const void *ptr, + size_t length, int advice, + pi_event *event) { return cast( clEnqueueMarkerWithWaitList(cast(queue), 0, nullptr, @@ -976,11 +977,9 @@ pi_result OCL(piextUSMEnqueueMemAdvise)(pi_queue queue, const void *ptr, /// \param param_value_size is the size of the result in bytes /// \param param_value is the result /// \param param_value_ret is how many bytes were written -pi_result OCL(piextUSMGetMemAllocInfo)(pi_context context, const void *ptr, - pi_mem_info param_name, - size_t param_value_size, - void *param_value, - size_t *param_value_size_ret) { +__SYCL_EXPORT pi_result OCL(piextUSMGetMemAllocInfo)( + pi_context context, const void *ptr, pi_mem_info param_name, + size_t param_value_size, void *param_value, size_t *param_value_size_ret) { clGetMemAllocInfoINTEL_fn FuncPtr = nullptr; pi_result RetVal = @@ -1007,10 +1006,10 @@ pi_result OCL(piextUSMGetMemAllocInfo)(pi_context context, const void *ptr, /// If param_name is PI_USM_INDIRECT_ACCESS, the value will be a ptr to /// the pi_bool value PI_TRUE /// If param_name is PI_USM_PTRS, the value will be an array of ptrs -pi_result OCL(piKernelSetExecInfo)(pi_kernel kernel, - pi_kernel_exec_info param_name, - size_t param_value_size, - const void *param_value) { +__SYCL_EXPORT pi_result OCL(piKernelSetExecInfo)(pi_kernel kernel, + pi_kernel_exec_info param_name, + size_t param_value_size, + const void *param_value) { if (param_name == PI_USM_INDIRECT_ACCESS && *(static_cast(param_value)) == PI_TRUE) { return USMSetIndirectAccess(kernel); @@ -1024,7 +1023,7 @@ typedef CL_API_ENTRY cl_int(CL_API_CALL *clSetProgramSpecializationConstant_fn)( cl_program program, cl_uint spec_id, size_t spec_size, const void *spec_value); -static pi_result OCL(piextProgramSetSpecializationConstantImpl)( +__SYCL_EXPORT pi_result OCL(piextProgramSetSpecializationConstantImpl)( pi_program prog, unsigned int spec_id, size_t spec_size, const void *spec_value) { cl_program ClProg = cast(prog); @@ -1052,14 +1051,14 @@ static pi_result OCL(piextProgramSetSpecializationConstantImpl)( /// \param nativeHandle is a pointer to be set to the native handle /// /// PI_SUCCESS -pi_result OCL(piextGetNativeHandle)(void *piObj, - pi_native_handle *nativeHandle) { +__SYCL_EXPORT pi_result +OCL(piextGetNativeHandle)(void *piObj, pi_native_handle *nativeHandle) { assert(nativeHandle != nullptr); *nativeHandle = reinterpret_cast(piObj); return PI_SUCCESS; } -pi_result piPluginInit(pi_plugin *PluginInit) { +__SYCL_EXPORT pi_result piPluginInit(pi_plugin *PluginInit) { int CompareVersions = strcmp(PluginInit->PiVersion, SupportedVersion); if (CompareVersions < 0) { // PI interface supports lower version of PI. From 41baa48a9025827cc6f67349c1408b0323b01d60 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Mon, 4 May 2020 14:54:59 -0700 Subject: [PATCH 25/32] [SYCL] Export only *pi symbols in libpi_opencl.so Cleaned up some unnecessary versioning code Changed library scope from SHARED to MODULE to limit its usage Moved duplicate code out of condition Signed-off-by: Byoungro So --- sycl/include/CL/sycl/detail/pi.h | 2 +- sycl/plugins/opencl/CMakeLists.txt | 26 ++++++++++---------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index a360f724422ae..e734d9c20061f 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -46,7 +46,7 @@ // elsewhere, e.g. in the pi_opencl, but constants/enums mapping is now // done here, for efficiency and simplicity. -#include "export.hpp" +#include #include #include #include diff --git a/sycl/plugins/opencl/CMakeLists.txt b/sycl/plugins/opencl/CMakeLists.txt index b5621e1127ca0..535fd491a3421 100644 --- a/sycl/plugins/opencl/CMakeLists.txt +++ b/sycl/plugins/opencl/CMakeLists.txt @@ -9,16 +9,14 @@ #TODO: remove dependency on pi.hpp in sycl project. #TODO: Currently, the pi.hpp header is common between sycl and plugin library sources. #This can be changed by copying the pi.hpp file in the plugins project. -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/../../source/version.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - @ONLY) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -add_library(pi_opencl SHARED + +# We chose MODULE type because libpi_opencl.so should never be linked dynamically to a target. +# MODULE will limit this library to be used to load symbols via dllopen only +add_library(pi_opencl MODULE "${sycl_inc_dir}/CL/sycl/detail/pi.h" "pi_opencl.cpp" - ${CMAKE_CURRENT_BINARY_DIR}/version.rc ) add_dependencies(pi_opencl @@ -33,13 +31,14 @@ set_target_properties(pi_opencl PROPERTIES LINKER_LANGUAGE CXX) #preprocessor definitions for compiling a target's sources. We do not need it for pi_opencl target_include_directories(pi_opencl PRIVATE "${sycl_inc_dir}") +target_link_libraries( pi_opencl + PRIVATE OpenCL::Headers + PRIVATE ${OpenCL_LIBRARIES} +) if (MSVC) + # by defining __SYCL_BUILD_SYCL_DLL, we can use __declspec(dllexport) + # which are individually tagged for all pi* symbols in pi_opencl.cpp target_compile_definitions(pi_opencl PRIVATE __SYCL_BUILD_SYCL_DLL) - target_link_libraries(pi_opencl PRIVATE shlwapi) - target_link_libraries( pi_opencl - PRIVATE OpenCL::Headers - PRIVATE ${OpenCL_LIBRARIES} - ) else() # we set the visibility of all symbols 'hidden' by default. # In *.cpp files, we set exported symbols with visibility==default individually @@ -51,8 +50,6 @@ else() #link pi_opencl with OpenCL headers and ICD Loader. target_link_libraries( pi_opencl - PRIVATE OpenCL::Headers - PRIVATE ${OpenCL_LIBRARIES} # Filter symbols based on the scope defined in the script file, # and export pi* function symbols in the library. PRIVATE "-Wl,--version-script=${linker_script}" @@ -61,9 +58,6 @@ endif() add_common_options(pi_opencl) -set_target_properties(pi_opencl PROPERTIES - VERSION ${SYCL_VERSION_STRING} - SOVERSION ${SYCL_MAJOR_VERSION}) install(TARGETS pi_opencl LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT pi_opencl RUNTIME DESTINATION "bin" COMPONENT pi_opencl) From 95b11806051e98555b7265d83df5f0a8acd39a42 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Mon, 4 May 2020 15:01:32 -0700 Subject: [PATCH 26/32] moved down include to conform to clang style Signed-off-by: Byoungro So --- sycl/include/CL/sycl/detail/pi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index e734d9c20061f..854c7387817cf 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -46,9 +46,9 @@ // elsewhere, e.g. in the pi_opencl, but constants/enums mapping is now // done here, for efficiency and simplicity. -#include #include #include +#include #include #ifdef __cplusplus From 5aa0d86cd769e89ad1ae9474294d34cd08e47c26 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Tue, 5 May 2020 15:46:09 -0700 Subject: [PATCH 27/32] removed __SYCL_EXPORT in pi_opencl.cpp because we already attached it in pi.h Signed-off-by: Byoungro So --- sycl/plugins/opencl/CMakeLists.txt | 6 +- sycl/plugins/opencl/pi_opencl.cpp | 225 +++++++++++++++-------------- 2 files changed, 116 insertions(+), 115 deletions(-) diff --git a/sycl/plugins/opencl/CMakeLists.txt b/sycl/plugins/opencl/CMakeLists.txt index 535fd491a3421..85096b7d99f28 100644 --- a/sycl/plugins/opencl/CMakeLists.txt +++ b/sycl/plugins/opencl/CMakeLists.txt @@ -13,7 +13,7 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) # We chose MODULE type because libpi_opencl.so should never be linked dynamically to a target. -# MODULE will limit this library to be used to load symbols via dllopen only +# MODULE will limit this library to be used to load symbols via dlopen only add_library(pi_opencl MODULE "${sycl_inc_dir}/CL/sycl/detail/pi.h" "pi_opencl.cpp" @@ -37,11 +37,11 @@ target_link_libraries( pi_opencl ) if (MSVC) # by defining __SYCL_BUILD_SYCL_DLL, we can use __declspec(dllexport) - # which are individually tagged for all pi* symbols in pi_opencl.cpp + # which are individually tagged for all pi* symbols in pi.h target_compile_definitions(pi_opencl PRIVATE __SYCL_BUILD_SYCL_DLL) else() # we set the visibility of all symbols 'hidden' by default. - # In *.cpp files, we set exported symbols with visibility==default individually + # In pi.h file, we set exported symbols with visibility==default individually target_compile_options(pi_opencl PUBLIC -fvisibility=hidden) # This script file is used to allow exporting pi* symbols only. diff --git a/sycl/plugins/opencl/pi_opencl.cpp b/sycl/plugins/opencl/pi_opencl.cpp index 3dc45b56ecfd0..092ad00b7867c 100644 --- a/sycl/plugins/opencl/pi_opencl.cpp +++ b/sycl/plugins/opencl/pi_opencl.cpp @@ -15,7 +15,6 @@ /// \ingroup sycl_pi_ocl #include -#include #include #include @@ -165,9 +164,8 @@ extern "C" { #define OCL(pi_api) pi_api // Example of a PI interface that does not map exactly to an OpenCL one. -__SYCL_EXPORT pi_result OCL(piPlatformsGet)(pi_uint32 num_entries, - pi_platform *platforms, - pi_uint32 *num_platforms) { +pi_result OCL(piPlatformsGet)(pi_uint32 num_entries, pi_platform *platforms, + pi_uint32 *num_platforms) { cl_int result = clGetPlatformIDs(cast(num_entries), cast(platforms), cast(num_platforms)); @@ -182,11 +180,9 @@ __SYCL_EXPORT pi_result OCL(piPlatformsGet)(pi_uint32 num_entries, } // Example of a PI interface that does not map exactly to an OpenCL one. -__SYCL_EXPORT pi_result OCL(piDevicesGet)(pi_platform platform, - pi_device_type device_type, - pi_uint32 num_entries, - pi_device *devices, - pi_uint32 *num_devices) { +pi_result OCL(piDevicesGet)(pi_platform platform, pi_device_type device_type, + pi_uint32 num_entries, pi_device *devices, + pi_uint32 *num_devices) { cl_int result = clGetDeviceIDs( cast(platform), cast(device_type), cast(num_entries), cast(devices), @@ -201,9 +197,10 @@ __SYCL_EXPORT pi_result OCL(piDevicesGet)(pi_platform platform, return cast(result); } -__SYCL_EXPORT pi_result OCL(piextDeviceSelectBinary)( - pi_device device, pi_device_binary *images, pi_uint32 num_images, - pi_uint32 *selected_image_ind) { +pi_result OCL(piextDeviceSelectBinary)(pi_device device, + pi_device_binary *images, + pi_uint32 num_images, + pi_uint32 *selected_image_ind) { // TODO: this is a bare-bones implementation for choosing a device image // that would be compatible with the targeted device. An AOT-compiled @@ -272,16 +269,15 @@ __SYCL_EXPORT pi_result OCL(piextDeviceSelectBinary)( return PI_INVALID_BINARY; } -__SYCL_EXPORT pi_result OCL(piextDeviceCreateWithNativeHandle)( - pi_native_handle nativeHandle, pi_device *piDevice) { +pi_result OCL(piextDeviceCreateWithNativeHandle)(pi_native_handle nativeHandle, + pi_device *piDevice) { assert(piDevice != nullptr); *piDevice = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -__SYCL_EXPORT pi_result OCL(piQueueCreate)(pi_context context, pi_device device, - pi_queue_properties properties, - pi_queue *queue) { +pi_result OCL(piQueueCreate)(pi_context context, pi_device device, + pi_queue_properties properties, pi_queue *queue) { assert(queue && "piQueueCreate failed, queue argument is null"); cl_platform_id curPlatform; @@ -320,16 +316,15 @@ __SYCL_EXPORT pi_result OCL(piQueueCreate)(pi_context context, pi_device device, return cast(ret_err); } -__SYCL_EXPORT pi_result OCL(piextQueueCreateWithNativeHandle)( - pi_native_handle nativeHandle, pi_queue *piQueue) { +pi_result OCL(piextQueueCreateWithNativeHandle)(pi_native_handle nativeHandle, + pi_queue *piQueue) { assert(piQueue != nullptr); *piQueue = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -__SYCL_EXPORT pi_result OCL(piProgramCreate)(pi_context context, const void *il, - size_t length, - pi_program *res_program) { +pi_result OCL(piProgramCreate)(pi_context context, const void *il, + size_t length, pi_program *res_program) { size_t deviceCount; @@ -406,16 +401,16 @@ __SYCL_EXPORT pi_result OCL(piProgramCreate)(pi_context context, const void *il, return err; } -__SYCL_EXPORT pi_result OCL(piextProgramCreateWithNativeHandle)( - pi_native_handle nativeHandle, pi_program *piProgram) { +pi_result OCL(piextProgramCreateWithNativeHandle)(pi_native_handle nativeHandle, + pi_program *piProgram) { assert(piProgram != nullptr); *piProgram = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -__SYCL_EXPORT pi_result OCL(piSamplerCreate)( - pi_context context, const pi_sampler_properties *sampler_properties, - pi_sampler *result_sampler) { +pi_result OCL(piSamplerCreate)(pi_context context, + const pi_sampler_properties *sampler_properties, + pi_sampler *result_sampler) { // Initialize properties according to OpenCL 2.1 spec. pi_result error_code; pi_bool normalizedCoords = PI_TRUE; @@ -444,17 +439,17 @@ __SYCL_EXPORT pi_result OCL(piSamplerCreate)( return error_code; } -__SYCL_EXPORT pi_result OCL(piextKernelSetArgMemObj)(pi_kernel kernel, - pi_uint32 arg_index, - const pi_mem *arg_value) { +pi_result OCL(piextKernelSetArgMemObj)(pi_kernel kernel, pi_uint32 arg_index, + const pi_mem *arg_value) { return cast( clSetKernelArg(cast(kernel), cast(arg_index), sizeof(arg_value), cast(arg_value))); } -__SYCL_EXPORT pi_result OCL(piextGetDeviceFunctionPointer)( - pi_device device, pi_program program, const char *func_name, - pi_uint64 *function_pointer_ret) { +pi_result OCL(piextGetDeviceFunctionPointer)(pi_device device, + pi_program program, + const char *func_name, + pi_uint64 *function_pointer_ret) { pi_platform platform; cl_int ret_err = clGetDeviceInfo(cast(device), PI_DEVICE_INFO_PLATFORM, @@ -489,12 +484,12 @@ __SYCL_EXPORT pi_result OCL(piextGetDeviceFunctionPointer)( function_pointer_ret)); } -__SYCL_EXPORT pi_result OCL(piContextCreate)( - const pi_context_properties *properties, pi_uint32 num_devices, - const pi_device *devices, - void (*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, - void *user_data1), - void *user_data, pi_context *retcontext) { +pi_result OCL(piContextCreate)(const pi_context_properties *properties, + pi_uint32 num_devices, const pi_device *devices, + void (*pfn_notify)(const char *errinfo, + const void *private_info, + size_t cb, void *user_data1), + void *user_data, pi_context *retcontext) { pi_result ret = PI_INVALID_OPERATION; *retcontext = cast( clCreateContext(properties, cast(num_devices), @@ -504,17 +499,15 @@ __SYCL_EXPORT pi_result OCL(piContextCreate)( return ret; } -__SYCL_EXPORT pi_result OCL(piextContextCreateWithNativeHandle)( - pi_native_handle nativeHandle, pi_context *piContext) { +pi_result OCL(piextContextCreateWithNativeHandle)(pi_native_handle nativeHandle, + pi_context *piContext) { assert(piContext != nullptr); *piContext = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -__SYCL_EXPORT pi_result OCL(piMemBufferCreate)(pi_context context, - pi_mem_flags flags, size_t size, - void *host_ptr, - pi_mem *ret_mem) { +pi_result OCL(piMemBufferCreate)(pi_context context, pi_mem_flags flags, + size_t size, void *host_ptr, pi_mem *ret_mem) { pi_result ret_err = PI_INVALID_OPERATION; *ret_mem = cast(clCreateBuffer(cast(context), cast(flags), size, @@ -523,9 +516,10 @@ __SYCL_EXPORT pi_result OCL(piMemBufferCreate)(pi_context context, return ret_err; } -__SYCL_EXPORT pi_result OCL(piMemImageCreate)( - pi_context context, pi_mem_flags flags, const pi_image_format *image_format, - const pi_image_desc *image_desc, void *host_ptr, pi_mem *ret_mem) { +pi_result OCL(piMemImageCreate)(pi_context context, pi_mem_flags flags, + const pi_image_format *image_format, + const pi_image_desc *image_desc, void *host_ptr, + pi_mem *ret_mem) { pi_result ret_err = PI_INVALID_OPERATION; *ret_mem = cast( clCreateImage(cast(context), cast(flags), @@ -536,9 +530,9 @@ __SYCL_EXPORT pi_result OCL(piMemImageCreate)( return ret_err; } -__SYCL_EXPORT pi_result OCL(piMemBufferPartition)( - pi_mem buffer, pi_mem_flags flags, pi_buffer_create_type buffer_create_type, - void *buffer_create_info, pi_mem *ret_mem) { +pi_result OCL(piMemBufferPartition)(pi_mem buffer, pi_mem_flags flags, + pi_buffer_create_type buffer_create_type, + void *buffer_create_info, pi_mem *ret_mem) { pi_result ret_err = PI_INVALID_OPERATION; *ret_mem = cast( @@ -548,16 +542,17 @@ __SYCL_EXPORT pi_result OCL(piMemBufferPartition)( return ret_err; } -__SYCL_EXPORT pi_result OCL(piextMemCreateWithNativeHandle)( - pi_native_handle nativeHandle, pi_mem *piMem) { +pi_result OCL(piextMemCreateWithNativeHandle)(pi_native_handle nativeHandle, + pi_mem *piMem) { assert(piMem != nullptr); *piMem = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -__SYCL_EXPORT pi_result OCL(piclProgramCreateWithSource)( - pi_context context, pi_uint32 count, const char **strings, - const size_t *lengths, pi_program *ret_program) { +pi_result OCL(piclProgramCreateWithSource)(pi_context context, pi_uint32 count, + const char **strings, + const size_t *lengths, + pi_program *ret_program) { pi_result ret_err = PI_INVALID_OPERATION; *ret_program = cast( @@ -566,7 +561,7 @@ __SYCL_EXPORT pi_result OCL(piclProgramCreateWithSource)( return ret_err; } -__SYCL_EXPORT pi_result OCL(piclProgramCreateWithBinary)( +pi_result OCL(piclProgramCreateWithBinary)( pi_context context, pi_uint32 num_devices, const pi_device *device_list, const size_t *lengths, const unsigned char **binaries, pi_int32 *binary_status, pi_program *ret_program) { @@ -579,12 +574,13 @@ __SYCL_EXPORT pi_result OCL(piclProgramCreateWithBinary)( return ret_err; } -__SYCL_EXPORT pi_result OCL(piProgramLink)( - pi_context context, pi_uint32 num_devices, const pi_device *device_list, - const char *options, pi_uint32 num_input_programs, - const pi_program *input_programs, - void (*pfn_notify)(pi_program program, void *user_data), void *user_data, - pi_program *ret_program) { +pi_result OCL(piProgramLink)(pi_context context, pi_uint32 num_devices, + const pi_device *device_list, const char *options, + pi_uint32 num_input_programs, + const pi_program *input_programs, + void (*pfn_notify)(pi_program program, + void *user_data), + void *user_data, pi_program *ret_program) { pi_result ret_err = PI_INVALID_OPERATION; *ret_program = cast( @@ -597,9 +593,8 @@ __SYCL_EXPORT pi_result OCL(piProgramLink)( return ret_err; } -__SYCL_EXPORT pi_result OCL(piKernelCreate)(pi_program program, - const char *kernel_name, - pi_kernel *ret_kernel) { +pi_result OCL(piKernelCreate)(pi_program program, const char *kernel_name, + pi_kernel *ret_kernel) { pi_result ret_err = PI_INVALID_OPERATION; *ret_kernel = cast(clCreateKernel( @@ -607,8 +602,7 @@ __SYCL_EXPORT pi_result OCL(piKernelCreate)(pi_program program, return ret_err; } -__SYCL_EXPORT pi_result OCL(piEventCreate)(pi_context context, - pi_event *ret_event) { +pi_result OCL(piEventCreate)(pi_context context, pi_event *ret_event) { pi_result ret_err = PI_INVALID_OPERATION; *ret_event = cast( @@ -616,14 +610,14 @@ __SYCL_EXPORT pi_result OCL(piEventCreate)(pi_context context, return ret_err; } -__SYCL_EXPORT pi_result OCL(piextEventCreateWithNativeHandle)( - pi_native_handle nativeHandle, pi_event *piEvent) { +pi_result OCL(piextEventCreateWithNativeHandle)(pi_native_handle nativeHandle, + pi_event *piEvent) { assert(piEvent != nullptr); *piEvent = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -__SYCL_EXPORT pi_result OCL(piEnqueueMemBufferMap)( +pi_result OCL(piEnqueueMemBufferMap)( pi_queue command_queue, pi_mem buffer, pi_bool blocking_map, cl_map_flags map_flags, // TODO: untie from OpenCL size_t offset, size_t size, pi_uint32 num_events_in_wait_list, @@ -650,9 +644,9 @@ __SYCL_EXPORT pi_result OCL(piEnqueueMemBufferMap)( /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -__SYCL_EXPORT pi_result OCL(piextUSMHostAlloc)( - void **result_ptr, pi_context context, pi_usm_mem_properties *properties, - size_t size, pi_uint32 alignment) { +pi_result OCL(piextUSMHostAlloc)(void **result_ptr, pi_context context, + pi_usm_mem_properties *properties, size_t size, + pi_uint32 alignment) { void *Ptr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -681,9 +675,10 @@ __SYCL_EXPORT pi_result OCL(piextUSMHostAlloc)( /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -__SYCL_EXPORT pi_result OCL(piextUSMDeviceAlloc)( - void **result_ptr, pi_context context, pi_device device, - pi_usm_mem_properties *properties, size_t size, pi_uint32 alignment) { +pi_result OCL(piextUSMDeviceAlloc)(void **result_ptr, pi_context context, + pi_device device, + pi_usm_mem_properties *properties, + size_t size, pi_uint32 alignment) { void *Ptr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -713,9 +708,10 @@ __SYCL_EXPORT pi_result OCL(piextUSMDeviceAlloc)( /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -__SYCL_EXPORT pi_result OCL(piextUSMSharedAlloc)( - void **result_ptr, pi_context context, pi_device device, - pi_usm_mem_properties *properties, size_t size, pi_uint32 alignment) { +pi_result OCL(piextUSMSharedAlloc)(void **result_ptr, pi_context context, + pi_device device, + pi_usm_mem_properties *properties, + size_t size, pi_uint32 alignment) { void *Ptr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -741,7 +737,7 @@ __SYCL_EXPORT pi_result OCL(piextUSMSharedAlloc)( /// /// \param context is the pi_context of the allocation /// \param ptr is the memory to be freed -__SYCL_EXPORT pi_result OCL(piextUSMFree)(pi_context context, void *ptr) { +pi_result OCL(piextUSMFree)(pi_context context, void *ptr) { clMemFreeINTEL_fn FuncPtr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -762,10 +758,9 @@ __SYCL_EXPORT pi_result OCL(piextUSMFree)(pi_context context, void *ptr) { /// \param arg_index is the index of the kernel argument /// \param arg_size is the size in bytes of the argument (ignored in CL) /// \param arg_value is the pointer argument -__SYCL_EXPORT pi_result OCL(piextKernelSetArgPointer)(pi_kernel kernel, - pi_uint32 arg_index, - size_t arg_size, - const void *arg_value) { +pi_result OCL(piextKernelSetArgPointer)(pi_kernel kernel, pi_uint32 arg_index, + size_t arg_size, + const void *arg_value) { // Size is unused in CL as pointer args are passed by value. @@ -804,10 +799,11 @@ __SYCL_EXPORT pi_result OCL(piextKernelSetArgPointer)(pi_kernel kernel, /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -__SYCL_EXPORT pi_result -OCL(piextUSMEnqueueMemset)(pi_queue queue, void *ptr, pi_int32 value, - size_t count, pi_uint32 num_events_in_waitlist, - const pi_event *events_waitlist, pi_event *event) { +pi_result OCL(piextUSMEnqueueMemset)(pi_queue queue, void *ptr, pi_int32 value, + size_t count, + pi_uint32 num_events_in_waitlist, + const pi_event *events_waitlist, + pi_event *event) { // Have to look up the context from the kernel cl_context CLContext; @@ -843,10 +839,12 @@ OCL(piextUSMEnqueueMemset)(pi_queue queue, void *ptr, pi_int32 value, /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -__SYCL_EXPORT pi_result OCL(piextUSMEnqueueMemcpy)( - pi_queue queue, pi_bool blocking, void *dst_ptr, const void *src_ptr, - size_t size, pi_uint32 num_events_in_waitlist, - const pi_event *events_waitlist, pi_event *event) { +pi_result OCL(piextUSMEnqueueMemcpy)(pi_queue queue, pi_bool blocking, + void *dst_ptr, const void *src_ptr, + size_t size, + pi_uint32 num_events_in_waitlist, + const pi_event *events_waitlist, + pi_event *event) { // Have to look up the context from the kernel cl_context CLContext; @@ -881,10 +879,12 @@ __SYCL_EXPORT pi_result OCL(piextUSMEnqueueMemcpy)( /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -__SYCL_EXPORT pi_result OCL(piextUSMEnqueuePrefetch)( - pi_queue queue, const void *ptr, size_t size, pi_usm_migration_flags flags, - pi_uint32 num_events_in_waitlist, const pi_event *events_waitlist, - pi_event *event) { +pi_result OCL(piextUSMEnqueuePrefetch)(pi_queue queue, const void *ptr, + size_t size, + pi_usm_migration_flags flags, + pi_uint32 num_events_in_waitlist, + const pi_event *events_waitlist, + pi_event *event) { return cast(clEnqueueMarkerWithWaitList( cast(queue), num_events_in_waitlist, @@ -924,10 +924,9 @@ __SYCL_EXPORT pi_result OCL(piextUSMEnqueuePrefetch)( /// \param advice is device specific advice /// \param event is the event that represents this operation // USM memadvise API to govern behavior of automatic migration mechanisms -__SYCL_EXPORT pi_result OCL(piextUSMEnqueueMemAdvise)(pi_queue queue, - const void *ptr, - size_t length, int advice, - pi_event *event) { +pi_result OCL(piextUSMEnqueueMemAdvise)(pi_queue queue, const void *ptr, + size_t length, int advice, + pi_event *event) { return cast( clEnqueueMarkerWithWaitList(cast(queue), 0, nullptr, @@ -977,9 +976,11 @@ __SYCL_EXPORT pi_result OCL(piextUSMEnqueueMemAdvise)(pi_queue queue, /// \param param_value_size is the size of the result in bytes /// \param param_value is the result /// \param param_value_ret is how many bytes were written -__SYCL_EXPORT pi_result OCL(piextUSMGetMemAllocInfo)( - pi_context context, const void *ptr, pi_mem_info param_name, - size_t param_value_size, void *param_value, size_t *param_value_size_ret) { +pi_result OCL(piextUSMGetMemAllocInfo)(pi_context context, const void *ptr, + pi_mem_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret) { clGetMemAllocInfoINTEL_fn FuncPtr = nullptr; pi_result RetVal = @@ -1006,10 +1007,10 @@ __SYCL_EXPORT pi_result OCL(piextUSMGetMemAllocInfo)( /// If param_name is PI_USM_INDIRECT_ACCESS, the value will be a ptr to /// the pi_bool value PI_TRUE /// If param_name is PI_USM_PTRS, the value will be an array of ptrs -__SYCL_EXPORT pi_result OCL(piKernelSetExecInfo)(pi_kernel kernel, - pi_kernel_exec_info param_name, - size_t param_value_size, - const void *param_value) { +pi_result OCL(piKernelSetExecInfo)(pi_kernel kernel, + pi_kernel_exec_info param_name, + size_t param_value_size, + const void *param_value) { if (param_name == PI_USM_INDIRECT_ACCESS && *(static_cast(param_value)) == PI_TRUE) { return USMSetIndirectAccess(kernel); @@ -1023,7 +1024,7 @@ typedef CL_API_ENTRY cl_int(CL_API_CALL *clSetProgramSpecializationConstant_fn)( cl_program program, cl_uint spec_id, size_t spec_size, const void *spec_value); -__SYCL_EXPORT pi_result OCL(piextProgramSetSpecializationConstantImpl)( +pi_result OCL(piextProgramSetSpecializationConstantImpl)( pi_program prog, unsigned int spec_id, size_t spec_size, const void *spec_value) { cl_program ClProg = cast(prog); @@ -1051,14 +1052,14 @@ __SYCL_EXPORT pi_result OCL(piextProgramSetSpecializationConstantImpl)( /// \param nativeHandle is a pointer to be set to the native handle /// /// PI_SUCCESS -__SYCL_EXPORT pi_result -OCL(piextGetNativeHandle)(void *piObj, pi_native_handle *nativeHandle) { +pi_result OCL(piextGetNativeHandle)(void *piObj, + pi_native_handle *nativeHandle) { assert(nativeHandle != nullptr); *nativeHandle = reinterpret_cast(piObj); return PI_SUCCESS; } -__SYCL_EXPORT pi_result piPluginInit(pi_plugin *PluginInit) { +pi_result piPluginInit(pi_plugin *PluginInit) { int CompareVersions = strcmp(PluginInit->PiVersion, SupportedVersion); if (CompareVersions < 0) { // PI interface supports lower version of PI. From c470b6d87ec84ce6619cdfb862cab7538db02e32 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Thu, 7 May 2020 16:41:11 -0700 Subject: [PATCH 28/32] match signatures of pi_opencl.cpp with pi.h Also, added regression test for checking pi* export symbols Signed-off-by: Byoungro So --- sycl/plugins/opencl/pi_opencl.cpp | 345 +++++++++--------- .../regression/pi_opencl_symbol_check.cpp | 6 + .../regression/pi_opencl_symbol_check.txt | 42 +++ 3 files changed, 225 insertions(+), 168 deletions(-) create mode 100644 sycl/test/regression/pi_opencl_symbol_check.cpp create mode 100644 sycl/test/regression/pi_opencl_symbol_check.txt diff --git a/sycl/plugins/opencl/pi_opencl.cpp b/sycl/plugins/opencl/pi_opencl.cpp index 092ad00b7867c..bee9ad4b5ba90 100644 --- a/sycl/plugins/opencl/pi_opencl.cpp +++ b/sycl/plugins/opencl/pi_opencl.cpp @@ -160,12 +160,9 @@ static pi_result USMSetIndirectAccess(pi_kernel kernel) { extern "C" { -// Convenience macro makes source code search easier -#define OCL(pi_api) pi_api - // Example of a PI interface that does not map exactly to an OpenCL one. -pi_result OCL(piPlatformsGet)(pi_uint32 num_entries, pi_platform *platforms, - pi_uint32 *num_platforms) { +pi_result piPlatformsGet(pi_uint32 num_entries, pi_platform *platforms, + pi_uint32 *num_platforms) { cl_int result = clGetPlatformIDs(cast(num_entries), cast(platforms), cast(num_platforms)); @@ -180,9 +177,9 @@ pi_result OCL(piPlatformsGet)(pi_uint32 num_entries, pi_platform *platforms, } // Example of a PI interface that does not map exactly to an OpenCL one. -pi_result OCL(piDevicesGet)(pi_platform platform, pi_device_type device_type, - pi_uint32 num_entries, pi_device *devices, - pi_uint32 *num_devices) { +pi_result piDevicesGet(pi_platform platform, pi_device_type device_type, + pi_uint32 num_entries, pi_device *devices, + pi_uint32 *num_devices) { cl_int result = clGetDeviceIDs( cast(platform), cast(device_type), cast(num_entries), cast(devices), @@ -197,10 +194,9 @@ pi_result OCL(piDevicesGet)(pi_platform platform, pi_device_type device_type, return cast(result); } -pi_result OCL(piextDeviceSelectBinary)(pi_device device, - pi_device_binary *images, - pi_uint32 num_images, - pi_uint32 *selected_image_ind) { +pi_result piextDeviceSelectBinary(pi_device device, pi_device_binary *images, + pi_uint32 num_images, + pi_uint32 *selected_image_ind) { // TODO: this is a bare-bones implementation for choosing a device image // that would be compatible with the targeted device. An AOT-compiled @@ -269,15 +265,15 @@ pi_result OCL(piextDeviceSelectBinary)(pi_device device, return PI_INVALID_BINARY; } -pi_result OCL(piextDeviceCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_device *piDevice) { +pi_result piextDeviceCreateWithNativeHandle(pi_native_handle nativeHandle, + pi_device *piDevice) { assert(piDevice != nullptr); *piDevice = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piQueueCreate)(pi_context context, pi_device device, - pi_queue_properties properties, pi_queue *queue) { +pi_result piQueueCreate(pi_context context, pi_device device, + pi_queue_properties properties, pi_queue *queue) { assert(queue && "piQueueCreate failed, queue argument is null"); cl_platform_id curPlatform; @@ -316,15 +312,15 @@ pi_result OCL(piQueueCreate)(pi_context context, pi_device device, return cast(ret_err); } -pi_result OCL(piextQueueCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_queue *piQueue) { +pi_result piextQueueCreateWithNativeHandle(pi_native_handle nativeHandle, + pi_queue *piQueue) { assert(piQueue != nullptr); *piQueue = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piProgramCreate)(pi_context context, const void *il, - size_t length, pi_program *res_program) { +pi_result piProgramCreate(pi_context context, const void *il, size_t length, + pi_program *res_program) { size_t deviceCount; @@ -401,16 +397,16 @@ pi_result OCL(piProgramCreate)(pi_context context, const void *il, return err; } -pi_result OCL(piextProgramCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_program *piProgram) { +pi_result piextProgramCreateWithNativeHandle(pi_native_handle nativeHandle, + pi_program *piProgram) { assert(piProgram != nullptr); *piProgram = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piSamplerCreate)(pi_context context, - const pi_sampler_properties *sampler_properties, - pi_sampler *result_sampler) { +pi_result piSamplerCreate(pi_context context, + const pi_sampler_properties *sampler_properties, + pi_sampler *result_sampler) { // Initialize properties according to OpenCL 2.1 spec. pi_result error_code; pi_bool normalizedCoords = PI_TRUE; @@ -439,17 +435,16 @@ pi_result OCL(piSamplerCreate)(pi_context context, return error_code; } -pi_result OCL(piextKernelSetArgMemObj)(pi_kernel kernel, pi_uint32 arg_index, - const pi_mem *arg_value) { +pi_result piextKernelSetArgMemObj(pi_kernel kernel, pi_uint32 arg_index, + const pi_mem *arg_value) { return cast( clSetKernelArg(cast(kernel), cast(arg_index), sizeof(arg_value), cast(arg_value))); } -pi_result OCL(piextGetDeviceFunctionPointer)(pi_device device, - pi_program program, - const char *func_name, - pi_uint64 *function_pointer_ret) { +pi_result piextGetDeviceFunctionPointer(pi_device device, pi_program program, + const char *func_name, + pi_uint64 *function_pointer_ret) { pi_platform platform; cl_int ret_err = clGetDeviceInfo(cast(device), PI_DEVICE_INFO_PLATFORM, @@ -484,12 +479,12 @@ pi_result OCL(piextGetDeviceFunctionPointer)(pi_device device, function_pointer_ret)); } -pi_result OCL(piContextCreate)(const pi_context_properties *properties, - pi_uint32 num_devices, const pi_device *devices, - void (*pfn_notify)(const char *errinfo, - const void *private_info, - size_t cb, void *user_data1), - void *user_data, pi_context *retcontext) { +pi_result piContextCreate(const pi_context_properties *properties, + pi_uint32 num_devices, const pi_device *devices, + void (*pfn_notify)(const char *errinfo, + const void *private_info, + size_t cb, void *user_data1), + void *user_data, pi_context *retcontext) { pi_result ret = PI_INVALID_OPERATION; *retcontext = cast( clCreateContext(properties, cast(num_devices), @@ -499,15 +494,15 @@ pi_result OCL(piContextCreate)(const pi_context_properties *properties, return ret; } -pi_result OCL(piextContextCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_context *piContext) { +pi_result piextContextCreateWithNativeHandle(pi_native_handle nativeHandle, + pi_context *piContext) { assert(piContext != nullptr); *piContext = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piMemBufferCreate)(pi_context context, pi_mem_flags flags, - size_t size, void *host_ptr, pi_mem *ret_mem) { +pi_result piMemBufferCreate(pi_context context, pi_mem_flags flags, size_t size, + void *host_ptr, pi_mem *ret_mem) { pi_result ret_err = PI_INVALID_OPERATION; *ret_mem = cast(clCreateBuffer(cast(context), cast(flags), size, @@ -516,10 +511,10 @@ pi_result OCL(piMemBufferCreate)(pi_context context, pi_mem_flags flags, return ret_err; } -pi_result OCL(piMemImageCreate)(pi_context context, pi_mem_flags flags, - const pi_image_format *image_format, - const pi_image_desc *image_desc, void *host_ptr, - pi_mem *ret_mem) { +pi_result piMemImageCreate(pi_context context, pi_mem_flags flags, + const pi_image_format *image_format, + const pi_image_desc *image_desc, void *host_ptr, + pi_mem *ret_mem) { pi_result ret_err = PI_INVALID_OPERATION; *ret_mem = cast( clCreateImage(cast(context), cast(flags), @@ -530,9 +525,9 @@ pi_result OCL(piMemImageCreate)(pi_context context, pi_mem_flags flags, return ret_err; } -pi_result OCL(piMemBufferPartition)(pi_mem buffer, pi_mem_flags flags, - pi_buffer_create_type buffer_create_type, - void *buffer_create_info, pi_mem *ret_mem) { +pi_result piMemBufferPartition(pi_mem buffer, pi_mem_flags flags, + pi_buffer_create_type buffer_create_type, + void *buffer_create_info, pi_mem *ret_mem) { pi_result ret_err = PI_INVALID_OPERATION; *ret_mem = cast( @@ -542,17 +537,17 @@ pi_result OCL(piMemBufferPartition)(pi_mem buffer, pi_mem_flags flags, return ret_err; } -pi_result OCL(piextMemCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_mem *piMem) { +pi_result piextMemCreateWithNativeHandle(pi_native_handle nativeHandle, + pi_mem *piMem) { assert(piMem != nullptr); *piMem = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piclProgramCreateWithSource)(pi_context context, pi_uint32 count, - const char **strings, - const size_t *lengths, - pi_program *ret_program) { +pi_result piclProgramCreateWithSource(pi_context context, pi_uint32 count, + const char **strings, + const size_t *lengths, + pi_program *ret_program) { pi_result ret_err = PI_INVALID_OPERATION; *ret_program = cast( @@ -561,10 +556,12 @@ pi_result OCL(piclProgramCreateWithSource)(pi_context context, pi_uint32 count, return ret_err; } -pi_result OCL(piclProgramCreateWithBinary)( - pi_context context, pi_uint32 num_devices, const pi_device *device_list, - const size_t *lengths, const unsigned char **binaries, - pi_int32 *binary_status, pi_program *ret_program) { +pi_result piclProgramCreateWithBinary(pi_context context, pi_uint32 num_devices, + const pi_device *device_list, + const size_t *lengths, + const unsigned char **binaries, + pi_int32 *binary_status, + pi_program *ret_program) { pi_result ret_err = PI_INVALID_OPERATION; *ret_program = cast(clCreateProgramWithBinary( @@ -574,13 +571,12 @@ pi_result OCL(piclProgramCreateWithBinary)( return ret_err; } -pi_result OCL(piProgramLink)(pi_context context, pi_uint32 num_devices, - const pi_device *device_list, const char *options, - pi_uint32 num_input_programs, - const pi_program *input_programs, - void (*pfn_notify)(pi_program program, - void *user_data), - void *user_data, pi_program *ret_program) { +pi_result piProgramLink(pi_context context, pi_uint32 num_devices, + const pi_device *device_list, const char *options, + pi_uint32 num_input_programs, + const pi_program *input_programs, + void (*pfn_notify)(pi_program program, void *user_data), + void *user_data, pi_program *ret_program) { pi_result ret_err = PI_INVALID_OPERATION; *ret_program = cast( @@ -593,8 +589,8 @@ pi_result OCL(piProgramLink)(pi_context context, pi_uint32 num_devices, return ret_err; } -pi_result OCL(piKernelCreate)(pi_program program, const char *kernel_name, - pi_kernel *ret_kernel) { +pi_result piKernelCreate(pi_program program, const char *kernel_name, + pi_kernel *ret_kernel) { pi_result ret_err = PI_INVALID_OPERATION; *ret_kernel = cast(clCreateKernel( @@ -602,7 +598,7 @@ pi_result OCL(piKernelCreate)(pi_program program, const char *kernel_name, return ret_err; } -pi_result OCL(piEventCreate)(pi_context context, pi_event *ret_event) { +pi_result piEventCreate(pi_context context, pi_event *ret_event) { pi_result ret_err = PI_INVALID_OPERATION; *ret_event = cast( @@ -610,14 +606,14 @@ pi_result OCL(piEventCreate)(pi_context context, pi_event *ret_event) { return ret_err; } -pi_result OCL(piextEventCreateWithNativeHandle)(pi_native_handle nativeHandle, - pi_event *piEvent) { +pi_result piextEventCreateWithNativeHandle(pi_native_handle nativeHandle, + pi_event *piEvent) { assert(piEvent != nullptr); *piEvent = reinterpret_cast(nativeHandle); return PI_SUCCESS; } -pi_result OCL(piEnqueueMemBufferMap)( +pi_result piEnqueueMemBufferMap( pi_queue command_queue, pi_mem buffer, pi_bool blocking_map, cl_map_flags map_flags, // TODO: untie from OpenCL size_t offset, size_t size, pi_uint32 num_events_in_wait_list, @@ -644,9 +640,9 @@ pi_result OCL(piEnqueueMemBufferMap)( /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -pi_result OCL(piextUSMHostAlloc)(void **result_ptr, pi_context context, - pi_usm_mem_properties *properties, size_t size, - pi_uint32 alignment) { +pi_result piextUSMHostAlloc(void **result_ptr, pi_context context, + pi_usm_mem_properties *properties, size_t size, + pi_uint32 alignment) { void *Ptr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -675,10 +671,10 @@ pi_result OCL(piextUSMHostAlloc)(void **result_ptr, pi_context context, /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -pi_result OCL(piextUSMDeviceAlloc)(void **result_ptr, pi_context context, - pi_device device, - pi_usm_mem_properties *properties, - size_t size, pi_uint32 alignment) { +pi_result piextUSMDeviceAlloc(void **result_ptr, pi_context context, + pi_device device, + pi_usm_mem_properties *properties, size_t size, + pi_uint32 alignment) { void *Ptr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -708,10 +704,10 @@ pi_result OCL(piextUSMDeviceAlloc)(void **result_ptr, pi_context context, /// \param pi_usm_mem_properties are optional allocation properties /// \param size_t is the size of the allocation /// \param alignment is the desired alignment of the allocation -pi_result OCL(piextUSMSharedAlloc)(void **result_ptr, pi_context context, - pi_device device, - pi_usm_mem_properties *properties, - size_t size, pi_uint32 alignment) { +pi_result piextUSMSharedAlloc(void **result_ptr, pi_context context, + pi_device device, + pi_usm_mem_properties *properties, size_t size, + pi_uint32 alignment) { void *Ptr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -737,7 +733,7 @@ pi_result OCL(piextUSMSharedAlloc)(void **result_ptr, pi_context context, /// /// \param context is the pi_context of the allocation /// \param ptr is the memory to be freed -pi_result OCL(piextUSMFree)(pi_context context, void *ptr) { +pi_result piextUSMFree(pi_context context, void *ptr) { clMemFreeINTEL_fn FuncPtr = nullptr; pi_result RetVal = PI_INVALID_OPERATION; @@ -758,9 +754,8 @@ pi_result OCL(piextUSMFree)(pi_context context, void *ptr) { /// \param arg_index is the index of the kernel argument /// \param arg_size is the size in bytes of the argument (ignored in CL) /// \param arg_value is the pointer argument -pi_result OCL(piextKernelSetArgPointer)(pi_kernel kernel, pi_uint32 arg_index, - size_t arg_size, - const void *arg_value) { +pi_result piextKernelSetArgPointer(pi_kernel kernel, pi_uint32 arg_index, + size_t arg_size, const void *arg_value) { // Size is unused in CL as pointer args are passed by value. @@ -799,11 +794,10 @@ pi_result OCL(piextKernelSetArgPointer)(pi_kernel kernel, pi_uint32 arg_index, /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -pi_result OCL(piextUSMEnqueueMemset)(pi_queue queue, void *ptr, pi_int32 value, - size_t count, - pi_uint32 num_events_in_waitlist, - const pi_event *events_waitlist, - pi_event *event) { +pi_result piextUSMEnqueueMemset(pi_queue queue, void *ptr, pi_int32 value, + size_t count, pi_uint32 num_events_in_waitlist, + const pi_event *events_waitlist, + pi_event *event) { // Have to look up the context from the kernel cl_context CLContext; @@ -839,12 +833,11 @@ pi_result OCL(piextUSMEnqueueMemset)(pi_queue queue, void *ptr, pi_int32 value, /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -pi_result OCL(piextUSMEnqueueMemcpy)(pi_queue queue, pi_bool blocking, - void *dst_ptr, const void *src_ptr, - size_t size, - pi_uint32 num_events_in_waitlist, - const pi_event *events_waitlist, - pi_event *event) { +pi_result piextUSMEnqueueMemcpy(pi_queue queue, pi_bool blocking, void *dst_ptr, + const void *src_ptr, size_t size, + pi_uint32 num_events_in_waitlist, + const pi_event *events_waitlist, + pi_event *event) { // Have to look up the context from the kernel cl_context CLContext; @@ -879,12 +872,11 @@ pi_result OCL(piextUSMEnqueueMemcpy)(pi_queue queue, pi_bool blocking, /// \param num_events_in_waitlist is the number of events to wait on /// \param events_waitlist is an array of events to wait on /// \param event is the event that represents this operation -pi_result OCL(piextUSMEnqueuePrefetch)(pi_queue queue, const void *ptr, - size_t size, - pi_usm_migration_flags flags, - pi_uint32 num_events_in_waitlist, - const pi_event *events_waitlist, - pi_event *event) { +pi_result piextUSMEnqueuePrefetch(pi_queue queue, const void *ptr, size_t size, + pi_usm_migration_flags flags, + pi_uint32 num_events_in_waitlist, + const pi_event *events_waitlist, + pi_event *event) { return cast(clEnqueueMarkerWithWaitList( cast(queue), num_events_in_waitlist, @@ -924,9 +916,8 @@ pi_result OCL(piextUSMEnqueuePrefetch)(pi_queue queue, const void *ptr, /// \param advice is device specific advice /// \param event is the event that represents this operation // USM memadvise API to govern behavior of automatic migration mechanisms -pi_result OCL(piextUSMEnqueueMemAdvise)(pi_queue queue, const void *ptr, - size_t length, int advice, - pi_event *event) { +pi_result piextUSMEnqueueMemAdvise(pi_queue queue, const void *ptr, + size_t length, int advice, pi_event *event) { return cast( clEnqueueMarkerWithWaitList(cast(queue), 0, nullptr, @@ -976,11 +967,10 @@ pi_result OCL(piextUSMEnqueueMemAdvise)(pi_queue queue, const void *ptr, /// \param param_value_size is the size of the result in bytes /// \param param_value is the result /// \param param_value_ret is how many bytes were written -pi_result OCL(piextUSMGetMemAllocInfo)(pi_context context, const void *ptr, - pi_mem_info param_name, - size_t param_value_size, - void *param_value, - size_t *param_value_size_ret) { +pi_result piextUSMGetMemAllocInfo(pi_context context, const void *ptr, + pi_mem_info param_name, + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) { clGetMemAllocInfoINTEL_fn FuncPtr = nullptr; pi_result RetVal = @@ -1007,10 +997,9 @@ pi_result OCL(piextUSMGetMemAllocInfo)(pi_context context, const void *ptr, /// If param_name is PI_USM_INDIRECT_ACCESS, the value will be a ptr to /// the pi_bool value PI_TRUE /// If param_name is PI_USM_PTRS, the value will be an array of ptrs -pi_result OCL(piKernelSetExecInfo)(pi_kernel kernel, - pi_kernel_exec_info param_name, - size_t param_value_size, - const void *param_value) { +pi_result piKernelSetExecInfo(pi_kernel kernel, pi_kernel_exec_info param_name, + size_t param_value_size, + const void *param_value) { if (param_name == PI_USM_INDIRECT_ACCESS && *(static_cast(param_value)) == PI_TRUE) { return USMSetIndirectAccess(kernel); @@ -1024,9 +1013,10 @@ typedef CL_API_ENTRY cl_int(CL_API_CALL *clSetProgramSpecializationConstant_fn)( cl_program program, cl_uint spec_id, size_t spec_size, const void *spec_value); -pi_result OCL(piextProgramSetSpecializationConstantImpl)( - pi_program prog, unsigned int spec_id, size_t spec_size, - const void *spec_value) { +pi_result piextProgramSetSpecializationConstant(pi_program prog, + pi_uint32 spec_id, + size_t spec_size, + const void *spec_value) { cl_program ClProg = cast(prog); cl_context Ctx = nullptr; size_t RetSize = 0; @@ -1052,13 +1042,37 @@ pi_result OCL(piextProgramSetSpecializationConstantImpl)( /// \param nativeHandle is a pointer to be set to the native handle /// /// PI_SUCCESS -pi_result OCL(piextGetNativeHandle)(void *piObj, - pi_native_handle *nativeHandle) { +static pi_result piextGetNativeHandle(void *piObj, + pi_native_handle *nativeHandle) { assert(nativeHandle != nullptr); *nativeHandle = reinterpret_cast(piObj); return PI_SUCCESS; } +pi_result piextDeviceGetNativeHandle(pi_device device, + pi_native_handle *nativeHandle) { + return piextGetNativeHandle(device, nativeHandle); +} + +pi_result piextContextGetNativeHandle(pi_context context, + pi_native_handle *nativeHandle) { + return piextGetNativeHandle(context, nativeHandle); +} + +pi_result piextQueueGetNativeHandle(pi_queue queue, + pi_native_handle *nativeHandle) { + return piextGetNativeHandle(queue, nativeHandle); +} + +pi_result piextMemGetNativeHandle(pi_mem mem, pi_native_handle *nativeHandle) { + return piextGetNativeHandle(mem, nativeHandle); +} + +pi_result piextProgramGetNativeHandle(pi_program program, + pi_native_handle *nativeHandle) { + return piextGetNativeHandle(program, nativeHandle); +} + pi_result piPluginInit(pi_plugin *PluginInit) { int CompareVersions = strcmp(PluginInit->PiVersion, SupportedVersion); if (CompareVersions < 0) { @@ -1074,74 +1088,70 @@ pi_result piPluginInit(pi_plugin *PluginInit) { (PluginInit->PiFunctionTable).pi_api = (decltype(&::pi_api))(&ocl_api); // Platform - _PI_CL(piPlatformsGet, OCL(piPlatformsGet)) + _PI_CL(piPlatformsGet, piPlatformsGet) _PI_CL(piPlatformGetInfo, clGetPlatformInfo) // Device - _PI_CL(piDevicesGet, OCL(piDevicesGet)) + _PI_CL(piDevicesGet, piDevicesGet) _PI_CL(piDeviceGetInfo, clGetDeviceInfo) _PI_CL(piDevicePartition, clCreateSubDevices) _PI_CL(piDeviceRetain, clRetainDevice) _PI_CL(piDeviceRelease, clReleaseDevice) - _PI_CL(piextDeviceSelectBinary, OCL(piextDeviceSelectBinary)) - _PI_CL(piextGetDeviceFunctionPointer, OCL(piextGetDeviceFunctionPointer)) - _PI_CL(piextDeviceGetNativeHandle, OCL(piextGetNativeHandle)) - _PI_CL(piextDeviceCreateWithNativeHandle, - OCL(piextDeviceCreateWithNativeHandle)) + _PI_CL(piextDeviceSelectBinary, piextDeviceSelectBinary) + _PI_CL(piextGetDeviceFunctionPointer, piextGetDeviceFunctionPointer) + _PI_CL(piextDeviceGetNativeHandle, piextDeviceGetNativeHandle) + _PI_CL(piextDeviceCreateWithNativeHandle, piextDeviceCreateWithNativeHandle) // Context - _PI_CL(piContextCreate, OCL(piContextCreate)) + _PI_CL(piContextCreate, piContextCreate) _PI_CL(piContextGetInfo, clGetContextInfo) _PI_CL(piContextRetain, clRetainContext) _PI_CL(piContextRelease, clReleaseContext) - _PI_CL(piextContextGetNativeHandle, OCL(piextGetNativeHandle)) - _PI_CL(piextContextCreateWithNativeHandle, - OCL(piextContextCreateWithNativeHandle)) + _PI_CL(piextContextGetNativeHandle, piextContextGetNativeHandle) + _PI_CL(piextContextCreateWithNativeHandle, piextContextCreateWithNativeHandle) // Queue - _PI_CL(piQueueCreate, OCL(piQueueCreate)) + _PI_CL(piQueueCreate, piQueueCreate) _PI_CL(piQueueGetInfo, clGetCommandQueueInfo) _PI_CL(piQueueFinish, clFinish) _PI_CL(piQueueRetain, clRetainCommandQueue) _PI_CL(piQueueRelease, clReleaseCommandQueue) - _PI_CL(piextQueueGetNativeHandle, OCL(piextGetNativeHandle)) - _PI_CL(piextQueueCreateWithNativeHandle, - OCL(piextQueueCreateWithNativeHandle)) + _PI_CL(piextQueueGetNativeHandle, piextQueueGetNativeHandle) + _PI_CL(piextQueueCreateWithNativeHandle, piextQueueCreateWithNativeHandle) // Memory - _PI_CL(piMemBufferCreate, OCL(piMemBufferCreate)) - _PI_CL(piMemImageCreate, OCL(piMemImageCreate)) + _PI_CL(piMemBufferCreate, piMemBufferCreate) + _PI_CL(piMemImageCreate, piMemImageCreate) _PI_CL(piMemGetInfo, clGetMemObjectInfo) _PI_CL(piMemImageGetInfo, clGetImageInfo) _PI_CL(piMemRetain, clRetainMemObject) _PI_CL(piMemRelease, clReleaseMemObject) - _PI_CL(piMemBufferPartition, OCL(piMemBufferPartition)) - _PI_CL(piextMemGetNativeHandle, OCL(piextGetNativeHandle)) - _PI_CL(piextMemCreateWithNativeHandle, OCL(piextMemCreateWithNativeHandle)) + _PI_CL(piMemBufferPartition, piMemBufferPartition) + _PI_CL(piextMemGetNativeHandle, piextMemGetNativeHandle) + _PI_CL(piextMemCreateWithNativeHandle, piextMemCreateWithNativeHandle) // Program - _PI_CL(piProgramCreate, OCL(piProgramCreate)) - _PI_CL(piclProgramCreateWithSource, OCL(piclProgramCreateWithSource)) - _PI_CL(piclProgramCreateWithBinary, OCL(piclProgramCreateWithBinary)) + _PI_CL(piProgramCreate, piProgramCreate) + _PI_CL(piclProgramCreateWithSource, piclProgramCreateWithSource) + _PI_CL(piclProgramCreateWithBinary, piclProgramCreateWithBinary) _PI_CL(piProgramGetInfo, clGetProgramInfo) _PI_CL(piProgramCompile, clCompileProgram) _PI_CL(piProgramBuild, clBuildProgram) - _PI_CL(piProgramLink, OCL(piProgramLink)) + _PI_CL(piProgramLink, piProgramLink) _PI_CL(piProgramGetBuildInfo, clGetProgramBuildInfo) _PI_CL(piProgramRetain, clRetainProgram) _PI_CL(piProgramRelease, clReleaseProgram) _PI_CL(piextProgramSetSpecializationConstant, - OCL(piextProgramSetSpecializationConstantImpl)) - _PI_CL(piextProgramGetNativeHandle, OCL(piextGetNativeHandle)) - _PI_CL(piextProgramCreateWithNativeHandle, - OCL(piextProgramCreateWithNativeHandle)) + piextProgramSetSpecializationConstant) + _PI_CL(piextProgramGetNativeHandle, piextProgramGetNativeHandle) + _PI_CL(piextProgramCreateWithNativeHandle, piextProgramCreateWithNativeHandle) // Kernel - _PI_CL(piKernelCreate, OCL(piKernelCreate)) + _PI_CL(piKernelCreate, piKernelCreate) _PI_CL(piKernelSetArg, clSetKernelArg) _PI_CL(piKernelGetInfo, clGetKernelInfo) _PI_CL(piKernelGetGroupInfo, clGetKernelWorkGroupInfo) _PI_CL(piKernelGetSubGroupInfo, clGetKernelSubGroupInfo) _PI_CL(piKernelRetain, clRetainKernel) _PI_CL(piKernelRelease, clReleaseKernel) - _PI_CL(piKernelSetExecInfo, OCL(piKernelSetExecInfo)) - _PI_CL(piextKernelSetArgPointer, OCL(piextKernelSetArgPointer)) + _PI_CL(piKernelSetExecInfo, piKernelSetExecInfo) + _PI_CL(piextKernelSetArgPointer, piextKernelSetArgPointer) // Event - _PI_CL(piEventCreate, OCL(piEventCreate)) + _PI_CL(piEventCreate, piEventCreate) _PI_CL(piEventGetInfo, clGetEventInfo) _PI_CL(piEventGetProfilingInfo, clGetEventProfilingInfo) _PI_CL(piEventsWait, clWaitForEvents) @@ -1149,11 +1159,10 @@ pi_result piPluginInit(pi_plugin *PluginInit) { _PI_CL(piEventSetStatus, clSetUserEventStatus) _PI_CL(piEventRetain, clRetainEvent) _PI_CL(piEventRelease, clReleaseEvent) - _PI_CL(piextEventGetNativeHandle, OCL(piextGetNativeHandle)) - _PI_CL(piextEventCreateWithNativeHandle, - OCL(piextEventCreateWithNativeHandle)) + _PI_CL(piextEventGetNativeHandle, piextGetNativeHandle) + _PI_CL(piextEventCreateWithNativeHandle, piextEventCreateWithNativeHandle) // Sampler - _PI_CL(piSamplerCreate, OCL(piSamplerCreate)) + _PI_CL(piSamplerCreate, piSamplerCreate) _PI_CL(piSamplerGetInfo, clGetSamplerInfo) _PI_CL(piSamplerRetain, clRetainSampler) _PI_CL(piSamplerRelease, clReleaseSampler) @@ -1172,20 +1181,20 @@ pi_result piPluginInit(pi_plugin *PluginInit) { _PI_CL(piEnqueueMemImageWrite, clEnqueueWriteImage) _PI_CL(piEnqueueMemImageCopy, clEnqueueCopyImage) _PI_CL(piEnqueueMemImageFill, clEnqueueFillImage) - _PI_CL(piEnqueueMemBufferMap, OCL(piEnqueueMemBufferMap)) + _PI_CL(piEnqueueMemBufferMap, piEnqueueMemBufferMap) _PI_CL(piEnqueueMemUnmap, clEnqueueUnmapMemObject) // USM - _PI_CL(piextUSMHostAlloc, OCL(piextUSMHostAlloc)) - _PI_CL(piextUSMDeviceAlloc, OCL(piextUSMDeviceAlloc)) - _PI_CL(piextUSMSharedAlloc, OCL(piextUSMSharedAlloc)) - _PI_CL(piextUSMFree, OCL(piextUSMFree)) - _PI_CL(piextUSMEnqueueMemset, OCL(piextUSMEnqueueMemset)) - _PI_CL(piextUSMEnqueueMemcpy, OCL(piextUSMEnqueueMemcpy)) - _PI_CL(piextUSMEnqueuePrefetch, OCL(piextUSMEnqueuePrefetch)) - _PI_CL(piextUSMEnqueueMemAdvise, OCL(piextUSMEnqueueMemAdvise)) - _PI_CL(piextUSMGetMemAllocInfo, OCL(piextUSMGetMemAllocInfo)) - - _PI_CL(piextKernelSetArgMemObj, OCL(piextKernelSetArgMemObj)) + _PI_CL(piextUSMHostAlloc, piextUSMHostAlloc) + _PI_CL(piextUSMDeviceAlloc, piextUSMDeviceAlloc) + _PI_CL(piextUSMSharedAlloc, piextUSMSharedAlloc) + _PI_CL(piextUSMFree, piextUSMFree) + _PI_CL(piextUSMEnqueueMemset, piextUSMEnqueueMemset) + _PI_CL(piextUSMEnqueueMemcpy, piextUSMEnqueueMemcpy) + _PI_CL(piextUSMEnqueuePrefetch, piextUSMEnqueuePrefetch) + _PI_CL(piextUSMEnqueueMemAdvise, piextUSMEnqueueMemAdvise) + _PI_CL(piextUSMGetMemAllocInfo, piextUSMGetMemAllocInfo) + + _PI_CL(piextKernelSetArgMemObj, piextKernelSetArgMemObj) #undef _PI_CL diff --git a/sycl/test/regression/pi_opencl_symbol_check.cpp b/sycl/test/regression/pi_opencl_symbol_check.cpp new file mode 100644 index 0000000000000..b0a02acbf68d7 --- /dev/null +++ b/sycl/test/regression/pi_opencl_symbol_check.cpp @@ -0,0 +1,6 @@ +// RUN: env LLVM_BIN_PATH=%llvm_build_bin_dir python %sycl_tools_src_dir/abi_check.py --mode check_symbols --reference %S/pi_opencl_symbol_check.txt %sycl_libs_dir/libpi_opencl.so +// expected-no-diagnostics +// +//===----------------------------------------------------------------------===// +// This test checks if there is any change in export symbols in libpi_opencl.so +//===----------------------------------------------------------------------===// diff --git a/sycl/test/regression/pi_opencl_symbol_check.txt b/sycl/test/regression/pi_opencl_symbol_check.txt new file mode 100644 index 0000000000000..96479adc27616 --- /dev/null +++ b/sycl/test/regression/pi_opencl_symbol_check.txt @@ -0,0 +1,42 @@ +piContextCreate +piDevicesGet +piEnqueueMemBufferMap +piEventCreate +piKernelCreate +piKernelSetExecInfo +piMemBufferCreate +piMemBufferPartition +piMemImageCreate +piPlatformsGet +piPluginInit +piProgramCreate +piProgramLink +piQueueCreate +piSamplerCreate +piclProgramCreateWithBinary +piclProgramCreateWithSource +piextContextCreateWithNativeHandle +piextContextGetNativeHandle +piextDeviceCreateWithNativeHandle +piextDeviceSelectBinary +piextDeviceGetNativeHandle +piextEventCreateWithNativeHandle +piextGetDeviceFunctionPointer +piextProgramGetNativeHandle +piextKernelSetArgMemObj +piextKernelSetArgPointer +piextMemCreateWithNativeHandle +piextMemGetNativeHandle +piextProgramCreateWithNativeHandle +piextProgramSetSpecializationConstant +piextQueueCreateWithNativeHandle +piextQueueGetNativeHandle +piextUSMDeviceAlloc +piextUSMEnqueueMemAdvise +piextUSMEnqueueMemcpy +piextUSMEnqueueMemset +piextUSMEnqueuePrefetch +piextUSMFree +piextUSMGetMemAllocInfo +piextUSMHostAlloc +piextUSMSharedAlloc \ No newline at end of file From feb39c27e89ebbf4887a2034335eb924c9aee5cf Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Thu, 7 May 2020 22:58:20 -0700 Subject: [PATCH 29/32] fixed Windows LIT error Signed-off-by: Byoungro So --- sycl/test/regression/pi_opencl_symbol_check.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/sycl/test/regression/pi_opencl_symbol_check.cpp b/sycl/test/regression/pi_opencl_symbol_check.cpp index b0a02acbf68d7..17683b1753ffe 100644 --- a/sycl/test/regression/pi_opencl_symbol_check.cpp +++ b/sycl/test/regression/pi_opencl_symbol_check.cpp @@ -1,4 +1,5 @@ // RUN: env LLVM_BIN_PATH=%llvm_build_bin_dir python %sycl_tools_src_dir/abi_check.py --mode check_symbols --reference %S/pi_opencl_symbol_check.txt %sycl_libs_dir/libpi_opencl.so +// REQUIRES: linux // expected-no-diagnostics // //===----------------------------------------------------------------------===// From 55fa3958c352c40765809f3f1e5ca63d7d09683a Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Fri, 8 May 2020 19:35:39 -0700 Subject: [PATCH 30/32] fixed Windows errors Signed-off-by: Byoungro So --- sycl/plugins/opencl/CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/sycl/plugins/opencl/CMakeLists.txt b/sycl/plugins/opencl/CMakeLists.txt index 85096b7d99f28..6f0d30dc5d763 100644 --- a/sycl/plugins/opencl/CMakeLists.txt +++ b/sycl/plugins/opencl/CMakeLists.txt @@ -10,11 +10,7 @@ #TODO: Currently, the pi.hpp header is common between sycl and plugin library sources. #This can be changed by copying the pi.hpp file in the plugins project. -set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) - -# We chose MODULE type because libpi_opencl.so should never be linked dynamically to a target. -# MODULE will limit this library to be used to load symbols via dlopen only -add_library(pi_opencl MODULE +add_library(pi_opencl SHARED "${sycl_inc_dir}/CL/sycl/detail/pi.h" "pi_opencl.cpp" ) From aeff97fef282a1f8747bc61ad7864683ce62eeb2 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Sat, 9 May 2020 11:41:50 -0700 Subject: [PATCH 31/32] combined regression abi testing files into .dump file. moved it under test/abi/ Signed-off-by: Byoungro So --- .../pi_opencl_symbol_check.dump} | 3 +++ sycl/test/regression/pi_opencl_symbol_check.cpp | 7 ------- 2 files changed, 3 insertions(+), 7 deletions(-) rename sycl/test/{regression/pi_opencl_symbol_check.txt => abi/pi_opencl_symbol_check.dump} (84%) delete mode 100644 sycl/test/regression/pi_opencl_symbol_check.cpp diff --git a/sycl/test/regression/pi_opencl_symbol_check.txt b/sycl/test/abi/pi_opencl_symbol_check.dump similarity index 84% rename from sycl/test/regression/pi_opencl_symbol_check.txt rename to sycl/test/abi/pi_opencl_symbol_check.dump index 96479adc27616..5ad52bd49911e 100644 --- a/sycl/test/regression/pi_opencl_symbol_check.txt +++ b/sycl/test/abi/pi_opencl_symbol_check.dump @@ -1,3 +1,6 @@ +# RUN: env LLVM_BIN_PATH=%llvm_build_bin_dir python %sycl_tools_src_dir/abi_check.py --mode check_symbols --reference %s %sycl_libs_dir/libpi_opencl.so +# REQUIRES: linux + piContextCreate piDevicesGet piEnqueueMemBufferMap diff --git a/sycl/test/regression/pi_opencl_symbol_check.cpp b/sycl/test/regression/pi_opencl_symbol_check.cpp deleted file mode 100644 index 17683b1753ffe..0000000000000 --- a/sycl/test/regression/pi_opencl_symbol_check.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// RUN: env LLVM_BIN_PATH=%llvm_build_bin_dir python %sycl_tools_src_dir/abi_check.py --mode check_symbols --reference %S/pi_opencl_symbol_check.txt %sycl_libs_dir/libpi_opencl.so -// REQUIRES: linux -// expected-no-diagnostics -// -//===----------------------------------------------------------------------===// -// This test checks if there is any change in export symbols in libpi_opencl.so -//===----------------------------------------------------------------------===// From 4b1c91666a755bd44a83e351710676b6691f8075 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Sat, 9 May 2020 12:03:04 -0700 Subject: [PATCH 32/32] moved comments in the right place Signed-off-by: Byoungro So --- sycl/plugins/opencl/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sycl/plugins/opencl/CMakeLists.txt b/sycl/plugins/opencl/CMakeLists.txt index 6f0d30dc5d763..30674c1d5621b 100644 --- a/sycl/plugins/opencl/CMakeLists.txt +++ b/sycl/plugins/opencl/CMakeLists.txt @@ -27,6 +27,7 @@ set_target_properties(pi_opencl PROPERTIES LINKER_LANGUAGE CXX) #preprocessor definitions for compiling a target's sources. We do not need it for pi_opencl target_include_directories(pi_opencl PRIVATE "${sycl_inc_dir}") +#link pi_opencl with OpenCL headers and ICD Loader. target_link_libraries( pi_opencl PRIVATE OpenCL::Headers PRIVATE ${OpenCL_LIBRARIES} @@ -44,10 +45,9 @@ else() # All other symbols are regarded as local (hidden) set(linker_script "${CMAKE_CURRENT_SOURCE_DIR}/../ld-version-script.txt") - #link pi_opencl with OpenCL headers and ICD Loader. + # Filter symbols based on the scope defined in the script file, + # and export pi* function symbols in the library. target_link_libraries( pi_opencl - # Filter symbols based on the scope defined in the script file, - # and export pi* function symbols in the library. PRIVATE "-Wl,--version-script=${linker_script}" ) endif()