-
Notifications
You must be signed in to change notification settings - Fork 807
[SYCL] Host pipe runtime implementation #7468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 39 commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
ac2e0a3
[SYCL] Implement initial host_pipe registration
sherry-yuan 8e054e2
Add pi extension API for host pipes
sherry-yuan 0fc3879
[SYCL] Add new hostpipe API to PIMockPlugin
zibaiwan 44342a6
[SYCL] Add data_flow_pipe properties
sherry-yuan 4e816d8
Register new command group to execute host pipe read/write operation
sherry-yuan abbb0a3
[SYCL] fix layout handler
zibaiwan aa6cdff
[SYCL] Query pipe name from registration
sherry-yuan 0d95375
[SYCL] Cache host pipe to device image mapping
zibaiwan 26eec1a
[SYCL][UNITTEST] Unit testing host pipe functionality
sherry-yuan 6d98b5a
[SYCL] update unit test to use newer PiMock
zibaiwan 252b403
remove type trait
sherry-yuan 2821aae
Move host pipe additions into existing pipe class
rho180 8fd64af
Define m_Storage on host and make public
rho180 5bb9cd6
created templateless base class for pipes
zibaiwan e2c5b86
Preliminary implementation of host pipe size property
rho180 c43b3c1
fix blocking read and add API for nonblocking read&write
zibaiwan 714d25d
fixup
zibaiwan a1d422a
fixup
zibaiwan a303464
fixup
zibaiwan 104e234
fixup
zibaiwan 3d164e8
clang format fixup
zibaiwan 61fbe0c
fix unit tests
zibaiwan 5791403
run clang format
zibaiwan ab0fafa
fix pipe property test
zibaiwan d0fb7d7
Collect host pipe attribute functions and cleanup comments
rho180 9884770
code cleanup
zibaiwan d341a8b
update opencl header function pointer name
zibaiwan 6af1f96
Fix misnamed attribute in host pipe lit test
rho180 d393163
add __SYCL_EXPORT to the header as well
zibaiwan ac93ebf
update windows symbol dump
zibaiwan 30eace1
Updated default value for the pipe properties
zibaiwan cade651
fixup
zibaiwan ae0988b
Update OPENCL Header commit
zibaiwan a41263a
Comments fixup
zibaiwan 7878b26
Update error messages when the device side API is called on the host
zibaiwan ddcc067
fix error messages
zibaiwan 400a10a
update default value of bits per symbol to 8
zibaiwan 666af1c
various fixes and style changes
zibaiwan 1b6db48
Variable naming style change
zibaiwan 2c6f27d
Reuse unique id attribute function from device globals for host pipes
rho180 3a49068
Update PI version and run clang format
zibaiwan 21298fc
Merge branch 'sycl' into sycl-hostpipe-runtime
zibaiwan a339956
clang-format change
zibaiwan 80c57d5
seperate handler function into read and write functions
zibaiwan 3c2ed1c
make the new handler member private
zibaiwan 873b385
Merge branch 'sycl' into sycl-hostpipe-runtime
zibaiwan 66a6307
Fix Pipe unit test to be able access private handler function
zibaiwan a9c58f6
fix windows symbol dump
zibaiwan e4ff9a4
fix unit test to call pipe read/write directly
zibaiwan 15136a6
run clang format
zibaiwan 8478af2
Merge branch 'intel:sycl' into sycl-hostpipe-runtime
zibaiwan 6913660
Empty commit
zibaiwan 39ab2b9
fixup
zibaiwan 05a7dff
fixup const qualifier
zibaiwan bcec635
remove unnecessary cast
zibaiwan 979201a
fixup the const cast
zibaiwan 839d7ee
fix the default switch in the unittest
zibaiwan 0b2ebd2
Empty commit to try triggering CI
zibaiwan 302aa86
Empty commit to try triggering CI
zibaiwan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
//===------- HostPipes.h - get required info about FPGA Host Pipes --------===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// The file contains a number of functions to extract corresponding attributes | ||
// of the host pipe global variables and save them as a property set for the | ||
// runtime. | ||
//===----------------------------------------------------------------------===// | ||
|
||
#pragma once | ||
|
||
#include "llvm/ADT/MapVector.h" | ||
|
||
#include <cstdint> | ||
#include <vector> | ||
|
||
namespace llvm { | ||
|
||
class GlobalVariable; | ||
class Module; | ||
class StringRef; | ||
|
||
// Represents a host pipe variable - at SYCL RT level host pipe | ||
// variables are being represented as a byte-array. | ||
struct HostPipeProperty { | ||
HostPipeProperty(uint32_t Size) : Size(Size) {} | ||
|
||
// Encodes size of the underlying type T of the host pipe variable. | ||
uint32_t Size; | ||
}; | ||
|
||
using HostPipePropertyMapTy = | ||
MapVector<StringRef, std::vector<HostPipeProperty>>; | ||
|
||
/// Return \c true if the variable @GV is a host pipe variable. | ||
/// | ||
/// The function checks whether the variable has the LLVM IR attribute \c | ||
/// sycl-host-pipe | ||
/// @param GV [in] A variable to test. | ||
/// | ||
/// @return \c true if the variable is a host pipe variable, \c false | ||
/// otherwise. | ||
bool isHostPipeVariable(const GlobalVariable &GV); | ||
|
||
/// Searches given module for occurrences of host pipe variable-specific | ||
/// metadata and builds "host pipe variable name" -> | ||
/// vector<"variable properties"> map. | ||
/// | ||
/// @param M [in] LLVM Module. | ||
/// | ||
/// @returns the "host pipe variable name" -> vector<"variable properties"> | ||
/// map. | ||
HostPipePropertyMapTy collectHostPipeProperties(const Module &M); | ||
|
||
/// Returns the unique id for the host pipe variable. | ||
/// | ||
/// @param GV [in] Device Global variable. | ||
/// | ||
/// @returns the unique id of the host pipe variable represented | ||
/// in the LLVM IR by \c GV. | ||
StringRef getHostPipeVariableUniqueId(const GlobalVariable &GV); | ||
|
||
} // end namespace llvm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
//===----- HostPipes.cpp - SYCL Device Globals Pass -------------------===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// See comments in the header. | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "llvm/SYCLLowerIR/HostPipes.h" | ||
#include "llvm/SYCLLowerIR/CompileTimePropertiesPass.h" | ||
#include "llvm/SYCLLowerIR/DeviceGlobals.h" | ||
|
||
#include "llvm/ADT/STLExtras.h" | ||
#include "llvm/ADT/StringRef.h" | ||
#include "llvm/IR/Module.h" | ||
|
||
#include <cassert> | ||
|
||
using namespace llvm; | ||
|
||
namespace { | ||
|
||
constexpr StringRef SYCL_HOST_PIPE_ATTR = "sycl-host-pipe"; | ||
constexpr StringRef SYCL_HOST_PIPE_SIZE_ATTR = "sycl-host-pipe-size"; | ||
constexpr StringRef SYCL_UNIQUE_ID_ATTR = "sycl-unique-id"; | ||
|
||
/// Returns the size (in bytes) of the type \c T of the host | ||
/// pipe variable. | ||
/// | ||
/// The function gets this value from the LLVM IR attribute \c | ||
/// sycl-host-pipe-size. | ||
/// | ||
/// @param GV [in] Host Pipe variable. | ||
/// | ||
/// @returns the size (int bytes) of the underlying type \c T of the | ||
/// host pipe variable represented in the LLVM IR by @GV. | ||
uint32_t getHostPipeTypeSize(const GlobalVariable &GV) { | ||
assert(GV.hasAttribute(SYCL_HOST_PIPE_SIZE_ATTR) && | ||
"The host pipe variable must have the 'sycl-host-pipe-size' " | ||
"attribute that must contain a number representing the size of the " | ||
"underlying type T of the host pipe variable"); | ||
return getAttributeAsInteger<uint32_t>(GV, SYCL_HOST_PIPE_SIZE_ATTR); | ||
} | ||
|
||
} // anonymous namespace | ||
|
||
namespace llvm { | ||
|
||
/// Return \c true if the variable @GV is a host pipe variable. | ||
/// | ||
/// The function checks whether the variable has the LLVM IR attribute \c | ||
/// sycl-host-pipe. | ||
/// @param GV [in] A variable to test. | ||
/// | ||
/// @return \c true if the variable is a host pipe variable, \c false | ||
/// otherwise. | ||
bool isHostPipeVariable(const GlobalVariable &GV) { | ||
return GV.hasAttribute(SYCL_HOST_PIPE_ATTR); | ||
} | ||
|
||
/// Returns the unique id for the host pipe variable. | ||
/// | ||
/// The function gets this value from the LLVM IR attribute \c | ||
/// sycl-unique-id. | ||
/// | ||
/// @param GV [in] Device Global variable. | ||
/// | ||
/// @returns the unique id of the host pipe variable represented | ||
/// in the LLVM IR by \c GV. | ||
StringRef getHostPipeVariableUniqueId(const GlobalVariable &GV) { | ||
assert(GV.hasAttribute(SYCL_UNIQUE_ID_ATTR) && | ||
"a 'sycl-unique-id' string must be associated with every host " | ||
"pipe variable"); | ||
return GV.getAttribute(SYCL_UNIQUE_ID_ATTR).getValueAsString(); | ||
} | ||
|
||
HostPipePropertyMapTy collectHostPipeProperties(const Module &M) { | ||
HostPipePropertyMapTy HPM; | ||
auto HostPipeNum = count_if(M.globals(), isHostPipeVariable); | ||
if (HostPipeNum == 0) | ||
return HPM; | ||
|
||
HPM.reserve(HostPipeNum); | ||
|
||
for (auto &GV : M.globals()) { | ||
if (!isHostPipeVariable(GV)) | ||
continue; | ||
|
||
HPM[getHostPipeVariableUniqueId(GV)] = {getHostPipeTypeSize(GV)}; | ||
} | ||
|
||
return HPM; | ||
} | ||
|
||
} // namespace llvm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given this, I suspect we have some common code with the
device_global
implementation. Could we maybe consolidate these to reduce the maintenance burden?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @steffenlarsen . @rho180 , can you please take a look at this specific comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rho180 for working on this! @steffenlarsen , please take a look when you have a chance. Thank you very much!