Skip to content

Commit

Permalink
Try to introduce the GPU-P support. (Suggested by Z841973620.)
Browse files Browse the repository at this point in the history
  • Loading branch information
MouriNaruto committed Jul 4, 2024
1 parent 4f8d4bd commit c8fd7a1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
38 changes: 30 additions & 8 deletions NanaBox/ConfigurationManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,9 +605,10 @@ void NanaBox::ComputeSystemUpdateGpu(
{
Result["Settings"]["AssignmentMode"] = "List";
nlohmann::json Devices;
for (std::string const& Device : Configuration.SelectedDevices)
for (std::pair<std::string, std::uint16_t> const& Device
: Configuration.SelectedDevices)
{
Devices[Device] = 0xffff;
Devices[Device.first] = Device.second;
}
Result["Settings"]["AssignmentRequest"] = Devices;
}
Expand Down Expand Up @@ -1405,11 +1406,22 @@ NanaBox::VirtualMachineConfiguration NanaBox::DeserializeConfiguration(
for (nlohmann::json const& SelectedDevice : Mile::Json::ToArray(
Mile::Json::GetSubKey(Gpu, "SelectedDevices")))
{
std::string SelectedDeviceString =
Mile::Json::ToString(SelectedDevice);
if (!SelectedDeviceString.empty())
std::string DeviceInterface = Mile::Json::ToString(SelectedDevice);
if (!DeviceInterface.empty())
{
Result.Gpu.SelectedDevices.push_back(SelectedDeviceString);
Result.Gpu.SelectedDevices[DeviceInterface] = 0xFFFF;
}
else
{
DeviceInterface = Mile::Json::ToString(
Mile::Json::GetSubKey(SelectedDevice, "DeviceInterface"));
if (!DeviceInterface.empty())
{
Result.Gpu.SelectedDevices[DeviceInterface] =
static_cast<std::uint16_t>(
Mile::Json::ToUInt64(Mile::Json::GetSubKey(
SelectedDevice, "PartitionId")));
}
}
}

Expand Down Expand Up @@ -1545,10 +1557,20 @@ std::string NanaBox::SerializeConfiguration(
if (!Configuration.Gpu.SelectedDevices.empty())
{
nlohmann::json SelectedDevices;
for (std::string const& SelectedDevice
for (std::pair<std::string, std::uint16_t> const& SelectedDevice
: Configuration.Gpu.SelectedDevices)
{
SelectedDevices.push_back(SelectedDevice);
if (0xFFFF == SelectedDevice.second)
{
SelectedDevices.push_back(SelectedDevice.first);
}
else
{
nlohmann::json Current;
Current["DeviceInterface"] = SelectedDevice.first;
Current["PartitionId"] = SelectedDevice.second;
SelectedDevices.push_back(Current);
}
}
Gpu["SelectedDevices"] = SelectedDevices;
}
Expand Down
3 changes: 2 additions & 1 deletion NanaBox/ConfigurationSpecification.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <Windows.h>

#include <cstdint>
#include <map>
#include <string>
#include <vector>

Expand Down Expand Up @@ -66,7 +67,7 @@ namespace NanaBox
{
GpuAssignmentMode AssignmentMode = GpuAssignmentMode::Disabled;
bool EnableHostDriverStore = false;
std::vector<std::string> SelectedDevices;
std::map<std::string, std::uint16_t> SelectedDevices;
};

struct NetworkAdapterConfiguration
Expand Down

0 comments on commit c8fd7a1

Please sign in to comment.