aclrtcCreateProg

Product Support

Product

Supported

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas 200I/500 A2 inference products

x

Atlas inference product's AI Core

x

Atlas inference product's Vector Core

x

Atlas training products

x

Function

Creates an instance of the compiler based on the given parameters.

Prototype

1
aclError aclrtcCreateProg(aclrtcProg *prog, const char *src, const char *name, int numHeaders, const char **headers, const char **includeNames)

Parameters

Table 1 API parameters

Parameter

Input/Output

Description

prog

Output

Handle to the compiler at runtime.

src

Input

Source code content of the Ascend C device provided in the form of a string.

name

Input

User-defined program name, which is used to identify and distinguish different programs. The default value is "default_program".

numHeaders

Input

Number of header files to be included. The value must be a non-negative integer.

If no header file needs to be included or the required header file has been included in the Ascend C device source code, set this parameter to 0.

headers

Input

A pointer to an array, where each element is a string ended with '\0', indicating the source code content of the header file. When numHeaders is 0, this parameter can be set to nullptr.

includeNames

Input

A pointer to an array, where each element is a string ended with '\0', indicating the name of the header file.

The names must be the same as those of the header files included in the #include directive in the source code.

Returns

aclError is of the int type. For details, see RTC Error Codes.

Restrictions

None

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
aclrtcProg prog;
const char *src = R""""(
#include "kernel_operator.h"
#include "my_const_a.h"
#include "my_const_b.h"

extern "C" __global__ __aicore__ void hello_world(GM_ADDR x)
{
	KERNEL_TASK_TYPE_DEFAULT(KERNEL_TYPE_AIC_ONLY);
	*x = *x + MY_CONST_A + MY_CONST_B;
}
)"""";
const char* headerSrcA = R"(
#ifndef CONST_A_H
#define CONST_A_H
const int MY_CONST_A = 100;
#endif // CONST_A_H
)";
const char* includeNameA = "my_const_a.h";

const char* headerSrcB = R"(
#ifndef CONST_B_H
#define CONST_B_H
const int MY_CONST_B = 50;
#endif // CONST_B_H
)";

const char* includeNameB = "my_const_b.h";
const char* headersArray[] = { headerSrcA, headerSrcB };
const char* includeNameArray[] = { includeNameA, includeNameB };
aclError result = aclrtcCreateProg(&prog, src, "hello_world", 2,  headersArray,  includeNameArray);