aclrtcCreateProg
产 品 支 持 情 况
功 能 说 明
通 过 给 定 的 参 数,创 建 编 译 程 序 的 实 例。
函 数 原 型
Text
aclError aclrtcCreateProg(aclrtcProg *prog, const char *src, const char *name, int numHeaders, const char **headers, const char **includeNames)
参 数 说 明
表 1 接 口 参 数 说 明
返 回 值 说 明
aclError为int类 型 变 量,详 细 说 明 请 参 考RTC错 误 码。
约 束 说 明
无
调 用 示 例
Text
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);