ReserveLocalMemory

Function

This function is used to reserve memory space of a specified size in the unified buffer. After this API is called, the size of the remaining available unified buffer space can be obtained by calling the GetCoreMemSize API.

Prototype

1
void ReserveLocalMemory(ReservedSize size)

Parameters

Parameter

Input/Output

Description

ReservedSize

Input

Size of the space to be reserved.

1
2
3
4
5
enum class ReservedSize {
    RESERVED_SIZE_8K, // 8 KB space is reserved.
    RESERVED_SIZE_16K, // 16 KB space is reserved.
    RESERVED_SIZE_32K, // 32 KB space is reserved.
};

Returns

None

Restrictions

When this function is called for multiple times, only the result of the last call is retained.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
ge::graphStatus TilingXXX(gert::TilingContext* context) {
    auto ascendcPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo());
    uint64_t ub_size, l1_size;
    // Reserve 8 KB unified buffer space.
    ascendcPlatform.ReserveLocalMemory(platform_ascendc::ReservedSize::RESERVED_SIZE_8K);
    // Obtain the actual available memory size of the unified buffer and L1.
    ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ub_size);
    ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::L1, l1_size);
    // ...
    return ret;
}

For details about the complete example, see Example of Using the High-Level API with the Math Library.