GmAlloc
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
√ |
|
√ |
|
x |
|
√ |
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); |