MapL2#
Fully qualified name: cupva::mem::MapL2
Defined in src/host/cpp_api/include/cupva_host.hpp
- void *cupva::mem::MapL2(
- void *devptr,
- uint32_t size,
- mem::L2SRAMPolicyType policy = mem::L2SRAMPolicyType::FILL_AND_FLUSH,
Creates a device pointer for an L2SRAM buffer of given size with an optional DRAM buffer backing for persistence and associated cache policy.
This function creates a device pointer for an L2SRAM buffer of given size with an optional DRAM buffer backing for persistence and associated cache policy. The created L2SRAM device pointer can be used like any other device pointer. It can serve as the base address for an OffsetPointer, or raw pointer when configuring DataFlows.
If a DRAM buffer is provided, it will be used as the backing for the L2SRAM buffer. It can be used to FILL or FLUSH the L2SRAM buffer depending on the specified policy. The same DRAM buffer pointer can be used to create multiple pointers to the same L2SRAM buffer with different cache policies. Please note that when configuring a single CmdProgram or CmdMemcpy operation, you can only use one mapped L2SRAM pointer at a time.
Mapping should be unmapped with mem::Free when the L2SRAM buffer is no longer needed. If specified, backing DRAM buffer should not be freed until all L2SRAM pointers mapped to it are unmapped.
Legacy setL2Size() API calls will not be honored if mapped L2SRAM pointers are used for a CmdProgram or CmdMemcpy.
Please refer to L2SRAMPolicyType for more details and usage examples.
MapL2 API requires driver version >= 2007.
Usage considerations
Allowed context for the API call
Thread-safe: Yes
API group
Init: Yes
Runtime: No
De-Init: No
- Parameters:
devptr – [in] The DRAM device pointer to map to L2 cache. If devptr is nullptr, the L2SRAM will not have DRAM backing and policy will be ignored.
size – [in] The size of the memory region to map. Should be larger than 0.
policy – [in] The access policy for the L2 cache mapping (FILL, FLUSH, or FILL_AND_FLUSH).
- Throws:
- Returns:
A mapped L2 device pointer.