2
0
Ficheiros
rocm-systems/rocclr/runtime/device/rocm/rochostcall.hpp
T
foreman 416f273e94 P4 to Git Change 2037301 by ssahasra@ssahasra-hip-vdi on 2019/11/26 22:42:25
SWDEV-204782 - introduce hostcall

	Hostcall is a service that allows a kernel to submit requests to the
	host using shared buffers, and block until a response is received. This
	will eventually replace the shared buffer currently used for printf, and
	repurposes the same hidden kernel argument.

	When the runtime launches a kernel that requires the hostcall service it
	performs the following actions:
	- Launch a hostcall listener thread if it is not already running.
	- Locate the hostcall buffer for the corresponding hardware queue, or
	  create a new one.
	- Register the new hostcall buffer with the listener thread.
	- Set the hostcall buffer pointer as an implicit argument to the kernel.

Affected files ...

... //depot/stg/opencl/drivers/opencl/make/hip.git/tests/Makefile#21 edit
... //depot/stg/opencl/drivers/opencl/make/hip.git/tests/build/Makefile.hip_tests#31 edit
... //depot/stg/opencl/drivers/opencl/make/hip.git/tests/scripts/hip_hostcall_tests.txt#1 add
... //depot/stg/opencl/drivers/opencl/make/hip.git/tests/scripts/run_all_tests.sh#22 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/devkernel.cpp#30 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/devkernel.hpp#19 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#143 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.hpp#45 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rochostcall.cpp#1 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rochostcall.hpp#1 add
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocvirtual.cpp#92 edit
2019-11-26 22:44:29 -05:00

61 linhas
2.2 KiB
C++

//
// Copyright (c) 2019 Advanced Micro Devices, Inc. All rights reserved.
//
#pragma once
/** \file Support for invoking host services from the device.
*
* A hostcall is a fixed-size request generated by a kernel running
* on the device, for some predefined service provided by the
* host. The life-cycle of a hostcall is as follows:
*
* 1. A workitem in the some kernel dispatch submits a request as a
* "packet" in a "hostcall buffer". The workitem blocks until it
* receives a response from the host.
*
* 2. A host thread called the "hostcall listener" notices the packet
* and invokes the desired service on the host.
*
* 3. When the service completes, the listener copies the response
* into the request packet. This unblocks the workitem, and the
* hostcall is said to be completed.
*
* The hostcall listeners and buffers are managed by the VDI
* runtime. The typical flow is as follows:
*
* - Create and launch one or more hostcall listeners.
*
* - Create and initialize a distinct hostcall buffer for each
* command queue in hardware (e.g., an hsa_queue_t on ROCm).
*
* - Register this buffer with the appropriate listener.
*
* - When a buffer is no longer used, deregister and then free
* it. This usually happens when the corresponding hardware queue
* is freed.
*
* - Destroy the listener(s) when they are no longer required. This must be
* done before exiting the application, so that the listener
* threads can join() correctly.
*
* A single listener is sufficient to correctly handle all hostcall
* buffers created in the application. The client may also launch
* multiple listeners, as long the same hostcall buffer is not
* registered with multiple listeners.
*/
/** \brief Determine the buffer size to be allocated
* \param num_packets Number of packets to be supported.
* \return Required size, including any internal padding required for
* the packets and their headers.
*/
size_t getHostcallBufferSize(uint32_t num_packets);
/** \brief Return the required alignment for a hostcall buffer.
*/
uint32_t getHostcallBufferAlignment(void);
bool enableHostcalls(void* buffer, uint32_t numPackets, const void* queue);
void disableHostcalls(void* buffer, const void* queue);