From 3678cc91880f93975242dd32e1f56cea91f6e68b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20Ke=C3=9Fler?= <53379559+tpkessler@users.noreply.github.com> Date: Tue, 8 Oct 2024 19:55:28 +0200 Subject: [PATCH 1/2] Add AVX512 support (#675) --- src/tcompiler.cpp | 27 ++++++++++++++++++++++++++- tests/avx512.t | 8 ++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 tests/avx512.t diff --git a/src/tcompiler.cpp b/src/tcompiler.cpp index 1084845d..c0f920a0 100644 --- a/src/tcompiler.cpp +++ b/src/tcompiler.cpp @@ -228,6 +228,25 @@ bool HostHasAVX() { return Features["avx"]; } +bool HostHasAVX512() { + StringMap Features; + sys::getHostCPUFeatures(Features); + // The following instructions sets are supported by Intel CPUs starting 2017 + // (Skylake-SP and beyond) and AMD CPUs starting 2022 (Zen4 and beyond) + const char *instruction_set[] = { + "avx512f", // Foundation + "avx512dq", // Double Word, Quad Word + "avx512bw", // Vector Byte and Word + "avx512vl", // Vector Length + "avx512cd", // Conflict Detection + }; + bool has_avx512 = true; + for (auto &instr : instruction_set) { + has_avx512 &= Features[instr]; + } + return has_avx512; +} + int terra_inittarget(lua_State *L) { terra_State *T = terra_getstate(L, 1); TerraTarget *TT = new TerraTarget(); @@ -257,7 +276,13 @@ int terra_inittarget(lua_State *L) { #ifdef DISABLE_AVX TT->Features = "-avx"; #else - TT->Features = HostHasAVX() ? "+avx" : ""; + if (HostHasAVX512()) { + TT->Features = "+avx512f,+avx512dq,+avx512bw,+avx512vl,+avx512cd"; + } else if (HostHasAVX()) { + TT->Features = "+avx"; + } else { + TT->Features = ""; + } #endif } diff --git a/tests/avx512.t b/tests/avx512.t new file mode 100644 index 00000000..fe1c90d9 --- /dev/null +++ b/tests/avx512.t @@ -0,0 +1,8 @@ +local vec = vector(int8, 64) +terra compute(x: vec, y: vec) + -- vec has a size of 8 * 64 = 512 bits so this operation should compile + -- to a single AVX512 instruction + return x + y +end +compute:compile() +compute:disas() From 7faa246f3bb8b3a7f24e7c86e2b54c99f801f8c7 Mon Sep 17 00:00:00 2001 From: Elliott Slaughter Date: Wed, 16 Oct 2024 16:39:37 -0700 Subject: [PATCH 2/2] Bump CI to macOS 13 (#676) --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 46701967..6b89340c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,14 +19,14 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - # Note: macOS 12 runs on x86 hardware, and 14 runs on M1 hardware - os: ['macos-12', 'macos-14', 'windows-2022'] + # Note: macOS 13 runs on x86 hardware, and 14 runs on M1 hardware + os: ['macos-13', 'macos-14', 'windows-2022'] llvm: ['11', '12', '13', '14', '15', '16', '17', '18'] cuda: ['0', '1'] lua: ['luajit', 'moonjit'] exclude: # macOS: exclude cuda - - os: 'macos-12' + - os: 'macos-13' cuda: '1' - os: 'macos-14' cuda: '1'