forked from OSchip/llvm-project
[Libomptarget] Experimental Remote Plugin Fixes
D97883 introduced a compile-time error in the experimental remote offloading libomptarget plugin, this patch fixes it and resolves a number of inconsistencies in the plugin as well: 1. Non-functional Asynchronous API 2. Unnecessarily verbose debug printing 3. Misc. code clean ups This is not intended to make any functional changes to the plugin. Differential Revision: https://reviews.llvm.org/D105325
This commit is contained in:
parent
f239026f89
commit
21e92612c0
|
@ -47,20 +47,39 @@ using openmp::libomptarget::remote::TargetBinaryDescription;
|
||||||
using openmp::libomptarget::remote::TargetOffloadEntry;
|
using openmp::libomptarget::remote::TargetOffloadEntry;
|
||||||
using openmp::libomptarget::remote::TargetTable;
|
using openmp::libomptarget::remote::TargetTable;
|
||||||
|
|
||||||
struct RPCConfig {
|
struct ClientManagerConfigTy {
|
||||||
std::vector<std::string> ServerAddresses;
|
std::vector<std::string> ServerAddresses;
|
||||||
uint64_t MaxSize;
|
uint64_t MaxSize;
|
||||||
uint64_t BlockSize;
|
uint64_t BlockSize;
|
||||||
RPCConfig() {
|
int Timeout;
|
||||||
ServerAddresses = {"0.0.0.0:50051"};
|
|
||||||
MaxSize = 1 << 30;
|
ClientManagerConfigTy()
|
||||||
BlockSize = 1 << 20;
|
: ServerAddresses({"0.0.0.0:50051"}), MaxSize(1 << 30),
|
||||||
|
BlockSize(1 << 20), Timeout(5) {
|
||||||
|
// TODO: Error handle for incorrect inputs
|
||||||
|
if (const char *Env = std::getenv("LIBOMPTARGET_RPC_ADDRESS")) {
|
||||||
|
ServerAddresses.clear();
|
||||||
|
std::string AddressString = Env;
|
||||||
|
const std::string Delimiter = ",";
|
||||||
|
|
||||||
|
size_t Pos;
|
||||||
|
std::string Token;
|
||||||
|
while ((Pos = AddressString.find(Delimiter)) != std::string::npos) {
|
||||||
|
Token = AddressString.substr(0, Pos);
|
||||||
|
ServerAddresses.push_back(Token);
|
||||||
|
AddressString.erase(0, Pos + Delimiter.length());
|
||||||
|
}
|
||||||
|
ServerAddresses.push_back(AddressString);
|
||||||
|
}
|
||||||
|
if (const char *Env = std::getenv("LIBOMPTARGET_RPC_ALLOCATOR_MAX"))
|
||||||
|
MaxSize = std::stoi(Env);
|
||||||
|
if (const char *Env = std::getenv("LIBOMPTARGET_RPC_BLOCK_SIZE"))
|
||||||
|
BlockSize = std::stoi(Env);
|
||||||
|
if (const char *Env1 = std::getenv("LIBOMPTARGET_RPC_LATENCY"))
|
||||||
|
Timeout = std::stoi(Env1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Helper function to parse common environment variables between client/server
|
|
||||||
void parseEnvironment(RPCConfig &Config);
|
|
||||||
|
|
||||||
/// Loads a target binary description into protobuf.
|
/// Loads a target binary description into protobuf.
|
||||||
void loadTargetBinaryDescription(const __tgt_bin_desc *Desc,
|
void loadTargetBinaryDescription(const __tgt_bin_desc *Desc,
|
||||||
TargetBinaryDescription &Request);
|
TargetBinaryDescription &Request);
|
||||||
|
|
|
@ -16,19 +16,18 @@ service RemoteOffload {
|
||||||
rpc InitRequires(I64) returns (I32) {}
|
rpc InitRequires(I64) returns (I32) {}
|
||||||
|
|
||||||
rpc LoadBinary(Binary) returns (TargetTable) {}
|
rpc LoadBinary(Binary) returns (TargetTable) {}
|
||||||
rpc Synchronize(SynchronizeDevice) returns (I32) {}
|
|
||||||
|
|
||||||
rpc DataAlloc(AllocData) returns (Pointer) {}
|
rpc DataAlloc(AllocData) returns (Pointer) {}
|
||||||
rpc DataDelete(DeleteData) returns (I32) {}
|
rpc DataDelete(DeleteData) returns (I32) {}
|
||||||
|
|
||||||
rpc DataSubmitAsync(stream SubmitDataAsync) returns (I32) {}
|
rpc DataSubmit(stream SubmitData) returns (I32) {}
|
||||||
rpc DataRetrieveAsync(RetrieveDataAsync) returns (stream Data) {}
|
rpc DataRetrieve(RetrieveData) returns (stream Data) {}
|
||||||
|
|
||||||
rpc IsDataExchangeable(DevicePair) returns (I32) {}
|
rpc IsDataExchangeable(DevicePair) returns (I32) {}
|
||||||
rpc DataExchangeAsync(ExchangeDataAsync) returns (I32) {}
|
rpc DataExchange(ExchangeData) returns (I32) {}
|
||||||
|
|
||||||
rpc RunTargetRegionAsync(TargetRegionAsync) returns (I32) {}
|
rpc RunTargetRegion(TargetRegion) returns (I32) {}
|
||||||
rpc RunTargetTeamRegionAsync(TargetTeamRegionAsync) returns (I32) {}
|
rpc RunTargetTeamRegion(TargetTeamRegion) returns (I32) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
message Null {}
|
message Null {}
|
||||||
|
@ -92,32 +91,25 @@ message TargetBinaryDescription {
|
||||||
uint64 bin_ptr = 5;
|
uint64 bin_ptr = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SynchronizeDevice {
|
|
||||||
uint64 queue_ptr = 1;
|
|
||||||
int32 device_id = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message AllocData {
|
message AllocData {
|
||||||
uint64 size = 1;
|
uint64 size = 1;
|
||||||
uint64 hst_ptr = 2;
|
uint64 hst_ptr = 2;
|
||||||
int32 device_id = 3;
|
int32 device_id = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SubmitDataAsync {
|
message SubmitData {
|
||||||
bytes data = 1;
|
bytes data = 1;
|
||||||
uint64 hst_ptr = 2;
|
uint64 hst_ptr = 2;
|
||||||
uint64 tgt_ptr = 3;
|
uint64 tgt_ptr = 3;
|
||||||
uint64 queue_ptr = 4;
|
|
||||||
uint64 start = 5;
|
uint64 start = 5;
|
||||||
uint64 size = 6;
|
uint64 size = 6;
|
||||||
int32 device_id = 7;
|
int32 device_id = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
message RetrieveDataAsync {
|
message RetrieveData {
|
||||||
uint64 hst_ptr = 1;
|
uint64 hst_ptr = 1;
|
||||||
uint64 tgt_ptr = 2;
|
uint64 tgt_ptr = 2;
|
||||||
uint64 size = 3;
|
uint64 size = 3;
|
||||||
uint64 queue_ptr = 4;
|
|
||||||
int32 device_id = 5;
|
int32 device_id = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,12 +120,11 @@ message Data {
|
||||||
int32 ret = 4;
|
int32 ret = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ExchangeDataAsync {
|
message ExchangeData {
|
||||||
uint64 src_dev_id = 1;
|
uint64 src_dev_id = 1;
|
||||||
uint64 src_ptr = 2;
|
uint64 src_ptr = 2;
|
||||||
uint64 dst_dev_id = 3;
|
uint64 dst_dev_id = 3;
|
||||||
uint64 dst_ptr = 4;
|
uint64 dst_ptr = 4;
|
||||||
uint64 queue_ptr = 5;
|
|
||||||
uint64 size = 6;
|
uint64 size = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,23 +133,21 @@ message DeleteData {
|
||||||
int32 device_id = 2;
|
int32 device_id = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message TargetRegionAsync {
|
message TargetRegion {
|
||||||
repeated uint64 tgt_args = 1;
|
repeated uint64 tgt_args = 1;
|
||||||
repeated int64 tgt_offsets = 2;
|
repeated int64 tgt_offsets = 2;
|
||||||
uint64 tgt_entry_ptr = 3;
|
uint64 tgt_entry_ptr = 3;
|
||||||
uint64 queue_ptr = 4;
|
int32 device_id = 4;
|
||||||
int32 device_id = 5;
|
int32 arg_num = 5;
|
||||||
int32 arg_num = 6;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message TargetTeamRegionAsync {
|
message TargetTeamRegion {
|
||||||
repeated uint64 tgt_args = 1;
|
repeated uint64 tgt_args = 1;
|
||||||
repeated int64 tgt_offsets = 2;
|
repeated int64 tgt_offsets = 2;
|
||||||
uint64 tgt_entry_ptr = 3;
|
uint64 tgt_entry_ptr = 3;
|
||||||
uint64 loop_tripcount = 4;
|
uint64 loop_tripcount = 4;
|
||||||
uint64 queue_ptr = 5;
|
int32 device_id = 5;
|
||||||
int32 device_id = 6;
|
int32 arg_num = 6;
|
||||||
int32 arg_num = 7;
|
int32 team_num = 7;
|
||||||
int32 team_num = 8;
|
int32 thread_limit = 8;
|
||||||
int32 thread_limit = 9;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,27 +14,6 @@
|
||||||
#include "omptarget.h"
|
#include "omptarget.h"
|
||||||
|
|
||||||
namespace RemoteOffloading {
|
namespace RemoteOffloading {
|
||||||
void parseEnvironment(RPCConfig &Config) {
|
|
||||||
// TODO: Error handle for incorrect inputs
|
|
||||||
if (const char *Env = std::getenv("LIBOMPTARGET_RPC_ADDRESS")) {
|
|
||||||
Config.ServerAddresses.clear();
|
|
||||||
std::string AddressString = Env;
|
|
||||||
const std::string Delimiter = ",";
|
|
||||||
|
|
||||||
size_t Pos = 0;
|
|
||||||
std::string Token;
|
|
||||||
while ((Pos = AddressString.find(Delimiter)) != std::string::npos) {
|
|
||||||
Token = AddressString.substr(0, Pos);
|
|
||||||
Config.ServerAddresses.push_back(Token);
|
|
||||||
AddressString.erase(0, Pos + Delimiter.length());
|
|
||||||
}
|
|
||||||
Config.ServerAddresses.push_back(AddressString);
|
|
||||||
}
|
|
||||||
if (const char *Env = std::getenv("LIBOMPTARGET_RPC_ALLOCATOR_MAX"))
|
|
||||||
Config.MaxSize = std::stoi(Env);
|
|
||||||
if (const char *Env = std::getenv("LIBOMPTARGET_RPC_BLOCK_SIZE"))
|
|
||||||
Config.BlockSize = std::stoi(Env);
|
|
||||||
}
|
|
||||||
|
|
||||||
void loadTargetBinaryDescription(const __tgt_bin_desc *Desc,
|
void loadTargetBinaryDescription(const __tgt_bin_desc *Desc,
|
||||||
TargetBinaryDescription &Request) {
|
TargetBinaryDescription &Request) {
|
||||||
|
@ -101,10 +80,12 @@ void unloadTargetBinaryDescription(
|
||||||
|
|
||||||
// Copy Global Offload Entries
|
// Copy Global Offload Entries
|
||||||
__tgt_offload_entry *CurEntry = Desc->HostEntriesBegin;
|
__tgt_offload_entry *CurEntry = Desc->HostEntriesBegin;
|
||||||
for (int i = 0; i < Request->entries_size(); i++) {
|
size_t I = 0;
|
||||||
copyOffloadEntry(Request->entries()[i], CurEntry);
|
for (auto &Entry : Request->entries()) {
|
||||||
CopiedOffloadEntries[(void *)Request->entry_ptrs()[i]] = CurEntry;
|
copyOffloadEntry(Entry, CurEntry);
|
||||||
|
CopiedOffloadEntries[(void *)Request->entry_ptrs()[I]] = CurEntry;
|
||||||
CurEntry++;
|
CurEntry++;
|
||||||
|
I++;
|
||||||
}
|
}
|
||||||
Desc->HostEntriesEnd = CurEntry;
|
Desc->HostEntriesEnd = CurEntry;
|
||||||
|
|
||||||
|
@ -113,7 +94,7 @@ void unloadTargetBinaryDescription(
|
||||||
auto ImageItr = Request->image_ptrs().begin();
|
auto ImageItr = Request->image_ptrs().begin();
|
||||||
for (auto Image : Request->images()) {
|
for (auto Image : Request->images()) {
|
||||||
// Copy Device Offload Entries
|
// Copy Device Offload Entries
|
||||||
auto *CurEntry = Desc->HostEntriesBegin;
|
CurEntry = Desc->HostEntriesBegin;
|
||||||
bool Found = false;
|
bool Found = false;
|
||||||
|
|
||||||
if (!Desc->HostEntriesBegin) {
|
if (!Desc->HostEntriesBegin) {
|
||||||
|
@ -121,21 +102,19 @@ void unloadTargetBinaryDescription(
|
||||||
CurImage->EntriesEnd = nullptr;
|
CurImage->EntriesEnd = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < Image.entries_size(); i++) {
|
for (size_t I = 0; I < Image.entries_size(); I++) {
|
||||||
auto TgtEntry =
|
auto TgtEntry =
|
||||||
CopiedOffloadEntries.find((void *)Request->entry_ptrs()[i]);
|
CopiedOffloadEntries.find((void *)Request->entry_ptrs()[I]);
|
||||||
if (TgtEntry != CopiedOffloadEntries.end()) {
|
if (TgtEntry != CopiedOffloadEntries.end()) {
|
||||||
if (!Found)
|
if (!Found)
|
||||||
CurImage->EntriesBegin = CurEntry;
|
CurImage->EntriesBegin = CurEntry;
|
||||||
|
|
||||||
|
CurImage->EntriesEnd = CurEntry + 1;
|
||||||
Found = true;
|
Found = true;
|
||||||
if (Found) {
|
|
||||||
CurImage->EntriesEnd = CurEntry + 1;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Found = false;
|
Found = false;
|
||||||
copyOffloadEntry(Image.entries()[i], CurEntry);
|
copyOffloadEntry(Image.entries()[I], CurEntry);
|
||||||
CopiedOffloadEntries[(void *)(Request->entry_ptrs()[i])] = CurEntry;
|
CopiedOffloadEntries[(void *)(Request->entry_ptrs()[I])] = CurEntry;
|
||||||
}
|
}
|
||||||
CurEntry++;
|
CurEntry++;
|
||||||
}
|
}
|
||||||
|
@ -199,10 +178,10 @@ void unloadTargetTable(
|
||||||
Table->EntriesBegin = new __tgt_offload_entry[TableResponse.entries_size()];
|
Table->EntriesBegin = new __tgt_offload_entry[TableResponse.entries_size()];
|
||||||
|
|
||||||
auto *CurEntry = Table->EntriesBegin;
|
auto *CurEntry = Table->EntriesBegin;
|
||||||
for (int i = 0; i < TableResponse.entries_size(); i++) {
|
for (size_t I = 0; I < TableResponse.entries_size(); I++) {
|
||||||
copyOffloadEntry(TableResponse.entries()[i], CurEntry);
|
copyOffloadEntry(TableResponse.entries()[I], CurEntry);
|
||||||
HostToRemoteTargetTableMap[CurEntry->addr] =
|
HostToRemoteTargetTableMap[CurEntry->addr] =
|
||||||
(void *)TableResponse.entry_ptrs()[i];
|
(void *)TableResponse.entry_ptrs()[I];
|
||||||
CurEntry++;
|
CurEntry++;
|
||||||
}
|
}
|
||||||
Table->EntriesEnd = CurEntry;
|
Table->EntriesEnd = CurEntry;
|
||||||
|
@ -292,10 +271,10 @@ void dump(__tgt_target_table *Table) {
|
||||||
|
|
||||||
void dump(TargetOffloadEntry Entry) {
|
void dump(TargetOffloadEntry Entry) {
|
||||||
fprintf(stderr, "Entry: ");
|
fprintf(stderr, "Entry: ");
|
||||||
fprintf(stderr, " %s\n", Entry.name().c_str());
|
fprintf(stderr, " Name: %s\n", Entry.name().c_str());
|
||||||
fprintf(stderr, " %d\n", Entry.reserved());
|
fprintf(stderr, " Reserved: %d\n", Entry.reserved());
|
||||||
fprintf(stderr, " %d\n", Entry.flags());
|
fprintf(stderr, " Flags: %d\n", Entry.flags());
|
||||||
fprintf(stderr, " %ld\n", Entry.data().size());
|
fprintf(stderr, " Size: %ld\n", Entry.data().size());
|
||||||
dump(static_cast<const void *>(Entry.data().data()),
|
dump(static_cast<const void *>(Entry.data().data()),
|
||||||
static_cast<const void *>((Entry.data().c_str() + Entry.data().size())));
|
static_cast<const void *>((Entry.data().c_str() + Entry.data().size())));
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,7 @@ using grpc::ServerBuilder;
|
||||||
std::promise<void> ShutdownPromise;
|
std::promise<void> ShutdownPromise;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
RPCConfig Config;
|
ClientManagerConfigTy Config;
|
||||||
parseEnvironment(Config);
|
|
||||||
|
|
||||||
RemoteOffloadImpl Service(Config.MaxSize, Config.BlockSize);
|
RemoteOffloadImpl Service(Config.MaxSize, Config.BlockSize);
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ extern std::promise<void> ShutdownPromise;
|
||||||
|
|
||||||
Status RemoteOffloadImpl::Shutdown(ServerContext *Context, const Null *Request,
|
Status RemoteOffloadImpl::Shutdown(ServerContext *Context, const Null *Request,
|
||||||
I32 *Reply) {
|
I32 *Reply) {
|
||||||
SERVER_DBG("Shutting down the server");
|
SERVER_DBG("Shutting down the server")
|
||||||
|
|
||||||
Reply->set_number(0);
|
Reply->set_number(0);
|
||||||
ShutdownPromise.set_value();
|
ShutdownPromise.set_value();
|
||||||
|
@ -35,8 +35,6 @@ Status
|
||||||
RemoteOffloadImpl::RegisterLib(ServerContext *Context,
|
RemoteOffloadImpl::RegisterLib(ServerContext *Context,
|
||||||
const TargetBinaryDescription *Description,
|
const TargetBinaryDescription *Description,
|
||||||
I32 *Reply) {
|
I32 *Reply) {
|
||||||
SERVER_DBG("Registering library");
|
|
||||||
|
|
||||||
auto Desc = std::make_unique<__tgt_bin_desc>();
|
auto Desc = std::make_unique<__tgt_bin_desc>();
|
||||||
|
|
||||||
unloadTargetBinaryDescription(Description, Desc.get(),
|
unloadTargetBinaryDescription(Description, Desc.get(),
|
||||||
|
@ -49,15 +47,13 @@ RemoteOffloadImpl::RegisterLib(ServerContext *Context,
|
||||||
else
|
else
|
||||||
Descriptions[(void *)Description->bin_ptr()] = std::move(Desc);
|
Descriptions[(void *)Description->bin_ptr()] = std::move(Desc);
|
||||||
|
|
||||||
SERVER_DBG("Registered library");
|
SERVER_DBG("Registered library")
|
||||||
Reply->set_number(0);
|
Reply->set_number(0);
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status RemoteOffloadImpl::UnregisterLib(ServerContext *Context,
|
Status RemoteOffloadImpl::UnregisterLib(ServerContext *Context,
|
||||||
const Pointer *Request, I32 *Reply) {
|
const Pointer *Request, I32 *Reply) {
|
||||||
SERVER_DBG("Unregistering library");
|
|
||||||
|
|
||||||
if (Descriptions.find((void *)Request->number()) == Descriptions.end()) {
|
if (Descriptions.find((void *)Request->number()) == Descriptions.end()) {
|
||||||
Reply->set_number(1);
|
Reply->set_number(1);
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
|
@ -67,7 +63,7 @@ Status RemoteOffloadImpl::UnregisterLib(ServerContext *Context,
|
||||||
freeTargetBinaryDescription(Descriptions[(void *)Request->number()].get());
|
freeTargetBinaryDescription(Descriptions[(void *)Request->number()].get());
|
||||||
Descriptions.erase((void *)Request->number());
|
Descriptions.erase((void *)Request->number());
|
||||||
|
|
||||||
SERVER_DBG("Unregistered library");
|
SERVER_DBG("Unregistered library")
|
||||||
Reply->set_number(0);
|
Reply->set_number(0);
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
|
@ -75,9 +71,6 @@ Status RemoteOffloadImpl::UnregisterLib(ServerContext *Context,
|
||||||
Status RemoteOffloadImpl::IsValidBinary(ServerContext *Context,
|
Status RemoteOffloadImpl::IsValidBinary(ServerContext *Context,
|
||||||
const TargetDeviceImagePtr *DeviceImage,
|
const TargetDeviceImagePtr *DeviceImage,
|
||||||
I32 *IsValid) {
|
I32 *IsValid) {
|
||||||
SERVER_DBG("Checking if binary (%p) is valid",
|
|
||||||
(void *)(DeviceImage->image_ptr()));
|
|
||||||
|
|
||||||
__tgt_device_image *Image =
|
__tgt_device_image *Image =
|
||||||
HostToRemoteDeviceImage[(void *)DeviceImage->image_ptr()];
|
HostToRemoteDeviceImage[(void *)DeviceImage->image_ptr()];
|
||||||
|
|
||||||
|
@ -90,14 +83,13 @@ Status RemoteOffloadImpl::IsValidBinary(ServerContext *Context,
|
||||||
}
|
}
|
||||||
|
|
||||||
SERVER_DBG("Checked if binary (%p) is valid",
|
SERVER_DBG("Checked if binary (%p) is valid",
|
||||||
(void *)(DeviceImage->image_ptr()));
|
(void *)(DeviceImage->image_ptr()))
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status RemoteOffloadImpl::GetNumberOfDevices(ServerContext *Context,
|
Status RemoteOffloadImpl::GetNumberOfDevices(ServerContext *Context,
|
||||||
const Null *Null,
|
const Null *Null,
|
||||||
I32 *NumberOfDevices) {
|
I32 *NumberOfDevices) {
|
||||||
SERVER_DBG("Getting number of devices");
|
|
||||||
std::call_once(PM->RTLs.initFlag, &RTLsTy::LoadRTLs, &PM->RTLs);
|
std::call_once(PM->RTLs.initFlag, &RTLsTy::LoadRTLs, &PM->RTLs);
|
||||||
|
|
||||||
int32_t Devices = 0;
|
int32_t Devices = 0;
|
||||||
|
@ -108,39 +100,32 @@ Status RemoteOffloadImpl::GetNumberOfDevices(ServerContext *Context,
|
||||||
|
|
||||||
NumberOfDevices->set_number(Devices);
|
NumberOfDevices->set_number(Devices);
|
||||||
|
|
||||||
SERVER_DBG("Got number of devices");
|
SERVER_DBG("Got number of devices")
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status RemoteOffloadImpl::InitDevice(ServerContext *Context,
|
Status RemoteOffloadImpl::InitDevice(ServerContext *Context,
|
||||||
const I32 *DeviceNum, I32 *Reply) {
|
const I32 *DeviceNum, I32 *Reply) {
|
||||||
SERVER_DBG("Initializing device %d", DeviceNum->number());
|
|
||||||
|
|
||||||
Reply->set_number(PM->Devices[DeviceNum->number()].RTL->init_device(
|
Reply->set_number(PM->Devices[DeviceNum->number()].RTL->init_device(
|
||||||
mapHostRTLDeviceId(DeviceNum->number())));
|
mapHostRTLDeviceId(DeviceNum->number())));
|
||||||
|
|
||||||
SERVER_DBG("Initialized device %d", DeviceNum->number());
|
SERVER_DBG("Initialized device %d", DeviceNum->number())
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status RemoteOffloadImpl::InitRequires(ServerContext *Context,
|
Status RemoteOffloadImpl::InitRequires(ServerContext *Context,
|
||||||
const I64 *RequiresFlag, I32 *Reply) {
|
const I64 *RequiresFlag, I32 *Reply) {
|
||||||
SERVER_DBG("Initializing requires for devices");
|
|
||||||
|
|
||||||
for (auto &Device : PM->Devices)
|
for (auto &Device : PM->Devices)
|
||||||
if (Device.RTL->init_requires)
|
if (Device.RTL->init_requires)
|
||||||
Device.RTL->init_requires(RequiresFlag->number());
|
Device.RTL->init_requires(RequiresFlag->number());
|
||||||
Reply->set_number(RequiresFlag->number());
|
Reply->set_number(RequiresFlag->number());
|
||||||
|
|
||||||
SERVER_DBG("Initialized requires for devices");
|
SERVER_DBG("Initialized requires for devices")
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status RemoteOffloadImpl::LoadBinary(ServerContext *Context,
|
Status RemoteOffloadImpl::LoadBinary(ServerContext *Context,
|
||||||
const Binary *Binary, TargetTable *Reply) {
|
const Binary *Binary, TargetTable *Reply) {
|
||||||
SERVER_DBG("Loading binary (%p) to device %d", (void *)Binary->image_ptr(),
|
|
||||||
Binary->device_id());
|
|
||||||
|
|
||||||
__tgt_device_image *Image =
|
__tgt_device_image *Image =
|
||||||
HostToRemoteDeviceImage[(void *)Binary->image_ptr()];
|
HostToRemoteDeviceImage[(void *)Binary->image_ptr()];
|
||||||
|
|
||||||
|
@ -150,32 +135,13 @@ Status RemoteOffloadImpl::LoadBinary(ServerContext *Context,
|
||||||
loadTargetTable(Table, *Reply, Image);
|
loadTargetTable(Table, *Reply, Image);
|
||||||
|
|
||||||
SERVER_DBG("Loaded binary (%p) to device %d", (void *)Binary->image_ptr(),
|
SERVER_DBG("Loaded binary (%p) to device %d", (void *)Binary->image_ptr(),
|
||||||
Binary->device_id());
|
Binary->device_id())
|
||||||
return Status::OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status RemoteOffloadImpl::Synchronize(ServerContext *Context,
|
|
||||||
const SynchronizeDevice *Info,
|
|
||||||
I32 *Reply) {
|
|
||||||
SERVER_DBG("Synchronizing device %d (probably won't work)",
|
|
||||||
Info->device_id());
|
|
||||||
|
|
||||||
void *AsyncInfo = (void *)Info->queue_ptr();
|
|
||||||
Reply->set_number(0);
|
|
||||||
if (PM->Devices[Info->device_id()].RTL->synchronize)
|
|
||||||
Reply->set_number(PM->Devices[Info->device_id()].synchronize(
|
|
||||||
(__tgt_async_info *)AsyncInfo));
|
|
||||||
|
|
||||||
SERVER_DBG("Synchronized device %d", Info->device_id());
|
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status RemoteOffloadImpl::IsDataExchangeable(ServerContext *Context,
|
Status RemoteOffloadImpl::IsDataExchangeable(ServerContext *Context,
|
||||||
const DevicePair *Request,
|
const DevicePair *Request,
|
||||||
I32 *Reply) {
|
I32 *Reply) {
|
||||||
SERVER_DBG("Checking if data exchangable between device %d and device %d",
|
|
||||||
Request->src_dev_id(), Request->dst_dev_id());
|
|
||||||
|
|
||||||
Reply->set_number(-1);
|
Reply->set_number(-1);
|
||||||
if (PM->Devices[mapHostRTLDeviceId(Request->src_dev_id())]
|
if (PM->Devices[mapHostRTLDeviceId(Request->src_dev_id())]
|
||||||
.RTL->is_data_exchangable)
|
.RTL->is_data_exchangable)
|
||||||
|
@ -183,40 +149,30 @@ Status RemoteOffloadImpl::IsDataExchangeable(ServerContext *Context,
|
||||||
.RTL->is_data_exchangable(Request->src_dev_id(),
|
.RTL->is_data_exchangable(Request->src_dev_id(),
|
||||||
Request->dst_dev_id()));
|
Request->dst_dev_id()));
|
||||||
|
|
||||||
SERVER_DBG("Checked if data exchangable between device %d and device %d",
|
SERVER_DBG("Checked if data exchangeable between device %d and device %d",
|
||||||
Request->src_dev_id(), Request->dst_dev_id());
|
Request->src_dev_id(), Request->dst_dev_id())
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status RemoteOffloadImpl::DataAlloc(ServerContext *Context,
|
Status RemoteOffloadImpl::DataAlloc(ServerContext *Context,
|
||||||
const AllocData *Request, Pointer *Reply) {
|
const AllocData *Request, Pointer *Reply) {
|
||||||
SERVER_DBG("Allocating %ld bytes on sevice %d", Request->size(),
|
|
||||||
Request->device_id());
|
|
||||||
|
|
||||||
uint64_t TgtPtr = (uint64_t)PM->Devices[Request->device_id()].RTL->data_alloc(
|
uint64_t TgtPtr = (uint64_t)PM->Devices[Request->device_id()].RTL->data_alloc(
|
||||||
mapHostRTLDeviceId(Request->device_id()), Request->size(),
|
mapHostRTLDeviceId(Request->device_id()), Request->size(),
|
||||||
(void *)Request->hst_ptr());
|
(void *)Request->hst_ptr(), TARGET_ALLOC_DEFAULT);
|
||||||
Reply->set_number(TgtPtr);
|
Reply->set_number(TgtPtr);
|
||||||
|
|
||||||
SERVER_DBG("Allocated at " DPxMOD "", DPxPTR((void *)TgtPtr));
|
SERVER_DBG("Allocated at " DPxMOD "", DPxPTR((void *)TgtPtr))
|
||||||
|
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status RemoteOffloadImpl::DataSubmitAsync(ServerContext *Context,
|
Status RemoteOffloadImpl::DataSubmit(ServerContext *Context,
|
||||||
ServerReader<SubmitDataAsync> *Reader,
|
ServerReader<SubmitData> *Reader,
|
||||||
I32 *Reply) {
|
I32 *Reply) {
|
||||||
SubmitDataAsync Request;
|
SubmitData Request;
|
||||||
uint8_t *HostCopy = nullptr;
|
uint8_t *HostCopy = nullptr;
|
||||||
while (Reader->Read(&Request)) {
|
while (Reader->Read(&Request)) {
|
||||||
if (Request.start() == 0 && Request.size() == Request.data().size()) {
|
if (Request.start() == 0 && Request.size() == Request.data().size()) {
|
||||||
SERVER_DBG("Submitting %lu bytes async to (%p) on device %d",
|
|
||||||
Request.data().size(), (void *)Request.tgt_ptr(),
|
|
||||||
Request.device_id());
|
|
||||||
|
|
||||||
SERVER_DBG(" Host Pointer Info: %p, %p", (void *)Request.hst_ptr(),
|
|
||||||
static_cast<const void *>(Request.data().data()));
|
|
||||||
|
|
||||||
Reader->SendInitialMetadata();
|
Reader->SendInitialMetadata();
|
||||||
|
|
||||||
Reply->set_number(PM->Devices[Request.device_id()].RTL->data_submit(
|
Reply->set_number(PM->Devices[Request.device_id()].RTL->data_submit(
|
||||||
|
@ -225,7 +181,7 @@ Status RemoteOffloadImpl::DataSubmitAsync(ServerContext *Context,
|
||||||
|
|
||||||
SERVER_DBG("Submitted %lu bytes async to (%p) on device %d",
|
SERVER_DBG("Submitted %lu bytes async to (%p) on device %d",
|
||||||
Request.data().size(), (void *)Request.tgt_ptr(),
|
Request.data().size(), (void *)Request.tgt_ptr(),
|
||||||
Request.device_id());
|
Request.device_id())
|
||||||
|
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
|
@ -234,15 +190,9 @@ Status RemoteOffloadImpl::DataSubmitAsync(ServerContext *Context,
|
||||||
Reader->SendInitialMetadata();
|
Reader->SendInitialMetadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
SERVER_DBG("Submitting %lu-%lu/%lu bytes async to (%p) on device %d",
|
|
||||||
Request.start(), Request.start() + Request.data().size(),
|
|
||||||
Request.size(), (void *)Request.tgt_ptr(), Request.device_id());
|
|
||||||
|
|
||||||
memcpy((void *)((char *)HostCopy + Request.start()), Request.data().data(),
|
memcpy((void *)((char *)HostCopy + Request.start()), Request.data().data(),
|
||||||
Request.data().size());
|
Request.data().size());
|
||||||
}
|
}
|
||||||
SERVER_DBG(" Host Pointer Info: %p, %p", (void *)Request.hst_ptr(),
|
|
||||||
static_cast<const void *>(Request.data().data()));
|
|
||||||
|
|
||||||
Reply->set_number(PM->Devices[Request.device_id()].RTL->data_submit(
|
Reply->set_number(PM->Devices[Request.device_id()].RTL->data_submit(
|
||||||
mapHostRTLDeviceId(Request.device_id()), (void *)Request.tgt_ptr(),
|
mapHostRTLDeviceId(Request.device_id()), (void *)Request.tgt_ptr(),
|
||||||
|
@ -251,15 +201,16 @@ Status RemoteOffloadImpl::DataSubmitAsync(ServerContext *Context,
|
||||||
delete[] HostCopy;
|
delete[] HostCopy;
|
||||||
|
|
||||||
SERVER_DBG("Submitted %lu bytes to (%p) on device %d", Request.data().size(),
|
SERVER_DBG("Submitted %lu bytes to (%p) on device %d", Request.data().size(),
|
||||||
(void *)Request.tgt_ptr(), Request.device_id());
|
(void *)Request.tgt_ptr(), Request.device_id())
|
||||||
|
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status RemoteOffloadImpl::DataRetrieveAsync(ServerContext *Context,
|
Status RemoteOffloadImpl::DataRetrieve(ServerContext *Context,
|
||||||
const RetrieveDataAsync *Request,
|
const RetrieveData *Request,
|
||||||
ServerWriter<Data> *Writer) {
|
ServerWriter<Data> *Writer) {
|
||||||
auto HstPtr = std::make_unique<char[]>(Request->size());
|
auto HstPtr = std::make_unique<char[]>(Request->size());
|
||||||
|
|
||||||
auto Ret = PM->Devices[Request->device_id()].RTL->data_retrieve(
|
auto Ret = PM->Devices[Request->device_id()].RTL->data_retrieve(
|
||||||
mapHostRTLDeviceId(Request->device_id()), HstPtr.get(),
|
mapHostRTLDeviceId(Request->device_id()), HstPtr.get(),
|
||||||
(void *)Request->tgt_ptr(), Request->size());
|
(void *)Request->tgt_ptr(), Request->size());
|
||||||
|
@ -277,17 +228,13 @@ Status RemoteOffloadImpl::DataRetrieveAsync(ServerContext *Context,
|
||||||
Reply->set_data((char *)HstPtr.get() + Start, End - Start);
|
Reply->set_data((char *)HstPtr.get() + Start, End - Start);
|
||||||
Reply->set_ret(Ret);
|
Reply->set_ret(Ret);
|
||||||
|
|
||||||
SERVER_DBG("Retrieving %lu-%lu/%lu bytes from (%p) on device %d", Start,
|
|
||||||
End, Request->size(), (void *)Request->tgt_ptr(),
|
|
||||||
mapHostRTLDeviceId(Request->device_id()));
|
|
||||||
|
|
||||||
if (!Writer->Write(*Reply)) {
|
if (!Writer->Write(*Reply)) {
|
||||||
CLIENT_DBG("Broken stream when submitting data");
|
CLIENT_DBG("Broken stream when submitting data")
|
||||||
}
|
}
|
||||||
|
|
||||||
SERVER_DBG("Retrieved %lu-%lu/%lu bytes from (%p) on device %d", Start,
|
SERVER_DBG("Retrieved %lu-%lu/%lu bytes from (%p) on device %d", Start,
|
||||||
End, Request->size(), (void *)Request->tgt_ptr(),
|
End, Request->size(), (void *)Request->tgt_ptr(),
|
||||||
mapHostRTLDeviceId(Request->device_id()));
|
mapHostRTLDeviceId(Request->device_id()))
|
||||||
|
|
||||||
Start += BlockSize;
|
Start += BlockSize;
|
||||||
End += BlockSize;
|
End += BlockSize;
|
||||||
|
@ -297,10 +244,6 @@ Status RemoteOffloadImpl::DataRetrieveAsync(ServerContext *Context,
|
||||||
} else {
|
} else {
|
||||||
auto *Reply = protobuf::Arena::CreateMessage<Data>(Arena.get());
|
auto *Reply = protobuf::Arena::CreateMessage<Data>(Arena.get());
|
||||||
|
|
||||||
SERVER_DBG("Retrieve %lu bytes from (%p) on device %d", Request->size(),
|
|
||||||
(void *)Request->tgt_ptr(),
|
|
||||||
mapHostRTLDeviceId(Request->device_id()));
|
|
||||||
|
|
||||||
Reply->set_start(0);
|
Reply->set_start(0);
|
||||||
Reply->set_size(Request->size());
|
Reply->set_size(Request->size());
|
||||||
Reply->set_data((char *)HstPtr.get(), Request->size());
|
Reply->set_data((char *)HstPtr.get(), Request->size());
|
||||||
|
@ -308,7 +251,7 @@ Status RemoteOffloadImpl::DataRetrieveAsync(ServerContext *Context,
|
||||||
|
|
||||||
SERVER_DBG("Retrieved %lu bytes from (%p) on device %d", Request->size(),
|
SERVER_DBG("Retrieved %lu bytes from (%p) on device %d", Request->size(),
|
||||||
(void *)Request->tgt_ptr(),
|
(void *)Request->tgt_ptr(),
|
||||||
mapHostRTLDeviceId(Request->device_id()));
|
mapHostRTLDeviceId(Request->device_id()))
|
||||||
|
|
||||||
Writer->WriteLast(*Reply, WriteOptions());
|
Writer->WriteLast(*Reply, WriteOptions());
|
||||||
}
|
}
|
||||||
|
@ -316,16 +259,9 @@ Status RemoteOffloadImpl::DataRetrieveAsync(ServerContext *Context,
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status RemoteOffloadImpl::DataExchangeAsync(ServerContext *Context,
|
Status RemoteOffloadImpl::DataExchange(ServerContext *Context,
|
||||||
const ExchangeDataAsync *Request,
|
const ExchangeData *Request,
|
||||||
I32 *Reply) {
|
I32 *Reply) {
|
||||||
SERVER_DBG(
|
|
||||||
"Exchanging data asynchronously from device %d (%p) to device %d (%p) of "
|
|
||||||
"size %lu",
|
|
||||||
mapHostRTLDeviceId(Request->src_dev_id()), (void *)Request->src_ptr(),
|
|
||||||
mapHostRTLDeviceId(Request->dst_dev_id()), (void *)Request->dst_ptr(),
|
|
||||||
Request->size());
|
|
||||||
|
|
||||||
if (PM->Devices[Request->src_dev_id()].RTL->data_exchange) {
|
if (PM->Devices[Request->src_dev_id()].RTL->data_exchange) {
|
||||||
int32_t Ret = PM->Devices[Request->src_dev_id()].RTL->data_exchange(
|
int32_t Ret = PM->Devices[Request->src_dev_id()].RTL->data_exchange(
|
||||||
mapHostRTLDeviceId(Request->src_dev_id()), (void *)Request->src_ptr(),
|
mapHostRTLDeviceId(Request->src_dev_id()), (void *)Request->src_ptr(),
|
||||||
|
@ -340,30 +276,24 @@ Status RemoteOffloadImpl::DataExchangeAsync(ServerContext *Context,
|
||||||
"size %lu",
|
"size %lu",
|
||||||
mapHostRTLDeviceId(Request->src_dev_id()), (void *)Request->src_ptr(),
|
mapHostRTLDeviceId(Request->src_dev_id()), (void *)Request->src_ptr(),
|
||||||
mapHostRTLDeviceId(Request->dst_dev_id()), (void *)Request->dst_ptr(),
|
mapHostRTLDeviceId(Request->dst_dev_id()), (void *)Request->dst_ptr(),
|
||||||
Request->size());
|
Request->size())
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status RemoteOffloadImpl::DataDelete(ServerContext *Context,
|
Status RemoteOffloadImpl::DataDelete(ServerContext *Context,
|
||||||
const DeleteData *Request, I32 *Reply) {
|
const DeleteData *Request, I32 *Reply) {
|
||||||
SERVER_DBG("Deleting data from (%p) on device %d", (void *)Request->tgt_ptr(),
|
|
||||||
mapHostRTLDeviceId(Request->device_id()));
|
|
||||||
|
|
||||||
auto Ret = PM->Devices[Request->device_id()].RTL->data_delete(
|
auto Ret = PM->Devices[Request->device_id()].RTL->data_delete(
|
||||||
mapHostRTLDeviceId(Request->device_id()), (void *)Request->tgt_ptr());
|
mapHostRTLDeviceId(Request->device_id()), (void *)Request->tgt_ptr());
|
||||||
Reply->set_number(Ret);
|
Reply->set_number(Ret);
|
||||||
|
|
||||||
SERVER_DBG("Deleted data from (%p) on device %d", (void *)Request->tgt_ptr(),
|
SERVER_DBG("Deleted data from (%p) on device %d", (void *)Request->tgt_ptr(),
|
||||||
mapHostRTLDeviceId(Request->device_id()));
|
mapHostRTLDeviceId(Request->device_id()))
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status RemoteOffloadImpl::RunTargetRegionAsync(ServerContext *Context,
|
Status RemoteOffloadImpl::RunTargetRegion(ServerContext *Context,
|
||||||
const TargetRegionAsync *Request,
|
const TargetRegion *Request,
|
||||||
I32 *Reply) {
|
I32 *Reply) {
|
||||||
SERVER_DBG("Running TargetRegionAsync on device %d with %d args",
|
|
||||||
mapHostRTLDeviceId(Request->device_id()), Request->arg_num());
|
|
||||||
|
|
||||||
std::vector<uint8_t> TgtArgs(Request->arg_num());
|
std::vector<uint8_t> TgtArgs(Request->arg_num());
|
||||||
for (auto I = 0; I < Request->arg_num(); I++)
|
for (auto I = 0; I < Request->arg_num(); I++)
|
||||||
TgtArgs[I] = (uint64_t)Request->tgt_args()[I];
|
TgtArgs[I] = (uint64_t)Request->tgt_args()[I];
|
||||||
|
@ -381,16 +311,14 @@ Status RemoteOffloadImpl::RunTargetRegionAsync(ServerContext *Context,
|
||||||
|
|
||||||
Reply->set_number(Ret);
|
Reply->set_number(Ret);
|
||||||
|
|
||||||
SERVER_DBG("Ran TargetRegionAsync on device %d with %d args",
|
SERVER_DBG("Ran TargetRegion on device %d with %d args",
|
||||||
mapHostRTLDeviceId(Request->device_id()), Request->arg_num());
|
mapHostRTLDeviceId(Request->device_id()), Request->arg_num())
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status RemoteOffloadImpl::RunTargetTeamRegionAsync(
|
Status RemoteOffloadImpl::RunTargetTeamRegion(ServerContext *Context,
|
||||||
ServerContext *Context, const TargetTeamRegionAsync *Request, I32 *Reply) {
|
const TargetTeamRegion *Request,
|
||||||
SERVER_DBG("Running TargetTeamRegionAsync on device %d with %d args",
|
I32 *Reply) {
|
||||||
mapHostRTLDeviceId(Request->device_id()), Request->arg_num());
|
|
||||||
|
|
||||||
std::vector<uint64_t> TgtArgs(Request->arg_num());
|
std::vector<uint64_t> TgtArgs(Request->arg_num());
|
||||||
for (auto I = 0; I < Request->arg_num(); I++)
|
for (auto I = 0; I < Request->arg_num(); I++)
|
||||||
TgtArgs[I] = (uint64_t)Request->tgt_args()[I];
|
TgtArgs[I] = (uint64_t)Request->tgt_args()[I];
|
||||||
|
@ -401,6 +329,7 @@ Status RemoteOffloadImpl::RunTargetTeamRegionAsync(
|
||||||
TgtOffsets[I] = (ptrdiff_t)*TgtOffsetItr;
|
TgtOffsets[I] = (ptrdiff_t)*TgtOffsetItr;
|
||||||
|
|
||||||
void *TgtEntryPtr = ((__tgt_offload_entry *)Request->tgt_entry_ptr())->addr;
|
void *TgtEntryPtr = ((__tgt_offload_entry *)Request->tgt_entry_ptr())->addr;
|
||||||
|
|
||||||
int32_t Ret = PM->Devices[Request->device_id()].RTL->run_team_region(
|
int32_t Ret = PM->Devices[Request->device_id()].RTL->run_team_region(
|
||||||
mapHostRTLDeviceId(Request->device_id()), TgtEntryPtr,
|
mapHostRTLDeviceId(Request->device_id()), TgtEntryPtr,
|
||||||
(void **)TgtArgs.data(), TgtOffsets.data(), Request->arg_num(),
|
(void **)TgtArgs.data(), TgtOffsets.data(), Request->arg_num(),
|
||||||
|
@ -408,8 +337,8 @@ Status RemoteOffloadImpl::RunTargetTeamRegionAsync(
|
||||||
|
|
||||||
Reply->set_number(Ret);
|
Reply->set_number(Ret);
|
||||||
|
|
||||||
SERVER_DBG("Ran TargetTeamRegionAsync on device %d with %d args",
|
SERVER_DBG("Ran TargetTeamRegion on device %d with %d args",
|
||||||
mapHostRTLDeviceId(Request->device_id()), Request->arg_num());
|
mapHostRTLDeviceId(Request->device_id()), Request->arg_num())
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,6 @@ private:
|
||||||
|
|
||||||
std::unordered_map<const void *, __tgt_device_image *>
|
std::unordered_map<const void *, __tgt_device_image *>
|
||||||
HostToRemoteDeviceImage;
|
HostToRemoteDeviceImage;
|
||||||
std::unordered_map<const void *, __tgt_offload_entry *>
|
|
||||||
HostToRemoteOffloadEntry;
|
|
||||||
std::unordered_map<const void *, std::unique_ptr<__tgt_bin_desc>>
|
std::unordered_map<const void *, std::unique_ptr<__tgt_bin_desc>>
|
||||||
Descriptions;
|
Descriptions;
|
||||||
__tgt_target_table *Table = nullptr;
|
__tgt_target_table *Table = nullptr;
|
||||||
|
@ -80,35 +78,29 @@ public:
|
||||||
|
|
||||||
Status LoadBinary(ServerContext *Context, const Binary *Binary,
|
Status LoadBinary(ServerContext *Context, const Binary *Binary,
|
||||||
TargetTable *Reply) override;
|
TargetTable *Reply) override;
|
||||||
Status Synchronize(ServerContext *Context, const SynchronizeDevice *Info,
|
|
||||||
I32 *Reply) override;
|
|
||||||
Status IsDataExchangeable(ServerContext *Context, const DevicePair *Request,
|
Status IsDataExchangeable(ServerContext *Context, const DevicePair *Request,
|
||||||
I32 *Reply) override;
|
I32 *Reply) override;
|
||||||
|
|
||||||
Status DataAlloc(ServerContext *Context, const AllocData *Request,
|
Status DataAlloc(ServerContext *Context, const AllocData *Request,
|
||||||
Pointer *Reply) override;
|
Pointer *Reply) override;
|
||||||
|
|
||||||
Status DataSubmitAsync(ServerContext *Context,
|
Status DataSubmit(ServerContext *Context, ServerReader<SubmitData> *Reader,
|
||||||
ServerReader<SubmitDataAsync> *Reader,
|
I32 *Reply) override;
|
||||||
I32 *Reply) override;
|
Status DataRetrieve(ServerContext *Context, const RetrieveData *Request,
|
||||||
Status DataRetrieveAsync(ServerContext *Context,
|
ServerWriter<Data> *Writer) override;
|
||||||
const RetrieveDataAsync *Request,
|
|
||||||
ServerWriter<Data> *Writer) override;
|
|
||||||
|
|
||||||
Status DataExchangeAsync(ServerContext *Context,
|
Status DataExchange(ServerContext *Context, const ExchangeData *Request,
|
||||||
const ExchangeDataAsync *Request,
|
I32 *Reply) override;
|
||||||
I32 *Reply) override;
|
|
||||||
|
|
||||||
Status DataDelete(ServerContext *Context, const DeleteData *Request,
|
Status DataDelete(ServerContext *Context, const DeleteData *Request,
|
||||||
I32 *Reply) override;
|
I32 *Reply) override;
|
||||||
|
|
||||||
Status RunTargetRegionAsync(ServerContext *Context,
|
Status RunTargetRegion(ServerContext *Context, const TargetRegion *Request,
|
||||||
const TargetRegionAsync *Request,
|
I32 *Reply) override;
|
||||||
I32 *Reply) override;
|
|
||||||
|
|
||||||
Status RunTargetTeamRegionAsync(ServerContext *Context,
|
Status RunTargetTeamRegion(ServerContext *Context,
|
||||||
const TargetTeamRegionAsync *Request,
|
const TargetTeamRegion *Request,
|
||||||
I32 *Reply) override;
|
I32 *Reply) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,31 +24,30 @@ using grpc::ClientWriter;
|
||||||
using grpc::Status;
|
using grpc::Status;
|
||||||
|
|
||||||
template <typename Fn1, typename Fn2, typename TReturn>
|
template <typename Fn1, typename Fn2, typename TReturn>
|
||||||
auto RemoteOffloadClient::remoteCall(Fn1 Preprocess, Fn2 Postprocess,
|
auto RemoteOffloadClient::remoteCall(Fn1 Preprocessor, Fn2 Postprocessor,
|
||||||
TReturn ErrorValue, bool Timeout) {
|
TReturn ErrorValue, bool CanTimeOut) {
|
||||||
ArenaAllocatorLock->lock();
|
ArenaAllocatorLock->lock();
|
||||||
if (Arena->SpaceAllocated() >= MaxSize)
|
if (Arena->SpaceAllocated() >= MaxSize)
|
||||||
Arena->Reset();
|
Arena->Reset();
|
||||||
ArenaAllocatorLock->unlock();
|
ArenaAllocatorLock->unlock();
|
||||||
|
|
||||||
ClientContext Context;
|
ClientContext Context;
|
||||||
if (Timeout) {
|
if (CanTimeOut) {
|
||||||
auto Deadline =
|
auto Deadline =
|
||||||
std::chrono::system_clock::now() + std::chrono::seconds(Timeout);
|
std::chrono::system_clock::now() + std::chrono::seconds(Timeout);
|
||||||
Context.set_deadline(Deadline);
|
Context.set_deadline(Deadline);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status RPCStatus;
|
Status RPCStatus;
|
||||||
auto Reply = Preprocess(RPCStatus, Context);
|
auto Reply = Preprocessor(RPCStatus, Context);
|
||||||
|
|
||||||
// TODO: Error handle more appropriately
|
|
||||||
if (!RPCStatus.ok()) {
|
if (!RPCStatus.ok()) {
|
||||||
CLIENT_DBG("%s", RPCStatus.error_message().c_str());
|
CLIENT_DBG("%s", RPCStatus.error_message().c_str())
|
||||||
} else {
|
} else {
|
||||||
return Postprocess(Reply);
|
return Postprocessor(Reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
CLIENT_DBG("Failed");
|
CLIENT_DBG("Failed")
|
||||||
return ErrorValue;
|
return ErrorValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +55,7 @@ int32_t RemoteOffloadClient::shutdown(void) {
|
||||||
ClientContext Context;
|
ClientContext Context;
|
||||||
Null Request;
|
Null Request;
|
||||||
I32 Reply;
|
I32 Reply;
|
||||||
CLIENT_DBG("Shutting down server.");
|
CLIENT_DBG("Shutting down server.")
|
||||||
auto Status = Stub->Shutdown(&Context, Request, &Reply);
|
auto Status = Stub->Shutdown(&Context, Request, &Reply);
|
||||||
if (Status.ok())
|
if (Status.ok())
|
||||||
return Reply.number();
|
return Reply.number();
|
||||||
|
@ -65,7 +64,7 @@ int32_t RemoteOffloadClient::shutdown(void) {
|
||||||
|
|
||||||
int32_t RemoteOffloadClient::registerLib(__tgt_bin_desc *Desc) {
|
int32_t RemoteOffloadClient::registerLib(__tgt_bin_desc *Desc) {
|
||||||
return remoteCall(
|
return remoteCall(
|
||||||
/* Preprocess */
|
/* Preprocessor */
|
||||||
[&](auto &RPCStatus, auto &Context) {
|
[&](auto &RPCStatus, auto &Context) {
|
||||||
auto *Request = protobuf::Arena::CreateMessage<TargetBinaryDescription>(
|
auto *Request = protobuf::Arena::CreateMessage<TargetBinaryDescription>(
|
||||||
Arena.get());
|
Arena.get());
|
||||||
|
@ -73,14 +72,13 @@ int32_t RemoteOffloadClient::registerLib(__tgt_bin_desc *Desc) {
|
||||||
loadTargetBinaryDescription(Desc, *Request);
|
loadTargetBinaryDescription(Desc, *Request);
|
||||||
Request->set_bin_ptr((uint64_t)Desc);
|
Request->set_bin_ptr((uint64_t)Desc);
|
||||||
|
|
||||||
CLIENT_DBG("Registering library");
|
|
||||||
RPCStatus = Stub->RegisterLib(&Context, *Request, Reply);
|
RPCStatus = Stub->RegisterLib(&Context, *Request, Reply);
|
||||||
return Reply;
|
return Reply;
|
||||||
},
|
},
|
||||||
/* Postprocess */
|
/* Postprocessor */
|
||||||
[&](const auto &Reply) {
|
[&](const auto &Reply) {
|
||||||
if (Reply->number() == 0) {
|
if (Reply->number() == 0) {
|
||||||
CLIENT_DBG("Registered library");
|
CLIENT_DBG("Registered library")
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -90,24 +88,23 @@ int32_t RemoteOffloadClient::registerLib(__tgt_bin_desc *Desc) {
|
||||||
|
|
||||||
int32_t RemoteOffloadClient::unregisterLib(__tgt_bin_desc *Desc) {
|
int32_t RemoteOffloadClient::unregisterLib(__tgt_bin_desc *Desc) {
|
||||||
return remoteCall(
|
return remoteCall(
|
||||||
/* Preprocess */
|
/* Preprocessor */
|
||||||
[&](auto &RPCStatus, auto &Context) {
|
[&](auto &RPCStatus, auto &Context) {
|
||||||
auto *Request = protobuf::Arena::CreateMessage<Pointer>(Arena.get());
|
auto *Request = protobuf::Arena::CreateMessage<Pointer>(Arena.get());
|
||||||
auto *Reply = protobuf::Arena::CreateMessage<I32>(Arena.get());
|
auto *Reply = protobuf::Arena::CreateMessage<I32>(Arena.get());
|
||||||
|
|
||||||
Request->set_number((uint64_t)Desc);
|
Request->set_number((uint64_t)Desc);
|
||||||
|
|
||||||
CLIENT_DBG("Unregistering library");
|
|
||||||
RPCStatus = Stub->UnregisterLib(&Context, *Request, Reply);
|
RPCStatus = Stub->UnregisterLib(&Context, *Request, Reply);
|
||||||
return Reply;
|
return Reply;
|
||||||
},
|
},
|
||||||
/* Postprocess */
|
/* Postprocessor */
|
||||||
[&](const auto &Reply) {
|
[&](const auto &Reply) {
|
||||||
if (Reply->number() == 0) {
|
if (Reply->number() == 0) {
|
||||||
CLIENT_DBG("Unregistered library");
|
CLIENT_DBG("Unregistered library")
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
CLIENT_DBG("Failed to unregister library");
|
CLIENT_DBG("Failed to unregister library")
|
||||||
return 1;
|
return 1;
|
||||||
},
|
},
|
||||||
/* Error Value */ 1);
|
/* Error Value */ 1);
|
||||||
|
@ -115,7 +112,7 @@ int32_t RemoteOffloadClient::unregisterLib(__tgt_bin_desc *Desc) {
|
||||||
|
|
||||||
int32_t RemoteOffloadClient::isValidBinary(__tgt_device_image *Image) {
|
int32_t RemoteOffloadClient::isValidBinary(__tgt_device_image *Image) {
|
||||||
return remoteCall(
|
return remoteCall(
|
||||||
/* Preprocess */
|
/* Preprocessor */
|
||||||
[&](auto &RPCStatus, auto &Context) {
|
[&](auto &RPCStatus, auto &Context) {
|
||||||
auto *Request =
|
auto *Request =
|
||||||
protobuf::Arena::CreateMessage<TargetDeviceImagePtr>(Arena.get());
|
protobuf::Arena::CreateMessage<TargetDeviceImagePtr>(Arena.get());
|
||||||
|
@ -127,16 +124,15 @@ int32_t RemoteOffloadClient::isValidBinary(__tgt_device_image *Image) {
|
||||||
while (EntryItr != Image->EntriesEnd)
|
while (EntryItr != Image->EntriesEnd)
|
||||||
Request->add_entry_ptrs((uint64_t)EntryItr++);
|
Request->add_entry_ptrs((uint64_t)EntryItr++);
|
||||||
|
|
||||||
CLIENT_DBG("Validating binary");
|
|
||||||
RPCStatus = Stub->IsValidBinary(&Context, *Request, Reply);
|
RPCStatus = Stub->IsValidBinary(&Context, *Request, Reply);
|
||||||
return Reply;
|
return Reply;
|
||||||
},
|
},
|
||||||
/* Postprocess */
|
/* Postprocessor */
|
||||||
[&](const auto &Reply) {
|
[&](const auto &Reply) {
|
||||||
if (Reply->number()) {
|
if (Reply->number()) {
|
||||||
CLIENT_DBG("Validated binary");
|
CLIENT_DBG("Validated binary")
|
||||||
} else {
|
} else {
|
||||||
CLIENT_DBG("Could not validate binary");
|
CLIENT_DBG("Could not validate binary")
|
||||||
}
|
}
|
||||||
return Reply->number();
|
return Reply->number();
|
||||||
},
|
},
|
||||||
|
@ -145,22 +141,21 @@ int32_t RemoteOffloadClient::isValidBinary(__tgt_device_image *Image) {
|
||||||
|
|
||||||
int32_t RemoteOffloadClient::getNumberOfDevices() {
|
int32_t RemoteOffloadClient::getNumberOfDevices() {
|
||||||
return remoteCall(
|
return remoteCall(
|
||||||
/* Preprocess */
|
/* Preprocessor */
|
||||||
[&](Status &RPCStatus, ClientContext &Context) {
|
[&](Status &RPCStatus, ClientContext &Context) {
|
||||||
auto *Request = protobuf::Arena::CreateMessage<Null>(Arena.get());
|
auto *Request = protobuf::Arena::CreateMessage<Null>(Arena.get());
|
||||||
auto *Reply = protobuf::Arena::CreateMessage<I32>(Arena.get());
|
auto *Reply = protobuf::Arena::CreateMessage<I32>(Arena.get());
|
||||||
|
|
||||||
CLIENT_DBG("Getting number of devices");
|
|
||||||
RPCStatus = Stub->GetNumberOfDevices(&Context, *Request, Reply);
|
RPCStatus = Stub->GetNumberOfDevices(&Context, *Request, Reply);
|
||||||
|
|
||||||
return Reply;
|
return Reply;
|
||||||
},
|
},
|
||||||
/* Postprocess */
|
/* Postprocessor */
|
||||||
[&](const auto &Reply) {
|
[&](const auto &Reply) {
|
||||||
if (Reply->number()) {
|
if (Reply->number()) {
|
||||||
CLIENT_DBG("Found %d devices", Reply->number());
|
CLIENT_DBG("Found %d devices", Reply->number())
|
||||||
} else {
|
} else {
|
||||||
CLIENT_DBG("Could not get the number of devices");
|
CLIENT_DBG("Could not get the number of devices")
|
||||||
}
|
}
|
||||||
return Reply->number();
|
return Reply->number();
|
||||||
},
|
},
|
||||||
|
@ -169,24 +164,23 @@ int32_t RemoteOffloadClient::getNumberOfDevices() {
|
||||||
|
|
||||||
int32_t RemoteOffloadClient::initDevice(int32_t DeviceId) {
|
int32_t RemoteOffloadClient::initDevice(int32_t DeviceId) {
|
||||||
return remoteCall(
|
return remoteCall(
|
||||||
/* Preprocess */
|
/* Preprocessor */
|
||||||
[&](auto &RPCStatus, auto &Context) {
|
[&](auto &RPCStatus, auto &Context) {
|
||||||
auto *Request = protobuf::Arena::CreateMessage<I32>(Arena.get());
|
auto *Request = protobuf::Arena::CreateMessage<I32>(Arena.get());
|
||||||
auto *Reply = protobuf::Arena::CreateMessage<I32>(Arena.get());
|
auto *Reply = protobuf::Arena::CreateMessage<I32>(Arena.get());
|
||||||
|
|
||||||
Request->set_number(DeviceId);
|
Request->set_number(DeviceId);
|
||||||
|
|
||||||
CLIENT_DBG("Initializing device %d", DeviceId);
|
|
||||||
RPCStatus = Stub->InitDevice(&Context, *Request, Reply);
|
RPCStatus = Stub->InitDevice(&Context, *Request, Reply);
|
||||||
|
|
||||||
return Reply;
|
return Reply;
|
||||||
},
|
},
|
||||||
/* Postprocess */
|
/* Postprocessor */
|
||||||
[&](const auto &Reply) {
|
[&](const auto &Reply) {
|
||||||
if (!Reply->number()) {
|
if (!Reply->number()) {
|
||||||
CLIENT_DBG("Initialized device %d", DeviceId);
|
CLIENT_DBG("Initialized device %d", DeviceId)
|
||||||
} else {
|
} else {
|
||||||
CLIENT_DBG("Could not initialize device %d", DeviceId);
|
CLIENT_DBG("Could not initialize device %d", DeviceId)
|
||||||
}
|
}
|
||||||
return Reply->number();
|
return Reply->number();
|
||||||
},
|
},
|
||||||
|
@ -195,21 +189,20 @@ int32_t RemoteOffloadClient::initDevice(int32_t DeviceId) {
|
||||||
|
|
||||||
int32_t RemoteOffloadClient::initRequires(int64_t RequiresFlags) {
|
int32_t RemoteOffloadClient::initRequires(int64_t RequiresFlags) {
|
||||||
return remoteCall(
|
return remoteCall(
|
||||||
/* Preprocess */
|
/* Preprocessor */
|
||||||
[&](auto &RPCStatus, auto &Context) {
|
[&](auto &RPCStatus, auto &Context) {
|
||||||
auto *Request = protobuf::Arena::CreateMessage<I64>(Arena.get());
|
auto *Request = protobuf::Arena::CreateMessage<I64>(Arena.get());
|
||||||
auto *Reply = protobuf::Arena::CreateMessage<I32>(Arena.get());
|
auto *Reply = protobuf::Arena::CreateMessage<I32>(Arena.get());
|
||||||
Request->set_number(RequiresFlags);
|
Request->set_number(RequiresFlags);
|
||||||
CLIENT_DBG("Initializing requires");
|
|
||||||
RPCStatus = Stub->InitRequires(&Context, *Request, Reply);
|
RPCStatus = Stub->InitRequires(&Context, *Request, Reply);
|
||||||
return Reply;
|
return Reply;
|
||||||
},
|
},
|
||||||
/* Postprocess */
|
/* Postprocessor */
|
||||||
[&](const auto &Reply) {
|
[&](const auto &Reply) {
|
||||||
if (Reply->number()) {
|
if (Reply->number()) {
|
||||||
CLIENT_DBG("Initialized requires");
|
CLIENT_DBG("Initialized requires")
|
||||||
} else {
|
} else {
|
||||||
CLIENT_DBG("Could not initialize requires");
|
CLIENT_DBG("Could not initialize requires")
|
||||||
}
|
}
|
||||||
return Reply->number();
|
return Reply->number();
|
||||||
},
|
},
|
||||||
|
@ -219,7 +212,7 @@ int32_t RemoteOffloadClient::initRequires(int64_t RequiresFlags) {
|
||||||
__tgt_target_table *RemoteOffloadClient::loadBinary(int32_t DeviceId,
|
__tgt_target_table *RemoteOffloadClient::loadBinary(int32_t DeviceId,
|
||||||
__tgt_device_image *Image) {
|
__tgt_device_image *Image) {
|
||||||
return remoteCall(
|
return remoteCall(
|
||||||
/* Preprocess */
|
/* Preprocessor */
|
||||||
[&](auto &RPCStatus, auto &Context) {
|
[&](auto &RPCStatus, auto &Context) {
|
||||||
auto *ImageMessage =
|
auto *ImageMessage =
|
||||||
protobuf::Arena::CreateMessage<Binary>(Arena.get());
|
protobuf::Arena::CreateMessage<Binary>(Arena.get());
|
||||||
|
@ -227,14 +220,13 @@ __tgt_target_table *RemoteOffloadClient::loadBinary(int32_t DeviceId,
|
||||||
ImageMessage->set_image_ptr((uint64_t)Image->ImageStart);
|
ImageMessage->set_image_ptr((uint64_t)Image->ImageStart);
|
||||||
ImageMessage->set_device_id(DeviceId);
|
ImageMessage->set_device_id(DeviceId);
|
||||||
|
|
||||||
CLIENT_DBG("Loading Image %p to device %d", Image, DeviceId);
|
|
||||||
RPCStatus = Stub->LoadBinary(&Context, *ImageMessage, Reply);
|
RPCStatus = Stub->LoadBinary(&Context, *ImageMessage, Reply);
|
||||||
return Reply;
|
return Reply;
|
||||||
},
|
},
|
||||||
/* Postprocess */
|
/* Postprocessor */
|
||||||
[&](auto &Reply) {
|
[&](auto &Reply) {
|
||||||
if (Reply->entries_size() == 0) {
|
if (Reply->entries_size() == 0) {
|
||||||
CLIENT_DBG("Could not load image %p onto device %d", Image, DeviceId);
|
CLIENT_DBG("Could not load image %p onto device %d", Image, DeviceId)
|
||||||
return (__tgt_target_table *)nullptr;
|
return (__tgt_target_table *)nullptr;
|
||||||
}
|
}
|
||||||
DevicesToTables[DeviceId] = std::make_unique<__tgt_target_table>();
|
DevicesToTables[DeviceId] = std::make_unique<__tgt_target_table>();
|
||||||
|
@ -242,46 +234,18 @@ __tgt_target_table *RemoteOffloadClient::loadBinary(int32_t DeviceId,
|
||||||
RemoteEntries[DeviceId]);
|
RemoteEntries[DeviceId]);
|
||||||
|
|
||||||
CLIENT_DBG("Loaded Image %p to device %d with %d entries", Image,
|
CLIENT_DBG("Loaded Image %p to device %d with %d entries", Image,
|
||||||
DeviceId, Reply->entries_size());
|
DeviceId, Reply->entries_size())
|
||||||
|
|
||||||
return DevicesToTables[DeviceId].get();
|
return DevicesToTables[DeviceId].get();
|
||||||
},
|
},
|
||||||
/* Error Value */ (__tgt_target_table *)nullptr,
|
/* Error Value */ (__tgt_target_table *)nullptr,
|
||||||
/* Timeout */ false);
|
/* CanTimeOut */ false);
|
||||||
}
|
|
||||||
|
|
||||||
int64_t RemoteOffloadClient::synchronize(int32_t DeviceId,
|
|
||||||
__tgt_async_info *AsyncInfo) {
|
|
||||||
return remoteCall(
|
|
||||||
/* Preprocess */
|
|
||||||
[&](auto &RPCStatus, auto &Context) {
|
|
||||||
auto *Reply = protobuf::Arena::CreateMessage<I32>(Arena.get());
|
|
||||||
auto *Info =
|
|
||||||
protobuf::Arena::CreateMessage<SynchronizeDevice>(Arena.get());
|
|
||||||
|
|
||||||
Info->set_device_id(DeviceId);
|
|
||||||
Info->set_queue_ptr((uint64_t)AsyncInfo);
|
|
||||||
|
|
||||||
CLIENT_DBG("Synchronizing device %d", DeviceId);
|
|
||||||
RPCStatus = Stub->Synchronize(&Context, *Info, Reply);
|
|
||||||
return Reply;
|
|
||||||
},
|
|
||||||
/* Postprocess */
|
|
||||||
[&](auto &Reply) {
|
|
||||||
if (Reply->number()) {
|
|
||||||
CLIENT_DBG("Synchronized device %d", DeviceId);
|
|
||||||
} else {
|
|
||||||
CLIENT_DBG("Could not synchronize device %d", DeviceId);
|
|
||||||
}
|
|
||||||
return Reply->number();
|
|
||||||
},
|
|
||||||
/* Error Value */ -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t RemoteOffloadClient::isDataExchangeable(int32_t SrcDevId,
|
int32_t RemoteOffloadClient::isDataExchangeable(int32_t SrcDevId,
|
||||||
int32_t DstDevId) {
|
int32_t DstDevId) {
|
||||||
return remoteCall(
|
return remoteCall(
|
||||||
/* Preprocess */
|
/* Preprocessor */
|
||||||
[&](auto &RPCStatus, auto &Context) {
|
[&](auto &RPCStatus, auto &Context) {
|
||||||
auto *Request = protobuf::Arena::CreateMessage<DevicePair>(Arena.get());
|
auto *Request = protobuf::Arena::CreateMessage<DevicePair>(Arena.get());
|
||||||
auto *Reply = protobuf::Arena::CreateMessage<I32>(Arena.get());
|
auto *Reply = protobuf::Arena::CreateMessage<I32>(Arena.get());
|
||||||
|
@ -289,18 +253,16 @@ int32_t RemoteOffloadClient::isDataExchangeable(int32_t SrcDevId,
|
||||||
Request->set_src_dev_id(SrcDevId);
|
Request->set_src_dev_id(SrcDevId);
|
||||||
Request->set_dst_dev_id(DstDevId);
|
Request->set_dst_dev_id(DstDevId);
|
||||||
|
|
||||||
CLIENT_DBG("Asking if data is exchangeable between %d, %d", SrcDevId,
|
|
||||||
DstDevId);
|
|
||||||
RPCStatus = Stub->IsDataExchangeable(&Context, *Request, Reply);
|
RPCStatus = Stub->IsDataExchangeable(&Context, *Request, Reply);
|
||||||
return Reply;
|
return Reply;
|
||||||
},
|
},
|
||||||
/* Postprocess */
|
/* Postprocessor */
|
||||||
[&](auto &Reply) {
|
[&](auto &Reply) {
|
||||||
if (Reply->number()) {
|
if (Reply->number()) {
|
||||||
CLIENT_DBG("Data is exchangeable between %d, %d", SrcDevId, DstDevId);
|
CLIENT_DBG("Data is exchangeable between %d, %d", SrcDevId, DstDevId)
|
||||||
} else {
|
} else {
|
||||||
CLIENT_DBG("Data is not exchangeable between %d, %d", SrcDevId,
|
CLIENT_DBG("Data is not exchangeable between %d, %d", SrcDevId,
|
||||||
DstDevId);
|
DstDevId)
|
||||||
}
|
}
|
||||||
return Reply->number();
|
return Reply->number();
|
||||||
},
|
},
|
||||||
|
@ -310,7 +272,7 @@ int32_t RemoteOffloadClient::isDataExchangeable(int32_t SrcDevId,
|
||||||
void *RemoteOffloadClient::dataAlloc(int32_t DeviceId, int64_t Size,
|
void *RemoteOffloadClient::dataAlloc(int32_t DeviceId, int64_t Size,
|
||||||
void *HstPtr) {
|
void *HstPtr) {
|
||||||
return remoteCall(
|
return remoteCall(
|
||||||
/* Preprocess */
|
/* Preprocessor */
|
||||||
[&](auto &RPCStatus, auto &Context) {
|
[&](auto &RPCStatus, auto &Context) {
|
||||||
auto *Reply = protobuf::Arena::CreateMessage<Pointer>(Arena.get());
|
auto *Reply = protobuf::Arena::CreateMessage<Pointer>(Arena.get());
|
||||||
auto *Request = protobuf::Arena::CreateMessage<AllocData>(Arena.get());
|
auto *Request = protobuf::Arena::CreateMessage<AllocData>(Arena.get());
|
||||||
|
@ -319,40 +281,38 @@ void *RemoteOffloadClient::dataAlloc(int32_t DeviceId, int64_t Size,
|
||||||
Request->set_size(Size);
|
Request->set_size(Size);
|
||||||
Request->set_hst_ptr((uint64_t)HstPtr);
|
Request->set_hst_ptr((uint64_t)HstPtr);
|
||||||
|
|
||||||
CLIENT_DBG("Allocating %ld bytes on device %d", Size, DeviceId);
|
|
||||||
RPCStatus = Stub->DataAlloc(&Context, *Request, Reply);
|
RPCStatus = Stub->DataAlloc(&Context, *Request, Reply);
|
||||||
return Reply;
|
return Reply;
|
||||||
},
|
},
|
||||||
/* Postprocess */
|
/* Postprocessor */
|
||||||
[&](auto &Reply) {
|
[&](auto &Reply) {
|
||||||
if (Reply->number()) {
|
if (Reply->number()) {
|
||||||
CLIENT_DBG("Allocated %ld bytes on device %d at %p", Size, DeviceId,
|
CLIENT_DBG("Allocated %ld bytes on device %d at %p", Size, DeviceId,
|
||||||
(void *)Reply->number());
|
(void *)Reply->number())
|
||||||
} else {
|
} else {
|
||||||
CLIENT_DBG("Could not allocate %ld bytes on device %d at %p", Size,
|
CLIENT_DBG("Could not allocate %ld bytes on device %d at %p", Size,
|
||||||
DeviceId, (void *)Reply->number());
|
DeviceId, (void *)Reply->number())
|
||||||
}
|
}
|
||||||
return (void *)Reply->number();
|
return (void *)Reply->number();
|
||||||
},
|
},
|
||||||
/* Error Value */ (void *)nullptr);
|
/* Error Value */ (void *)nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t RemoteOffloadClient::dataSubmitAsync(int32_t DeviceId, void *TgtPtr,
|
int32_t RemoteOffloadClient::dataSubmit(int32_t DeviceId, void *TgtPtr,
|
||||||
void *HstPtr, int64_t Size,
|
void *HstPtr, int64_t Size) {
|
||||||
__tgt_async_info *AsyncInfo) {
|
|
||||||
|
|
||||||
return remoteCall(
|
return remoteCall(
|
||||||
/* Preprocess */
|
/* Preprocessor */
|
||||||
[&](auto &RPCStatus, auto &Context) {
|
[&](auto &RPCStatus, auto &Context) {
|
||||||
auto *Reply = protobuf::Arena::CreateMessage<I32>(Arena.get());
|
auto *Reply = protobuf::Arena::CreateMessage<I32>(Arena.get());
|
||||||
std::unique_ptr<ClientWriter<SubmitDataAsync>> Writer(
|
std::unique_ptr<ClientWriter<SubmitData>> Writer(
|
||||||
Stub->DataSubmitAsync(&Context, Reply));
|
Stub->DataSubmit(&Context, Reply));
|
||||||
|
|
||||||
if (Size > BlockSize) {
|
if (Size > BlockSize) {
|
||||||
int64_t Start = 0, End = BlockSize;
|
int64_t Start = 0, End = BlockSize;
|
||||||
for (auto I = 0; I < ceil((float)Size / BlockSize); I++) {
|
for (auto I = 0; I < ceil((float)Size / BlockSize); I++) {
|
||||||
auto *Request =
|
auto *Request =
|
||||||
protobuf::Arena::CreateMessage<SubmitDataAsync>(Arena.get());
|
protobuf::Arena::CreateMessage<SubmitData>(Arena.get());
|
||||||
|
|
||||||
Request->set_device_id(DeviceId);
|
Request->set_device_id(DeviceId);
|
||||||
Request->set_data((char *)HstPtr + Start, End - Start);
|
Request->set_data((char *)HstPtr + Start, End - Start);
|
||||||
|
@ -360,13 +320,9 @@ int32_t RemoteOffloadClient::dataSubmitAsync(int32_t DeviceId, void *TgtPtr,
|
||||||
Request->set_tgt_ptr((uint64_t)TgtPtr);
|
Request->set_tgt_ptr((uint64_t)TgtPtr);
|
||||||
Request->set_start(Start);
|
Request->set_start(Start);
|
||||||
Request->set_size(Size);
|
Request->set_size(Size);
|
||||||
Request->set_queue_ptr((uint64_t)AsyncInfo);
|
|
||||||
|
|
||||||
CLIENT_DBG("Submitting %ld-%ld/%ld bytes async on device %d at %p",
|
|
||||||
Start, End, Size, DeviceId, TgtPtr)
|
|
||||||
|
|
||||||
if (!Writer->Write(*Request)) {
|
if (!Writer->Write(*Request)) {
|
||||||
CLIENT_DBG("Broken stream when submitting data");
|
CLIENT_DBG("Broken stream when submitting data")
|
||||||
Reply->set_number(0);
|
Reply->set_number(0);
|
||||||
return Reply;
|
return Reply;
|
||||||
}
|
}
|
||||||
|
@ -378,7 +334,7 @@ int32_t RemoteOffloadClient::dataSubmitAsync(int32_t DeviceId, void *TgtPtr,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto *Request =
|
auto *Request =
|
||||||
protobuf::Arena::CreateMessage<SubmitDataAsync>(Arena.get());
|
protobuf::Arena::CreateMessage<SubmitData>(Arena.get());
|
||||||
|
|
||||||
Request->set_device_id(DeviceId);
|
Request->set_device_id(DeviceId);
|
||||||
Request->set_data(HstPtr, Size);
|
Request->set_data(HstPtr, Size);
|
||||||
|
@ -387,10 +343,8 @@ int32_t RemoteOffloadClient::dataSubmitAsync(int32_t DeviceId, void *TgtPtr,
|
||||||
Request->set_start(0);
|
Request->set_start(0);
|
||||||
Request->set_size(Size);
|
Request->set_size(Size);
|
||||||
|
|
||||||
CLIENT_DBG("Submitting %ld bytes async on device %d at %p", Size,
|
|
||||||
DeviceId, TgtPtr)
|
|
||||||
if (!Writer->Write(*Request)) {
|
if (!Writer->Write(*Request)) {
|
||||||
CLIENT_DBG("Broken stream when submitting data");
|
CLIENT_DBG("Broken stream when submitting data")
|
||||||
Reply->set_number(0);
|
Reply->set_number(0);
|
||||||
return Reply;
|
return Reply;
|
||||||
}
|
}
|
||||||
|
@ -401,11 +355,11 @@ int32_t RemoteOffloadClient::dataSubmitAsync(int32_t DeviceId, void *TgtPtr,
|
||||||
|
|
||||||
return Reply;
|
return Reply;
|
||||||
},
|
},
|
||||||
/* Postprocess */
|
/* Postprocessor */
|
||||||
[&](auto &Reply) {
|
[&](auto &Reply) {
|
||||||
if (!Reply->number()) {
|
if (!Reply->number()) {
|
||||||
CLIENT_DBG("Async submitted %ld bytes on device %d at %p", Size,
|
CLIENT_DBG(" submitted %ld bytes on device %d at %p", Size, DeviceId,
|
||||||
DeviceId, TgtPtr)
|
TgtPtr)
|
||||||
} else {
|
} else {
|
||||||
CLIENT_DBG("Could not async submit %ld bytes on device %d at %p",
|
CLIENT_DBG("Could not async submit %ld bytes on device %d at %p",
|
||||||
Size, DeviceId, TgtPtr)
|
Size, DeviceId, TgtPtr)
|
||||||
|
@ -413,27 +367,25 @@ int32_t RemoteOffloadClient::dataSubmitAsync(int32_t DeviceId, void *TgtPtr,
|
||||||
return Reply->number();
|
return Reply->number();
|
||||||
},
|
},
|
||||||
/* Error Value */ -1,
|
/* Error Value */ -1,
|
||||||
/* Timeout */ false);
|
/* CanTimeOut */ false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t RemoteOffloadClient::dataRetrieveAsync(int32_t DeviceId, void *HstPtr,
|
int32_t RemoteOffloadClient::dataRetrieve(int32_t DeviceId, void *HstPtr,
|
||||||
void *TgtPtr, int64_t Size,
|
void *TgtPtr, int64_t Size) {
|
||||||
__tgt_async_info *AsyncInfo) {
|
|
||||||
return remoteCall(
|
return remoteCall(
|
||||||
/* Preprocess */
|
/* Preprocessor */
|
||||||
[&](auto &RPCStatus, auto &Context) {
|
[&](auto &RPCStatus, auto &Context) {
|
||||||
auto *Request =
|
auto *Request =
|
||||||
protobuf::Arena::CreateMessage<RetrieveDataAsync>(Arena.get());
|
protobuf::Arena::CreateMessage<RetrieveData>(Arena.get());
|
||||||
|
|
||||||
Request->set_device_id(DeviceId);
|
Request->set_device_id(DeviceId);
|
||||||
Request->set_size(Size);
|
Request->set_size(Size);
|
||||||
Request->set_hst_ptr((int64_t)HstPtr);
|
Request->set_hst_ptr((int64_t)HstPtr);
|
||||||
Request->set_tgt_ptr((int64_t)TgtPtr);
|
Request->set_tgt_ptr((int64_t)TgtPtr);
|
||||||
Request->set_queue_ptr((uint64_t)AsyncInfo);
|
|
||||||
|
|
||||||
auto *Reply = protobuf::Arena::CreateMessage<Data>(Arena.get());
|
auto *Reply = protobuf::Arena::CreateMessage<Data>(Arena.get());
|
||||||
std::unique_ptr<ClientReader<Data>> Reader(
|
std::unique_ptr<ClientReader<Data>> Reader(
|
||||||
Stub->DataRetrieveAsync(&Context, *Request));
|
Stub->DataRetrieve(&Context, *Request));
|
||||||
Reader->WaitForInitialMetadata();
|
Reader->WaitForInitialMetadata();
|
||||||
while (Reader->Read(Reply)) {
|
while (Reader->Read(Reply)) {
|
||||||
if (Reply->ret()) {
|
if (Reply->ret()) {
|
||||||
|
@ -444,18 +396,10 @@ int32_t RemoteOffloadClient::dataRetrieveAsync(int32_t DeviceId, void *HstPtr,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Reply->start() == 0 && Reply->size() == Reply->data().size()) {
|
if (Reply->start() == 0 && Reply->size() == Reply->data().size()) {
|
||||||
CLIENT_DBG("Async retrieving %ld bytes on device %d at %p for %p",
|
|
||||||
Size, DeviceId, TgtPtr, HstPtr)
|
|
||||||
|
|
||||||
memcpy(HstPtr, Reply->data().data(), Reply->data().size());
|
memcpy(HstPtr, Reply->data().data(), Reply->data().size());
|
||||||
|
|
||||||
return Reply;
|
return Reply;
|
||||||
}
|
}
|
||||||
CLIENT_DBG("Retrieving %lu-%lu/%lu bytes async from (%p) to (%p) "
|
|
||||||
"on Device %d",
|
|
||||||
Reply->start(), Reply->start() + Reply->data().size(),
|
|
||||||
Reply->size(), (void *)Request->tgt_ptr(), HstPtr,
|
|
||||||
Request->device_id());
|
|
||||||
|
|
||||||
memcpy((void *)((char *)HstPtr + Reply->start()),
|
memcpy((void *)((char *)HstPtr + Reply->start()),
|
||||||
Reply->data().data(), Reply->data().size());
|
Reply->data().data(), Reply->data().size());
|
||||||
|
@ -464,54 +408,49 @@ int32_t RemoteOffloadClient::dataRetrieveAsync(int32_t DeviceId, void *HstPtr,
|
||||||
|
|
||||||
return Reply;
|
return Reply;
|
||||||
},
|
},
|
||||||
/* Postprocess */
|
/* Postprocessor */
|
||||||
[&](auto &Reply) {
|
[&](auto &Reply) {
|
||||||
if (!Reply->ret()) {
|
if (!Reply->ret()) {
|
||||||
CLIENT_DBG("Async retrieve %ld bytes on Device %d", Size, DeviceId);
|
CLIENT_DBG("Retrieved %ld bytes on Device %d", Size, DeviceId)
|
||||||
} else {
|
} else {
|
||||||
CLIENT_DBG("Could not async retrieve %ld bytes on Device %d", Size,
|
CLIENT_DBG("Could not async retrieve %ld bytes on Device %d", Size,
|
||||||
DeviceId);
|
DeviceId)
|
||||||
}
|
}
|
||||||
return Reply->ret();
|
return Reply->ret();
|
||||||
},
|
},
|
||||||
/* Error Value */ -1,
|
/* Error Value */ -1,
|
||||||
/* Timeout */ false);
|
/* CanTimeOut */ false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t RemoteOffloadClient::dataExchangeAsync(int32_t SrcDevId, void *SrcPtr,
|
int32_t RemoteOffloadClient::dataExchange(int32_t SrcDevId, void *SrcPtr,
|
||||||
int32_t DstDevId, void *DstPtr,
|
int32_t DstDevId, void *DstPtr,
|
||||||
int64_t Size,
|
int64_t Size) {
|
||||||
__tgt_async_info *AsyncInfo) {
|
|
||||||
return remoteCall(
|
return remoteCall(
|
||||||
/* Preprocess */
|
/* Preprocessor */
|
||||||
[&](auto &RPCStatus, auto &Context) {
|
[&](auto &RPCStatus, auto &Context) {
|
||||||
auto *Reply = protobuf::Arena::CreateMessage<I32>(Arena.get());
|
auto *Reply = protobuf::Arena::CreateMessage<I32>(Arena.get());
|
||||||
auto *Request =
|
auto *Request =
|
||||||
protobuf::Arena::CreateMessage<ExchangeDataAsync>(Arena.get());
|
protobuf::Arena::CreateMessage<ExchangeData>(Arena.get());
|
||||||
|
|
||||||
Request->set_src_dev_id(SrcDevId);
|
Request->set_src_dev_id(SrcDevId);
|
||||||
Request->set_src_ptr((uint64_t)SrcPtr);
|
Request->set_src_ptr((uint64_t)SrcPtr);
|
||||||
Request->set_dst_dev_id(DstDevId);
|
Request->set_dst_dev_id(DstDevId);
|
||||||
Request->set_dst_ptr((uint64_t)DstPtr);
|
Request->set_dst_ptr((uint64_t)DstPtr);
|
||||||
Request->set_size(Size);
|
Request->set_size(Size);
|
||||||
Request->set_queue_ptr((uint64_t)AsyncInfo);
|
|
||||||
|
|
||||||
CLIENT_DBG(
|
RPCStatus = Stub->DataExchange(&Context, *Request, Reply);
|
||||||
"Exchanging %ld bytes on device %d at %p for %p on device %d", Size,
|
|
||||||
SrcDevId, SrcPtr, DstPtr, DstDevId);
|
|
||||||
RPCStatus = Stub->DataExchangeAsync(&Context, *Request, Reply);
|
|
||||||
return Reply;
|
return Reply;
|
||||||
},
|
},
|
||||||
/* Postprocess */
|
/* Postprocessor */
|
||||||
[&](auto &Reply) {
|
[&](auto &Reply) {
|
||||||
if (Reply->number()) {
|
if (Reply->number()) {
|
||||||
CLIENT_DBG(
|
CLIENT_DBG(
|
||||||
"Exchanged %ld bytes on device %d at %p for %p on device %d",
|
"Exchanged %ld bytes on device %d at %p for %p on device %d",
|
||||||
Size, SrcDevId, SrcPtr, DstPtr, DstDevId);
|
Size, SrcDevId, SrcPtr, DstPtr, DstDevId)
|
||||||
} else {
|
} else {
|
||||||
CLIENT_DBG("Could not exchange %ld bytes on device %d at %p for %p "
|
CLIENT_DBG("Could not exchange %ld bytes on device %d at %p for %p "
|
||||||
"on device %d",
|
"on device %d",
|
||||||
Size, SrcDevId, SrcPtr, DstPtr, DstDevId);
|
Size, SrcDevId, SrcPtr, DstPtr, DstDevId)
|
||||||
}
|
}
|
||||||
return Reply->number();
|
return Reply->number();
|
||||||
},
|
},
|
||||||
|
@ -520,7 +459,7 @@ int32_t RemoteOffloadClient::dataExchangeAsync(int32_t SrcDevId, void *SrcPtr,
|
||||||
|
|
||||||
int32_t RemoteOffloadClient::dataDelete(int32_t DeviceId, void *TgtPtr) {
|
int32_t RemoteOffloadClient::dataDelete(int32_t DeviceId, void *TgtPtr) {
|
||||||
return remoteCall(
|
return remoteCall(
|
||||||
/* Preprocess */
|
/* Preprocessor */
|
||||||
[&](auto &RPCStatus, auto &Context) {
|
[&](auto &RPCStatus, auto &Context) {
|
||||||
auto *Reply = protobuf::Arena::CreateMessage<I32>(Arena.get());
|
auto *Reply = protobuf::Arena::CreateMessage<I32>(Arena.get());
|
||||||
auto *Request = protobuf::Arena::CreateMessage<DeleteData>(Arena.get());
|
auto *Request = protobuf::Arena::CreateMessage<DeleteData>(Arena.get());
|
||||||
|
@ -528,11 +467,10 @@ int32_t RemoteOffloadClient::dataDelete(int32_t DeviceId, void *TgtPtr) {
|
||||||
Request->set_device_id(DeviceId);
|
Request->set_device_id(DeviceId);
|
||||||
Request->set_tgt_ptr((uint64_t)TgtPtr);
|
Request->set_tgt_ptr((uint64_t)TgtPtr);
|
||||||
|
|
||||||
CLIENT_DBG("Deleting data at %p on device %d", TgtPtr, DeviceId)
|
|
||||||
RPCStatus = Stub->DataDelete(&Context, *Request, Reply);
|
RPCStatus = Stub->DataDelete(&Context, *Request, Reply);
|
||||||
return Reply;
|
return Reply;
|
||||||
},
|
},
|
||||||
/* Postprocess */
|
/* Postprocessor */
|
||||||
[&](auto &Reply) {
|
[&](auto &Reply) {
|
||||||
if (!Reply->number()) {
|
if (!Reply->number()) {
|
||||||
CLIENT_DBG("Deleted data at %p on device %d", TgtPtr, DeviceId)
|
CLIENT_DBG("Deleted data at %p on device %d", TgtPtr, DeviceId)
|
||||||
|
@ -545,18 +483,18 @@ int32_t RemoteOffloadClient::dataDelete(int32_t DeviceId, void *TgtPtr) {
|
||||||
/* Error Value */ -1);
|
/* Error Value */ -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t RemoteOffloadClient::runTargetRegionAsync(
|
int32_t RemoteOffloadClient::runTargetRegion(int32_t DeviceId,
|
||||||
int32_t DeviceId, void *TgtEntryPtr, void **TgtArgs, ptrdiff_t *TgtOffsets,
|
void *TgtEntryPtr, void **TgtArgs,
|
||||||
int32_t ArgNum, __tgt_async_info *AsyncInfo) {
|
ptrdiff_t *TgtOffsets,
|
||||||
|
int32_t ArgNum) {
|
||||||
return remoteCall(
|
return remoteCall(
|
||||||
/* Preprocess */
|
/* Preprocessor */
|
||||||
[&](auto &RPCStatus, auto &Context) {
|
[&](auto &RPCStatus, auto &Context) {
|
||||||
auto *Reply = protobuf::Arena::CreateMessage<I32>(Arena.get());
|
auto *Reply = protobuf::Arena::CreateMessage<I32>(Arena.get());
|
||||||
auto *Request =
|
auto *Request =
|
||||||
protobuf::Arena::CreateMessage<TargetRegionAsync>(Arena.get());
|
protobuf::Arena::CreateMessage<TargetRegion>(Arena.get());
|
||||||
|
|
||||||
Request->set_device_id(DeviceId);
|
Request->set_device_id(DeviceId);
|
||||||
Request->set_queue_ptr((uint64_t)AsyncInfo);
|
|
||||||
|
|
||||||
Request->set_tgt_entry_ptr(
|
Request->set_tgt_entry_ptr(
|
||||||
(uint64_t)RemoteEntries[DeviceId][TgtEntryPtr]);
|
(uint64_t)RemoteEntries[DeviceId][TgtEntryPtr]);
|
||||||
|
@ -571,37 +509,34 @@ int32_t RemoteOffloadClient::runTargetRegionAsync(
|
||||||
|
|
||||||
Request->set_arg_num(ArgNum);
|
Request->set_arg_num(ArgNum);
|
||||||
|
|
||||||
CLIENT_DBG("Running target region async on device %d", DeviceId);
|
RPCStatus = Stub->RunTargetRegion(&Context, *Request, Reply);
|
||||||
RPCStatus = Stub->RunTargetRegionAsync(&Context, *Request, Reply);
|
|
||||||
return Reply;
|
return Reply;
|
||||||
},
|
},
|
||||||
/* Postprocess */
|
/* Postprocessor */
|
||||||
[&](auto &Reply) {
|
[&](auto &Reply) {
|
||||||
if (!Reply->number()) {
|
if (!Reply->number()) {
|
||||||
CLIENT_DBG("Ran target region async on device %d", DeviceId);
|
CLIENT_DBG("Ran target region async on device %d", DeviceId)
|
||||||
} else {
|
} else {
|
||||||
CLIENT_DBG("Could not run target region async on device %d",
|
CLIENT_DBG("Could not run target region async on device %d", DeviceId)
|
||||||
DeviceId);
|
|
||||||
}
|
}
|
||||||
return Reply->number();
|
return Reply->number();
|
||||||
},
|
},
|
||||||
/* Error Value */ -1,
|
/* Error Value */ -1,
|
||||||
/* Timeout */ false);
|
/* CanTimeOut */ false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t RemoteOffloadClient::runTargetTeamRegionAsync(
|
int32_t RemoteOffloadClient::runTargetTeamRegion(
|
||||||
int32_t DeviceId, void *TgtEntryPtr, void **TgtArgs, ptrdiff_t *TgtOffsets,
|
int32_t DeviceId, void *TgtEntryPtr, void **TgtArgs, ptrdiff_t *TgtOffsets,
|
||||||
int32_t ArgNum, int32_t TeamNum, int32_t ThreadLimit,
|
int32_t ArgNum, int32_t TeamNum, int32_t ThreadLimit,
|
||||||
uint64_t LoopTripcount, __tgt_async_info *AsyncInfo) {
|
uint64_t LoopTripcount) {
|
||||||
return remoteCall(
|
return remoteCall(
|
||||||
/* Preprocess */
|
/* Preprocessor */
|
||||||
[&](auto &RPCStatus, auto &Context) {
|
[&](auto &RPCStatus, auto &Context) {
|
||||||
auto *Reply = protobuf::Arena::CreateMessage<I32>(Arena.get());
|
auto *Reply = protobuf::Arena::CreateMessage<I32>(Arena.get());
|
||||||
auto *Request =
|
auto *Request =
|
||||||
protobuf::Arena::CreateMessage<TargetTeamRegionAsync>(Arena.get());
|
protobuf::Arena::CreateMessage<TargetTeamRegion>(Arena.get());
|
||||||
|
|
||||||
Request->set_device_id(DeviceId);
|
Request->set_device_id(DeviceId);
|
||||||
Request->set_queue_ptr((uint64_t)AsyncInfo);
|
|
||||||
|
|
||||||
Request->set_tgt_entry_ptr(
|
Request->set_tgt_entry_ptr(
|
||||||
(uint64_t)RemoteEntries[DeviceId][TgtEntryPtr]);
|
(uint64_t)RemoteEntries[DeviceId][TgtEntryPtr]);
|
||||||
|
@ -620,25 +555,23 @@ int32_t RemoteOffloadClient::runTargetTeamRegionAsync(
|
||||||
Request->set_thread_limit(ThreadLimit);
|
Request->set_thread_limit(ThreadLimit);
|
||||||
Request->set_loop_tripcount(LoopTripcount);
|
Request->set_loop_tripcount(LoopTripcount);
|
||||||
|
|
||||||
CLIENT_DBG("Running target team region async on device %d", DeviceId);
|
RPCStatus = Stub->RunTargetTeamRegion(&Context, *Request, Reply);
|
||||||
RPCStatus = Stub->RunTargetTeamRegionAsync(&Context, *Request, Reply);
|
|
||||||
return Reply;
|
return Reply;
|
||||||
},
|
},
|
||||||
/* Postprocess */
|
/* Postprocessor */
|
||||||
[&](auto &Reply) {
|
[&](auto &Reply) {
|
||||||
if (!Reply->number()) {
|
if (!Reply->number()) {
|
||||||
CLIENT_DBG("Ran target team region async on device %d", DeviceId);
|
CLIENT_DBG("Ran target team region async on device %d", DeviceId)
|
||||||
} else {
|
} else {
|
||||||
CLIENT_DBG("Could not run target team region async on device %d",
|
CLIENT_DBG("Could not run target team region async on device %d",
|
||||||
DeviceId);
|
DeviceId)
|
||||||
}
|
}
|
||||||
return Reply->number();
|
return Reply->number();
|
||||||
},
|
},
|
||||||
/* Error Value */ -1,
|
/* Error Value */ -1,
|
||||||
/* Timeout */ false);
|
/* CanTimeOut */ false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Better error handling for the next three functions
|
|
||||||
int32_t RemoteClientManager::shutdown(void) {
|
int32_t RemoteClientManager::shutdown(void) {
|
||||||
int32_t Ret = 0;
|
int32_t Ret = 0;
|
||||||
for (auto &Client : Clients)
|
for (auto &Client : Clients)
|
||||||
|
@ -684,7 +617,7 @@ int32_t RemoteClientManager::getNumberOfDevices() {
|
||||||
|
|
||||||
std::pair<int32_t, int32_t> RemoteClientManager::mapDeviceId(int32_t DeviceId) {
|
std::pair<int32_t, int32_t> RemoteClientManager::mapDeviceId(int32_t DeviceId) {
|
||||||
for (size_t ClientIdx = 0; ClientIdx < Devices.size(); ClientIdx++) {
|
for (size_t ClientIdx = 0; ClientIdx < Devices.size(); ClientIdx++) {
|
||||||
if (!(DeviceId >= Devices[ClientIdx]))
|
if (DeviceId < Devices[ClientIdx])
|
||||||
return {ClientIdx, DeviceId};
|
return {ClientIdx, DeviceId};
|
||||||
DeviceId -= Devices[ClientIdx];
|
DeviceId -= Devices[ClientIdx];
|
||||||
}
|
}
|
||||||
|
@ -711,13 +644,6 @@ __tgt_target_table *RemoteClientManager::loadBinary(int32_t DeviceId,
|
||||||
return Clients[ClientIdx].loadBinary(DeviceIdx, Image);
|
return Clients[ClientIdx].loadBinary(DeviceIdx, Image);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t RemoteClientManager::synchronize(int32_t DeviceId,
|
|
||||||
__tgt_async_info *AsyncInfo) {
|
|
||||||
int32_t ClientIdx, DeviceIdx;
|
|
||||||
std::tie(ClientIdx, DeviceIdx) = mapDeviceId(DeviceId);
|
|
||||||
return Clients[ClientIdx].synchronize(DeviceIdx, AsyncInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t RemoteClientManager::isDataExchangeable(int32_t SrcDevId,
|
int32_t RemoteClientManager::isDataExchangeable(int32_t SrcDevId,
|
||||||
int32_t DstDevId) {
|
int32_t DstDevId) {
|
||||||
int32_t SrcClientIdx, SrcDeviceIdx, DstClientIdx, DstDeviceIdx;
|
int32_t SrcClientIdx, SrcDeviceIdx, DstClientIdx, DstDeviceIdx;
|
||||||
|
@ -739,51 +665,47 @@ int32_t RemoteClientManager::dataDelete(int32_t DeviceId, void *TgtPtr) {
|
||||||
return Clients[ClientIdx].dataDelete(DeviceIdx, TgtPtr);
|
return Clients[ClientIdx].dataDelete(DeviceIdx, TgtPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t RemoteClientManager::dataSubmitAsync(int32_t DeviceId, void *TgtPtr,
|
int32_t RemoteClientManager::dataSubmit(int32_t DeviceId, void *TgtPtr,
|
||||||
void *HstPtr, int64_t Size,
|
void *HstPtr, int64_t Size) {
|
||||||
__tgt_async_info *AsyncInfo) {
|
|
||||||
int32_t ClientIdx, DeviceIdx;
|
int32_t ClientIdx, DeviceIdx;
|
||||||
std::tie(ClientIdx, DeviceIdx) = mapDeviceId(DeviceId);
|
std::tie(ClientIdx, DeviceIdx) = mapDeviceId(DeviceId);
|
||||||
return Clients[ClientIdx].dataSubmitAsync(DeviceIdx, TgtPtr, HstPtr, Size,
|
return Clients[ClientIdx].dataSubmit(DeviceIdx, TgtPtr, HstPtr, Size);
|
||||||
AsyncInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t RemoteClientManager::dataRetrieveAsync(int32_t DeviceId, void *HstPtr,
|
int32_t RemoteClientManager::dataRetrieve(int32_t DeviceId, void *HstPtr,
|
||||||
void *TgtPtr, int64_t Size,
|
void *TgtPtr, int64_t Size) {
|
||||||
__tgt_async_info *AsyncInfo) {
|
|
||||||
int32_t ClientIdx, DeviceIdx;
|
int32_t ClientIdx, DeviceIdx;
|
||||||
std::tie(ClientIdx, DeviceIdx) = mapDeviceId(DeviceId);
|
std::tie(ClientIdx, DeviceIdx) = mapDeviceId(DeviceId);
|
||||||
return Clients[ClientIdx].dataRetrieveAsync(DeviceIdx, HstPtr, TgtPtr, Size,
|
return Clients[ClientIdx].dataRetrieve(DeviceIdx, HstPtr, TgtPtr, Size);
|
||||||
AsyncInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t RemoteClientManager::dataExchangeAsync(int32_t SrcDevId, void *SrcPtr,
|
int32_t RemoteClientManager::dataExchange(int32_t SrcDevId, void *SrcPtr,
|
||||||
int32_t DstDevId, void *DstPtr,
|
int32_t DstDevId, void *DstPtr,
|
||||||
int64_t Size,
|
int64_t Size) {
|
||||||
__tgt_async_info *AsyncInfo) {
|
|
||||||
int32_t SrcClientIdx, SrcDeviceIdx, DstClientIdx, DstDeviceIdx;
|
int32_t SrcClientIdx, SrcDeviceIdx, DstClientIdx, DstDeviceIdx;
|
||||||
std::tie(SrcClientIdx, SrcDeviceIdx) = mapDeviceId(SrcDevId);
|
std::tie(SrcClientIdx, SrcDeviceIdx) = mapDeviceId(SrcDevId);
|
||||||
std::tie(DstClientIdx, DstDeviceIdx) = mapDeviceId(DstDevId);
|
std::tie(DstClientIdx, DstDeviceIdx) = mapDeviceId(DstDevId);
|
||||||
return Clients[SrcClientIdx].dataExchangeAsync(
|
return Clients[SrcClientIdx].dataExchange(SrcDeviceIdx, SrcPtr, DstDeviceIdx,
|
||||||
SrcDeviceIdx, SrcPtr, DstDeviceIdx, DstPtr, Size, AsyncInfo);
|
DstPtr, Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t RemoteClientManager::runTargetRegionAsync(
|
int32_t RemoteClientManager::runTargetRegion(int32_t DeviceId,
|
||||||
int32_t DeviceId, void *TgtEntryPtr, void **TgtArgs, ptrdiff_t *TgtOffsets,
|
void *TgtEntryPtr, void **TgtArgs,
|
||||||
int32_t ArgNum, __tgt_async_info *AsyncInfo) {
|
ptrdiff_t *TgtOffsets,
|
||||||
|
int32_t ArgNum) {
|
||||||
int32_t ClientIdx, DeviceIdx;
|
int32_t ClientIdx, DeviceIdx;
|
||||||
std::tie(ClientIdx, DeviceIdx) = mapDeviceId(DeviceId);
|
std::tie(ClientIdx, DeviceIdx) = mapDeviceId(DeviceId);
|
||||||
return Clients[ClientIdx].runTargetRegionAsync(
|
return Clients[ClientIdx].runTargetRegion(DeviceIdx, TgtEntryPtr, TgtArgs,
|
||||||
DeviceIdx, TgtEntryPtr, TgtArgs, TgtOffsets, ArgNum, AsyncInfo);
|
TgtOffsets, ArgNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t RemoteClientManager::runTargetTeamRegionAsync(
|
int32_t RemoteClientManager::runTargetTeamRegion(
|
||||||
int32_t DeviceId, void *TgtEntryPtr, void **TgtArgs, ptrdiff_t *TgtOffsets,
|
int32_t DeviceId, void *TgtEntryPtr, void **TgtArgs, ptrdiff_t *TgtOffsets,
|
||||||
int32_t ArgNum, int32_t TeamNum, int32_t ThreadLimit,
|
int32_t ArgNum, int32_t TeamNum, int32_t ThreadLimit,
|
||||||
uint64_t LoopTripCount, __tgt_async_info *AsyncInfo) {
|
uint64_t LoopTripCount) {
|
||||||
int32_t ClientIdx, DeviceIdx;
|
int32_t ClientIdx, DeviceIdx;
|
||||||
std::tie(ClientIdx, DeviceIdx) = mapDeviceId(DeviceId);
|
std::tie(ClientIdx, DeviceIdx) = mapDeviceId(DeviceId);
|
||||||
return Clients[ClientIdx].runTargetTeamRegionAsync(
|
return Clients[ClientIdx].runTargetTeamRegion(DeviceIdx, TgtEntryPtr, TgtArgs,
|
||||||
DeviceIdx, TgtEntryPtr, TgtArgs, TgtOffsets, ArgNum, TeamNum, ThreadLimit,
|
TgtOffsets, ArgNum, TeamNum,
|
||||||
LoopTripCount, AsyncInfo);
|
ThreadLimit, LoopTripCount);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,11 +30,10 @@ using namespace RemoteOffloading;
|
||||||
using namespace google;
|
using namespace google;
|
||||||
|
|
||||||
class RemoteOffloadClient {
|
class RemoteOffloadClient {
|
||||||
const int Timeout;
|
|
||||||
|
|
||||||
int DebugLevel;
|
int DebugLevel;
|
||||||
uint64_t MaxSize;
|
const int Timeout;
|
||||||
int64_t BlockSize;
|
const uint64_t MaxSize;
|
||||||
|
const int64_t BlockSize;
|
||||||
|
|
||||||
std::unique_ptr<RemoteOffload::Stub> Stub;
|
std::unique_ptr<RemoteOffload::Stub> Stub;
|
||||||
std::unique_ptr<protobuf::Arena> Arena;
|
std::unique_ptr<protobuf::Arena> Arena;
|
||||||
|
@ -45,8 +44,8 @@ class RemoteOffloadClient {
|
||||||
std::map<int32_t, std::unique_ptr<__tgt_target_table>> DevicesToTables;
|
std::map<int32_t, std::unique_ptr<__tgt_target_table>> DevicesToTables;
|
||||||
|
|
||||||
template <typename Fn1, typename Fn2, typename TReturn>
|
template <typename Fn1, typename Fn2, typename TReturn>
|
||||||
auto remoteCall(Fn1 Preprocess, Fn2 Postprocess, TReturn ErrorValue,
|
auto remoteCall(Fn1 Preprocessor, Fn2 Postprocessor, TReturn ErrorValue,
|
||||||
bool Timeout = true);
|
bool CanTimeOut = true);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RemoteOffloadClient(std::shared_ptr<Channel> Channel, int Timeout,
|
RemoteOffloadClient(std::shared_ptr<Channel> Channel, int Timeout,
|
||||||
|
@ -77,35 +76,29 @@ public:
|
||||||
int32_t initRequires(int64_t RequiresFlags);
|
int32_t initRequires(int64_t RequiresFlags);
|
||||||
|
|
||||||
__tgt_target_table *loadBinary(int32_t DeviceId, __tgt_device_image *Image);
|
__tgt_target_table *loadBinary(int32_t DeviceId, __tgt_device_image *Image);
|
||||||
int64_t synchronize(int32_t DeviceId, __tgt_async_info *AsyncInfo);
|
|
||||||
int32_t isDataExchangeable(int32_t SrcDevId, int32_t DstDevId);
|
|
||||||
|
|
||||||
void *dataAlloc(int32_t DeviceId, int64_t Size, void *HstPtr);
|
void *dataAlloc(int32_t DeviceId, int64_t Size, void *HstPtr);
|
||||||
int32_t dataDelete(int32_t DeviceId, void *TgtPtr);
|
int32_t dataDelete(int32_t DeviceId, void *TgtPtr);
|
||||||
|
|
||||||
int32_t dataSubmitAsync(int32_t DeviceId, void *TgtPtr, void *HstPtr,
|
int32_t dataSubmit(int32_t DeviceId, void *TgtPtr, void *HstPtr,
|
||||||
int64_t Size, __tgt_async_info *AsyncInfo);
|
int64_t Size);
|
||||||
int32_t dataRetrieveAsync(int32_t DeviceId, void *HstPtr, void *TgtPtr,
|
int32_t dataRetrieve(int32_t DeviceId, void *HstPtr, void *TgtPtr,
|
||||||
int64_t Size, __tgt_async_info *AsyncInfo);
|
int64_t Size);
|
||||||
|
|
||||||
int32_t dataExchangeAsync(int32_t SrcDevId, void *SrcPtr, int32_t DstDevId,
|
int32_t isDataExchangeable(int32_t SrcDevId, int32_t DstDevId);
|
||||||
void *DstPtr, int64_t Size,
|
int32_t dataExchange(int32_t SrcDevId, void *SrcPtr, int32_t DstDevId,
|
||||||
__tgt_async_info *AsyncInfo);
|
void *DstPtr, int64_t Size);
|
||||||
|
|
||||||
int32_t runTargetRegionAsync(int32_t DeviceId, void *TgtEntryPtr,
|
int32_t runTargetRegion(int32_t DeviceId, void *TgtEntryPtr, void **TgtArgs,
|
||||||
void **TgtArgs, ptrdiff_t *TgtOffsets,
|
ptrdiff_t *TgtOffsets, int32_t ArgNum);
|
||||||
int32_t ArgNum, __tgt_async_info *AsyncInfo);
|
int32_t runTargetTeamRegion(int32_t DeviceId, void *TgtEntryPtr,
|
||||||
|
void **TgtArgs, ptrdiff_t *TgtOffsets,
|
||||||
int32_t runTargetTeamRegionAsync(int32_t DeviceId, void *TgtEntryPtr,
|
int32_t ArgNum, int32_t TeamNum,
|
||||||
void **TgtArgs, ptrdiff_t *TgtOffsets,
|
int32_t ThreadLimit, uint64_t LoopTripCount);
|
||||||
int32_t ArgNum, int32_t TeamNum,
|
|
||||||
int32_t ThreadLimit, uint64_t LoopTripCount,
|
|
||||||
__tgt_async_info *AsyncInfo);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class RemoteClientManager {
|
class RemoteClientManager {
|
||||||
private:
|
private:
|
||||||
std::vector<std::string> Addresses;
|
|
||||||
std::vector<RemoteOffloadClient> Clients;
|
std::vector<RemoteOffloadClient> Clients;
|
||||||
std::vector<int> Devices;
|
std::vector<int> Devices;
|
||||||
|
|
||||||
|
@ -113,16 +106,16 @@ private:
|
||||||
int DebugLevel;
|
int DebugLevel;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RemoteClientManager(std::vector<std::string> Addresses, int Timeout,
|
RemoteClientManager() {
|
||||||
uint64_t MaxSize, int64_t BlockSize)
|
ClientManagerConfigTy Config;
|
||||||
: Addresses(Addresses) {
|
|
||||||
grpc::ChannelArguments ChArgs;
|
grpc::ChannelArguments ChArgs;
|
||||||
ChArgs.SetMaxReceiveMessageSize(-1);
|
ChArgs.SetMaxReceiveMessageSize(-1);
|
||||||
DebugLevel = getDebugLevel();
|
DebugLevel = getDebugLevel();
|
||||||
for (auto Address : Addresses) {
|
for (auto Address : Config.ServerAddresses) {
|
||||||
Clients.push_back(RemoteOffloadClient(
|
Clients.push_back(RemoteOffloadClient(
|
||||||
grpc::CreateChannel(Address, grpc::InsecureChannelCredentials()),
|
grpc::CreateChannel(Address, grpc::InsecureChannelCredentials()),
|
||||||
Timeout, MaxSize, BlockSize));
|
Config.Timeout, Config.MaxSize, Config.BlockSize));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,30 +131,25 @@ public:
|
||||||
int32_t initRequires(int64_t RequiresFlags);
|
int32_t initRequires(int64_t RequiresFlags);
|
||||||
|
|
||||||
__tgt_target_table *loadBinary(int32_t DeviceId, __tgt_device_image *Image);
|
__tgt_target_table *loadBinary(int32_t DeviceId, __tgt_device_image *Image);
|
||||||
int64_t synchronize(int32_t DeviceId, __tgt_async_info *AsyncInfo);
|
|
||||||
int32_t isDataExchangeable(int32_t SrcDevId, int32_t DstDevId);
|
|
||||||
|
|
||||||
void *dataAlloc(int32_t DeviceId, int64_t Size, void *HstPtr);
|
void *dataAlloc(int32_t DeviceId, int64_t Size, void *HstPtr);
|
||||||
int32_t dataDelete(int32_t DeviceId, void *TgtPtr);
|
int32_t dataDelete(int32_t DeviceId, void *TgtPtr);
|
||||||
|
|
||||||
int32_t dataSubmitAsync(int32_t DeviceId, void *TgtPtr, void *HstPtr,
|
int32_t dataSubmit(int32_t DeviceId, void *TgtPtr, void *HstPtr,
|
||||||
int64_t Size, __tgt_async_info *AsyncInfo);
|
int64_t Size);
|
||||||
int32_t dataRetrieveAsync(int32_t DeviceId, void *HstPtr, void *TgtPtr,
|
int32_t dataRetrieve(int32_t DeviceId, void *HstPtr, void *TgtPtr,
|
||||||
int64_t Size, __tgt_async_info *AsyncInfo);
|
int64_t Size);
|
||||||
|
|
||||||
int32_t dataExchangeAsync(int32_t SrcDevId, void *SrcPtr, int32_t DstDevId,
|
int32_t isDataExchangeable(int32_t SrcDevId, int32_t DstDevId);
|
||||||
void *DstPtr, int64_t Size,
|
int32_t dataExchange(int32_t SrcDevId, void *SrcPtr, int32_t DstDevId,
|
||||||
__tgt_async_info *AsyncInfo);
|
void *DstPtr, int64_t Size);
|
||||||
|
|
||||||
int32_t runTargetRegionAsync(int32_t DeviceId, void *TgtEntryPtr,
|
int32_t runTargetRegion(int32_t DeviceId, void *TgtEntryPtr, void **TgtArgs,
|
||||||
void **TgtArgs, ptrdiff_t *TgtOffsets,
|
ptrdiff_t *TgtOffsets, int32_t ArgNum);
|
||||||
int32_t ArgNum, __tgt_async_info *AsyncInfo);
|
int32_t runTargetTeamRegion(int32_t DeviceId, void *TgtEntryPtr,
|
||||||
|
void **TgtArgs, ptrdiff_t *TgtOffsets,
|
||||||
int32_t runTargetTeamRegionAsync(int32_t DeviceId, void *TgtEntryPtr,
|
int32_t ArgNum, int32_t TeamNum,
|
||||||
void **TgtArgs, ptrdiff_t *TgtOffsets,
|
int32_t ThreadLimit, uint64_t LoopTripCount);
|
||||||
int32_t ArgNum, int32_t TeamNum,
|
|
||||||
int32_t ThreadLimit, uint64_t LoopTripCount,
|
|
||||||
__tgt_async_info *AsyncInfo);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -27,15 +27,7 @@ RemoteClientManager *Manager;
|
||||||
__attribute__((constructor(101))) void initRPC() {
|
__attribute__((constructor(101))) void initRPC() {
|
||||||
DP("Init RPC library!\n");
|
DP("Init RPC library!\n");
|
||||||
|
|
||||||
RPCConfig Config;
|
Manager = new RemoteClientManager();
|
||||||
parseEnvironment(Config);
|
|
||||||
|
|
||||||
int Timeout = 5;
|
|
||||||
if (const char *Env1 = std::getenv("LIBOMPTARGET_RPC_LATENCY"))
|
|
||||||
Timeout = std::stoi(Env1);
|
|
||||||
|
|
||||||
Manager = new RemoteClientManager(Config.ServerAddresses, Timeout,
|
|
||||||
Config.MaxSize, Config.BlockSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((destructor(101))) void deinitRPC() {
|
__attribute__((destructor(101))) void deinitRPC() {
|
||||||
|
@ -76,17 +68,13 @@ __tgt_target_table *__tgt_rtl_load_binary(int32_t DeviceId,
|
||||||
return Manager->loadBinary(DeviceId, (__tgt_device_image *)Image);
|
return Manager->loadBinary(DeviceId, (__tgt_device_image *)Image);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t __tgt_rtl_synchronize(int32_t DeviceId, __tgt_async_info *AsyncInfo) {
|
|
||||||
return Manager->synchronize(DeviceId, AsyncInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t __tgt_rtl_is_data_exchangable(int32_t SrcDevId, int32_t DstDevId) {
|
int32_t __tgt_rtl_is_data_exchangable(int32_t SrcDevId, int32_t DstDevId) {
|
||||||
return Manager->isDataExchangeable(SrcDevId, DstDevId);
|
return Manager->isDataExchangeable(SrcDevId, DstDevId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *__tgt_rtl_data_alloc(int32_t DeviceId, int64_t Size, void *HstPtr,
|
void *__tgt_rtl_data_alloc(int32_t DeviceId, int64_t Size, void *HstPtr,
|
||||||
int32_t kind) {
|
int32_t Kind) {
|
||||||
if (kind != TARGET_ALLOC_DEFAULT) {
|
if (Kind != TARGET_ALLOC_DEFAULT) {
|
||||||
REPORT("Invalid target data allocation kind or requested allocator not "
|
REPORT("Invalid target data allocation kind or requested allocator not "
|
||||||
"implemented yet\n");
|
"implemented yet\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -97,24 +85,12 @@ void *__tgt_rtl_data_alloc(int32_t DeviceId, int64_t Size, void *HstPtr,
|
||||||
|
|
||||||
int32_t __tgt_rtl_data_submit(int32_t DeviceId, void *TgtPtr, void *HstPtr,
|
int32_t __tgt_rtl_data_submit(int32_t DeviceId, void *TgtPtr, void *HstPtr,
|
||||||
int64_t Size) {
|
int64_t Size) {
|
||||||
return Manager->dataSubmitAsync(DeviceId, TgtPtr, HstPtr, Size, nullptr);
|
return Manager->dataSubmit(DeviceId, TgtPtr, HstPtr, Size);
|
||||||
}
|
|
||||||
|
|
||||||
int32_t __tgt_rtl_data_submit_async(int32_t DeviceId, void *TgtPtr,
|
|
||||||
void *HstPtr, int64_t Size,
|
|
||||||
__tgt_async_info *AsyncInfo) {
|
|
||||||
return Manager->dataSubmitAsync(DeviceId, TgtPtr, HstPtr, Size, AsyncInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t __tgt_rtl_data_retrieve(int32_t DeviceId, void *HstPtr, void *TgtPtr,
|
int32_t __tgt_rtl_data_retrieve(int32_t DeviceId, void *HstPtr, void *TgtPtr,
|
||||||
int64_t Size) {
|
int64_t Size) {
|
||||||
return Manager->dataRetrieveAsync(DeviceId, HstPtr, TgtPtr, Size, nullptr);
|
return Manager->dataRetrieve(DeviceId, HstPtr, TgtPtr, Size);
|
||||||
}
|
|
||||||
|
|
||||||
int32_t __tgt_rtl_data_retrieve_async(int32_t DeviceId, void *HstPtr,
|
|
||||||
void *TgtPtr, int64_t Size,
|
|
||||||
__tgt_async_info *AsyncInfo) {
|
|
||||||
return Manager->dataRetrieveAsync(DeviceId, HstPtr, TgtPtr, Size, AsyncInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t __tgt_rtl_data_delete(int32_t DeviceId, void *TgtPtr) {
|
int32_t __tgt_rtl_data_delete(int32_t DeviceId, void *TgtPtr) {
|
||||||
|
@ -123,31 +99,15 @@ int32_t __tgt_rtl_data_delete(int32_t DeviceId, void *TgtPtr) {
|
||||||
|
|
||||||
int32_t __tgt_rtl_data_exchange(int32_t SrcDevId, void *SrcPtr,
|
int32_t __tgt_rtl_data_exchange(int32_t SrcDevId, void *SrcPtr,
|
||||||
int32_t DstDevId, void *DstPtr, int64_t Size) {
|
int32_t DstDevId, void *DstPtr, int64_t Size) {
|
||||||
return Manager->dataExchangeAsync(SrcDevId, SrcPtr, DstDevId, DstPtr, Size,
|
return Manager->dataExchange(SrcDevId, SrcPtr, DstDevId, DstPtr, Size);
|
||||||
nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t __tgt_rtl_data_exchange_async(int32_t SrcDevId, void *SrcPtr,
|
|
||||||
int32_t DstDevId, void *DstPtr,
|
|
||||||
int64_t Size,
|
|
||||||
__tgt_async_info *AsyncInfo) {
|
|
||||||
return Manager->dataExchangeAsync(SrcDevId, SrcPtr, DstDevId, DstPtr, Size,
|
|
||||||
AsyncInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t __tgt_rtl_run_target_region(int32_t DeviceId, void *TgtEntryPtr,
|
int32_t __tgt_rtl_run_target_region(int32_t DeviceId, void *TgtEntryPtr,
|
||||||
void **TgtArgs, ptrdiff_t *TgtOffsets,
|
void **TgtArgs, ptrdiff_t *TgtOffsets,
|
||||||
int32_t ArgNum) {
|
int32_t ArgNum) {
|
||||||
return Manager->runTargetRegionAsync(DeviceId, TgtEntryPtr, TgtArgs,
|
return Manager->runTargetRegion(DeviceId, TgtEntryPtr, TgtArgs, TgtOffsets,
|
||||||
TgtOffsets, ArgNum, nullptr);
|
ArgNum);
|
||||||
}
|
|
||||||
|
|
||||||
int32_t __tgt_rtl_run_target_region_async(int32_t DeviceId, void *TgtEntryPtr,
|
|
||||||
void **TgtArgs, ptrdiff_t *TgtOffsets,
|
|
||||||
int32_t ArgNum,
|
|
||||||
__tgt_async_info *AsyncInfo) {
|
|
||||||
return Manager->runTargetRegionAsync(DeviceId, TgtEntryPtr, TgtArgs,
|
|
||||||
TgtOffsets, ArgNum, AsyncInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t __tgt_rtl_run_target_team_region(int32_t DeviceId, void *TgtEntryPtr,
|
int32_t __tgt_rtl_run_target_team_region(int32_t DeviceId, void *TgtEntryPtr,
|
||||||
|
@ -155,18 +115,9 @@ int32_t __tgt_rtl_run_target_team_region(int32_t DeviceId, void *TgtEntryPtr,
|
||||||
int32_t ArgNum, int32_t TeamNum,
|
int32_t ArgNum, int32_t TeamNum,
|
||||||
int32_t ThreadLimit,
|
int32_t ThreadLimit,
|
||||||
uint64_t LoopTripCount) {
|
uint64_t LoopTripCount) {
|
||||||
return Manager->runTargetTeamRegionAsync(DeviceId, TgtEntryPtr, TgtArgs,
|
return Manager->runTargetTeamRegion(DeviceId, TgtEntryPtr, TgtArgs,
|
||||||
TgtOffsets, ArgNum, TeamNum,
|
TgtOffsets, ArgNum, TeamNum, ThreadLimit,
|
||||||
ThreadLimit, LoopTripCount, nullptr);
|
LoopTripCount);
|
||||||
}
|
|
||||||
|
|
||||||
int32_t __tgt_rtl_run_target_team_region_async(
|
|
||||||
int32_t DeviceId, void *TgtEntryPtr, void **TgtArgs, ptrdiff_t *TgtOffsets,
|
|
||||||
int32_t ArgNum, int32_t TeamNum, int32_t ThreadLimit,
|
|
||||||
uint64_t LoopTripCount, __tgt_async_info *AsyncInfo) {
|
|
||||||
return Manager->runTargetTeamRegionAsync(
|
|
||||||
DeviceId, TgtEntryPtr, TgtArgs, TgtOffsets, ArgNum, TeamNum, ThreadLimit,
|
|
||||||
LoopTripCount, AsyncInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exposed library API function
|
// Exposed library API function
|
||||||
|
|
Loading…
Reference in New Issue