Skip to content

Commit 5dae47e

Browse files
committed
fix ascendc toolchain
1 parent ac1a064 commit 5dae47e

15 files changed

Lines changed: 102 additions & 167 deletions

File tree

tests/modules/language/ascendc/test.lua

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import("core.language.language")
22

3-
local function _write_asc_file(name, source)
3+
function _write_asc_file(name, source)
44
local sourcefile = os.tmpfile(name) .. ".asc"
55
io.writefile(sourcefile, source)
66
return sourcefile
@@ -16,8 +16,7 @@ function test_check_main(t)
1616
local mainfile = _write_asc_file("ascendc_check_main", [[
1717
#include "acl/acl.h"
1818
19-
int32_t main(int argc, char const *argv[])
20-
{
19+
int32_t main(int argc, char const *argv[]) {
2120
return 0;
2221
}
2322
]])
@@ -28,8 +27,7 @@ int32_t main(int argc, char const *argv[])
2827
/*
2928
int main() { return 1; }
3029
*/
31-
__global__ __vector__ void kernel()
32-
{
30+
__global__ __vector__ void kernel() {
3331
}
3432
]])
3533
t:are_equal(check_main(commentfile), false)
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "kernel_operator.h"
22

3-
__global__ __vector__ void hello_world()
4-
{
3+
__global__ __vector__ void hello_world() {
54
AscendC::printf("[Block (%lu/%lu)]: Hello World!!!\n", AscendC::GetBlockIdx(), AscendC::GetBlockNum());
65
}

tests/projects/ascendc/libs/src/main.asc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
extern __global__ __vector__ void hello_world();
55

6-
int32_t main(int argc, char const *argv[])
7-
{
6+
int32_t main(int argc, char const *argv[]) {
87
aclInit(nullptr);
98
int32_t deviceId = 0;
109
aclrtSetDevice(deviceId);

tests/projects/ascendc/libs/xmake.lua

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,16 @@ add_rules("mode.debug", "mode.release")
22

33
target("ascendc_static")
44
set_kind("static")
5-
set_toolchains("ascendc")
65
add_files("src/lib.asc")
76
add_ascnpuarchs("dav-2201")
87

98
target("ascendc_shared")
109
set_kind("shared")
11-
set_toolchains("ascendc")
1210
add_files("src/lib.asc")
1311
add_ascnpuarchs("dav-2201")
1412

1513
target("ascendc_libs_bin")
1614
add_deps("ascendc_static", "ascendc_shared")
1715
set_kind("binary")
18-
set_toolchains("ascendc")
1916
add_files("src/main.asc")
2017
add_ascnpuarchs("dav-2201")
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "aicpu_api.h"
22

3-
__global__ __aicpu__ uint32_t hello_world(void *args)
4-
{
3+
__global__ __aicpu__ uint32_t hello_world(void *args) {
54
AscendC::printf("Hello World!!!\n");
65
return 0;
76
}

tests/projects/ascendc/mixed_binary/src/main.asc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ struct KernelArgs {
66

77
extern __global__ __aicpu__ uint32_t hello_world(void *args);
88

9-
int32_t main(int argc, char const *argv[])
10-
{
9+
int32_t main(int argc, char const *argv[]) {
1110
aclInit(nullptr);
1211
int32_t deviceId = 0;
1312
aclrtSetDevice(deviceId);

xmake/languages/ascendc/check_main.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function main(sourcefile)
2626

2727
-- remove comment first
2828
sourcecode = sourcecode:gsub("/%*.-%*/", "")
29-
sourcecode = sourcecode:gsub("//.-\n", "\n")
29+
sourcecode = sourcecode:gsub("//[^\n]*", "")
3030

3131
-- find int main(int argc, char** argv) {}
3232
if sourcecode:find("%s+main%s*%(.-%)") then

xmake/modules/core/tools/bisheng.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ function init(self)
2727
self:add("ascflags", "-Qunused-arguments")
2828
self:add("aicpuflags", "-Qunused-arguments")
2929
self:set("ascshflags", "-shared")
30+
-- default C++ standard and source kind for bisheng compiler driver
31+
self:add("ascflags", "-std=c++17", {force = true})
32+
self:add("aicpuflags", "-std=c++17", {force = true})
33+
self:add("ascflags", "-x", "asc", {force = true})
34+
self:add("aicpuflags", "-x", "aicpu", {force = true})
3035
end
3136

3237
-- make the language flag

xmake/modules/core/tools/bisheng/has_flags.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ function _check_try_running(flags, opt, islinker)
133133
local snippet = opt.snippet or
134134
"int main(int argc, char** argv)\n{return 0;}\n"
135135
local sourcekind = _get_sourcekind(opt, islinker)
136-
local sourcefile = os.tmpfile("bisheng_has_flags:" .. snippet) ..
136+
local sourcefile = os.tmpfile("bisheng_has_flags") ..
137137
_get_extension(sourcekind)
138138
if not os.isfile(sourcefile) then
139139
io.writefile(sourcefile, snippet)

xmake/platforms/linux/xmake.lua

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ platform("linux")
4545
{category = "Cuda SDK Configuration" }
4646
, {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" }
4747
, {nil, "cuda_sdkver", "kv", "auto", "The Cuda SDK Version" }
48-
, {category = "Ascend CANN SDK Configuration" }
49-
, {nil, "ascendc", "kv", "auto", "The Ascend CANN SDK Directory" }
5048
, {category = "Qt SDK Configuration" }
5149
, {nil, "qt", "kv", "auto", "The Qt SDK Directory" }
5250
, {nil, "qt_host", "kv", "auto", "The Qt Host SDK Directory" }
@@ -59,8 +57,6 @@ platform("linux")
5957
{
6058
{category = "Cuda SDK Configuration" }
6159
, {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" }
62-
, {category = "Ascend CANN SDK Configuration" }
63-
, {nil, "ascendc", "kv", "auto", "The Ascend CANN SDK Directory" }
6460
, {category = "Qt SDK Configuration" }
6561
, {nil, "qt", "kv", "auto", "The Qt SDK Directory" }
6662
, {nil, "qt_host", "kv", "auto", "The Qt Host SDK Directory" }

0 commit comments

Comments
 (0)