P4 to Git Change 2014404 by gandryey@gera-win10 on 2019/10/16 11:13:37

SWDEV-184710 - Support hipLaunchCooperativeKernelMultiDevice()
	- Add support for multi grid launch in hip
	- Detect the new hidden argument and pass the required information for the kernel launch
	- Memory for synchronization is allocated as a single object and then the offset for each GPU is found

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/hip/hip_module.cpp#44 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#343 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/devkernel.cpp#25 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/devkernel.hpp#17 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palkernel.cpp#82 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#136 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.hpp#42 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocvirtual.cpp#90 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocvirtual.hpp#30 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/command.cpp#99 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/command.hpp#97 edit


[ROCm/clr commit: 6e7e97987f]
This commit is contained in:
foreman
2019-10-16 11:24:09 -04:00
parent f49169e681
commit fb7da41d27
10 changed files with 151 additions and 52 deletions
@@ -232,12 +232,19 @@ const Context& Command::context() const { return queue_->context(); }
NDRangeKernelCommand::NDRangeKernelCommand(HostQueue& queue, const EventWaitList& eventWaitList,
Kernel& kernel, const NDRangeContainer& sizes,
uint32_t sharedMemBytes, uint32_t extraParam)
: Command(queue, CL_COMMAND_NDRANGE_KERNEL, eventWaitList, AMD_SERIALIZE_KERNEL)
, kernel_(kernel)
, sizes_(sizes)
, sharedMemBytes_(sharedMemBytes)
, extraParam_(extraParam) {
uint32_t sharedMemBytes, uint32_t extraParam,
uint32_t gridId, uint32_t numGrids,
uint64_t prevGridSum, uint64_t allGridSum, uint32_t firstDevice) :
Command(queue, CL_COMMAND_NDRANGE_KERNEL, eventWaitList, AMD_SERIALIZE_KERNEL),
kernel_(kernel),
sizes_(sizes),
sharedMemBytes_(sharedMemBytes),
extraParam_(extraParam),
gridId_(gridId),
numGrids_(numGrids),
prevGridSum_(prevGridSum),
allGridSum_(allGridSum),
firstDevice_(firstDevice) {
auto& device = queue.device();
auto devKernel = const_cast<device::Kernel*>(kernel.getDeviceKernel(device));
profilingInfo_.setCallback(devKernel->getProfilingCallback(
@@ -764,9 +764,15 @@ class NDRangeKernelCommand : public Command {
private:
Kernel& kernel_;
NDRangeContainer sizes_;
address parameters_;
uint32_t sharedMemBytes_;
uint32_t extraParam_;
address parameters_; //!< Pointer to the kernel argumets
// The below fields are specific to the HIP functionality
uint32_t sharedMemBytes_; //!< Size of reserved shared memory
uint32_t extraParam_; //!< Extra flags for the kernel launch
uint32_t gridId_; //!< Grid ID in the multi GPU kernel launch
uint32_t numGrids_; //!< Total number of grids in multi GPU launch
uint64_t prevGridSum_; //!< A sum of previous grids to the current launch
uint64_t allGridSum_; //!< A sum of all grids in multi GPU launch
uint32_t firstDevice_; //!< Device index of the first device in the grid
public:
enum {
@@ -777,7 +783,8 @@ class NDRangeKernelCommand : public Command {
//! Construct an ExecuteKernel command
NDRangeKernelCommand(HostQueue& queue, const EventWaitList& eventWaitList, Kernel& kernel,
const NDRangeContainer& sizes, uint32_t sharedMemBytes = 0,
uint32_t extraParam = 0);
uint32_t extraParam = 0, uint32_t gridId = 0, uint32_t numGrids = 0,
uint64_t prevGridSum = 0, uint64_t allGridSum = 0, uint32_t firstDevice = 0);
virtual void submit(device::VirtualDevice& device) { device.submitKernel(*this); }
@@ -804,6 +811,21 @@ class NDRangeKernelCommand : public Command {
return (extraParam_ & CooperativeMultiDeviceGroups) ? true : false;
}
//! Return the current grid ID for multidevice launch
uint32_t gridId() const { return gridId_; }
//! Return the number of launched grids
uint32_t numGrids() const { return numGrids_; }
//! Return the total workload size for up to the current
uint64_t prevGridSum() const { return prevGridSum_; }
//! Return the total workload size for all GPUs
uint64_t allGridSum() const { return allGridSum_; }
//! Return the index of the first device in multi GPU launch
uint64_t firstDevice() const { return firstDevice_; }
//! Set the local work size.
void setLocalWorkSize(const NDRange& local) { sizes_.local() = local; }