GmAlloc

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product AI Core

Atlas inference product Vector Core

x

Atlas training product

Function Usage

Creates shared memory during verification of the CPU-side operation of the kernel function. That is, creates a shared file in the /tmp directory and returns the mapping pointer to the file.

Prototype

1
void *GmAlloc(size_t size)

Parameters

Parameter

Input/Output

Description

size

Input

Size of the shared memory to be allocated.

Returns

Returns the start address of the shared memory space.

Restrictions

This API generates a temporary file in the system /tmp directory. Therefore, the shared memory can be properly generated only when the drive space is sufficient.

Example

1
2
3
4
uint32_t numBlocks = 8;    // Total number of cores
uint32_t blockLength = 2048;    // Memory size allocated to each core
size_t len = numBlocks * blockLength * sizeof(uint16_t);    // Shared memory size
uint8_t* x = (uint8_t*)AscendC::GmAlloc(len);