Skip to content

Commit e068d51

Browse files
committed
chore: update rust toolchain (#272)
AVX512 is stablized in Rust 1.89. So we could switch to stable Rust toolchain on 7 August. job: +psql_macos job: +psql_windows Signed-off-by: usamoi <usamoi@outlook.com>
1 parent 8598ded commit e068d51

16 files changed

Lines changed: 138 additions & 409 deletions

File tree

.github/workflows/check.yml

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
- name: Set up Environment
2323
run: |
2424
rustup set profile
25+
rustup default nightly-2025-06-08
2526
2627
curl -fsSL https://github.com/tamasfe/taplo/releases/latest/download/taplo-full-linux-$(uname -m).gz | gzip -d - | install -m 755 /dev/stdin /usr/local/bin/taplo
2728
@@ -112,6 +113,8 @@ jobs:
112113
- name: Set up Environment
113114
run: |
114115
rustup set profile
116+
rustup default nightly-2025-06-08
117+
115118
sudo apt-get update
116119
117120
if [ "$(uname -m)" == "x86_64" ]; then
@@ -152,6 +155,11 @@ jobs:
152155
fi
153156
154157
psql:
158+
if: |
159+
(github.event_name == 'push' && !contains(github.event.head_commit.message, 'job: -psql')) ||
160+
(github.event_name == 'pull_request' && !contains(github.event.pull_request.body, 'job: -psql')) ||
161+
github.event_name == 'workflow_dispatch'
162+
155163
strategy:
156164
matrix:
157165
version: ["13", "14", "15", "16", "17"]
@@ -166,6 +174,8 @@ jobs:
166174
- name: Set up Environment
167175
run: |
168176
rustup set profile
177+
rustup default nightly-2025-06-08
178+
169179
sudo apt-get update
170180
171181
sudo apt-get remove -y '^postgres.*' '^libpq.*'
@@ -254,8 +264,8 @@ jobs:
254264

255265
psql_macos:
256266
if: |
257-
(github.event_name == 'push' && contains(github.event.head_commit.message, 'try-job: psql_macos')) ||
258-
(github.event_name == 'pull_request' && contains(github.event.pull_request.body, 'try-job: psql_macos')) ||
267+
(github.event_name == 'push' && contains(github.event.head_commit.message, 'job: +psql_macos')) ||
268+
(github.event_name == 'pull_request' && contains(github.event.pull_request.body, 'job: +psql_macos')) ||
259269
github.event_name == 'workflow_dispatch'
260270
261271
strategy:
@@ -273,6 +283,7 @@ jobs:
273283
- name: Set up Environment
274284
run: |
275285
rustup set profile
286+
rustup default nightly-2025-06-08
276287
277288
echo CC=$(brew --prefix llvm@18)/bin/clang >> $GITHUB_ENV
278289
@@ -337,3 +348,52 @@ jobs:
337348
./build/postgresql-${{ matrix.version }}-vchord_0.0.0_${{ matrix.arch }}-apple-darwin.zip
338349
compression-level: 9
339350
retention-days: 14
351+
352+
psql_windows:
353+
if: |
354+
(github.event_name == 'push' && contains(github.event.head_commit.message, 'job: +psql_windows')) ||
355+
(github.event_name == 'pull_request' && contains(github.event.pull_request.body, 'job: +psql_windows')) ||
356+
github.event_name == 'workflow_dispatch'
357+
358+
strategy:
359+
matrix:
360+
version: ["16"]
361+
arch: ["x86_64"]
362+
363+
runs-on: "windows-2022"
364+
365+
env:
366+
RUSTC_WRAPPER: sccache
367+
SCCACHE_GHA_ENABLED: true
368+
369+
steps:
370+
- name: Set up Environment
371+
run: |
372+
rustup set profile
373+
rustup default nightly-2025-06-08
374+
375+
Invoke-WebRequest -Uri "https://get.enterprisedb.com/postgresql/postgresql-16.9-1-windows-x64-binaries.zip" -OutFile "$env:TEMP\postgresql-install.zip"
376+
Expand-Archive -Path "$env:TEMP\postgresql-install.zip" -DestinationPath "D:\postgresql-install" -Force
377+
Add-Content -Path $env:GITHUB_ENV -Value "PGRX_PG_CONFIG_PATH=D:\postgresql-install\pgsql\bin\pg_config.exe"
378+
Add-Content -Path $env:GITHUB_ENV -Value "PGBIN=D:\postgresql-install\pgsql\bin"
379+
Add-Content -Path $env:GITHUB_ENV -Value "PGDATA=D:\postgresql-install\pgsql\data"
380+
Add-Content -Path $env:GITHUB_ENV -Value "PGROOT=D:\postgresql-install\pgsql"
381+
382+
Invoke-WebRequest -Uri https://github.com/risinglightdb/sqllogictest-rs/releases/download/v0.26.4/sqllogictest-bin-v0.26.4-${{ matrix.arch }}-pc-windows-msvc.zip -OutFile "$env:TEMP\sqllogictest-install.zip"
383+
Expand-Archive -Path "$env:TEMP\sqllogictest-install.zip" -DestinationPath "D:\sqllogictest-install" -Force
384+
Add-Content -Path $env:GITHUB_PATH -Value "D:\sqllogictest-install"
385+
386+
- name: Set up Sccache
387+
uses: mozilla-actions/sccache-action@v0.0.9
388+
389+
- name: Checkout
390+
uses: actions/checkout@v4
391+
392+
- name: Clippy
393+
run: |
394+
cargo clippy -p vchord --features pg${{ matrix.version }} -- --no-deps
395+
396+
- name: Install
397+
run: |
398+
cargo make build -o ./build/raw
399+
make PG_CONFIG="$env:PGRX_PG_CONFIG_PATH" install

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ jobs:
5151
steps:
5252
- name: Set up Environment
5353
run: |
54+
rustup set profile
55+
rustup default nightly-2025-06-08
56+
5457
sudo apt-get update
5558
5659
sudo apt-get remove -y '^postgres.*' '^libpq.*'

crates/algorithm/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
//
1313
// Copyright (c) 2025 TensorChord Inc.
1414

15-
#![feature(select_unpredictable)]
1615
#![allow(clippy::type_complexity)]
1716

1817
mod build;

crates/make/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ fn main() -> Result<()> {
8383
eprintln!("Fork: {fork}");
8484
fork
8585
};
86+
#[allow(clippy::collapsible_if)]
8687
let version = 'version: {
8788
for line in std::fs::read_to_string("./vchord.control")?.lines() {
8889
if let Some(prefix_stripped) = line.strip_prefix("default_version = '") {

crates/rabitq/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
//
1313
// Copyright (c) 2025 TensorChord Inc.
1414

15-
#![feature(slice_as_chunks)]
16-
#![feature(select_unpredictable)]
17-
1815
pub mod binary;
1916
pub mod block;
2017
pub mod packing;

crates/simd/cshim/x86_64.c

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,50 @@
1616
#if !(__clang_major__ >= 16)
1717
#error "Clang version must be at least 16."
1818
#endif
19+
#elif defined(__GNUC__)
20+
#if !(__GNUC__ >= 12)
21+
#error "GCC version must be at least 12."
22+
#endif
1923
#else
20-
#error "This file requires Clang."
24+
#error "This file requires Clang or GCC."
2125
#endif
2226

2327
#include <immintrin.h>
2428
#include <stddef.h>
2529
#include <stdint.h>
2630

31+
#if defined(__clang__) && defined(_MSC_VER) && (__clang_major__ <= 19)
32+
// https://github.com/llvm/llvm-project/issues/53520
33+
// clang-format off
34+
#include <pmmintrin.h>
35+
#include <tmmintrin.h>
36+
#include <smmintrin.h>
37+
#include <lzcntintrin.h>
38+
#include <avxintrin.h>
39+
#include <avx2intrin.h>
40+
#include <f16cintrin.h>
41+
#include <fmaintrin.h>
42+
#include <bmiintrin.h>
43+
#include <bmi2intrin.h>
44+
#include <lzcntintrin.h>
45+
#include <avx512fintrin.h>
46+
#include <avx512bwintrin.h>
47+
#include <avx512cdintrin.h>
48+
#include <avx512dqintrin.h>
49+
#include <avx512vlintrin.h>
50+
#include <avx512vlbwintrin.h>
51+
#include <avx512vlcdintrin.h>
52+
#include <avx512vldqintrin.h>
53+
#include <avx512fp16intrin.h>
54+
#include <avx512vlfp16intrin.h>
55+
// clang-format on
56+
#endif
57+
2758
typedef _Float16 f16;
2859
typedef float f32;
2960

3061
__attribute__((target("arch=x86-64-v4,avx512fp16"))) float
31-
fp16_reduce_sum_of_xy_v4fp16(f16 *restrict a, f16 *restrict b, size_t n) {
62+
fp16_reduce_sum_of_xy_v4_avx512fp16(f16 *restrict a, f16 *restrict b, size_t n) {
3263
__m512h xy = _mm512_setzero_ph();
3364
while (n >= 32) {
3465
__m512h x = _mm512_loadu_ph(a);
@@ -48,7 +79,7 @@ fp16_reduce_sum_of_xy_v4fp16(f16 *restrict a, f16 *restrict b, size_t n) {
4879
}
4980

5081
__attribute__((target("arch=x86-64-v4,avx512fp16"))) float
51-
fp16_reduce_sum_of_d2_v4fp16(f16 *restrict a, f16 *restrict b, size_t n) {
82+
fp16_reduce_sum_of_d2_v4_avx512fp16(f16 *restrict a, f16 *restrict b, size_t n) {
5283
__m512h d2 = _mm512_setzero_ph();
5384
while (n >= 32) {
5485
__m512h x = _mm512_loadu_ph(a);

crates/simd/src/f16.rs

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -239,25 +239,29 @@ mod reduce_sum_of_xy {
239239

240240
#[inline]
241241
#[cfg(target_arch = "x86_64")]
242-
#[crate::target_cpu(enable = "v4fp16")]
243-
pub fn reduce_sum_of_xy_v4fp16(lhs: &[f16], rhs: &[f16]) -> f32 {
242+
#[crate::target_cpu(enable = "v4")]
243+
#[target_feature(enable = "avx512fp16")]
244+
pub fn reduce_sum_of_xy_v4_avx512fp16(lhs: &[f16], rhs: &[f16]) -> f32 {
244245
assert!(lhs.len() == rhs.len());
245246
unsafe {
246247
unsafe extern "C" {
247-
unsafe fn fp16_reduce_sum_of_xy_v4fp16(a: *const (), b: *const (), n: usize)
248-
-> f32;
248+
unsafe fn fp16_reduce_sum_of_xy_v4_avx512fp16(
249+
a: *const (),
250+
b: *const (),
251+
n: usize,
252+
) -> f32;
249253
}
250-
fp16_reduce_sum_of_xy_v4fp16(lhs.as_ptr().cast(), rhs.as_ptr().cast(), lhs.len())
254+
fp16_reduce_sum_of_xy_v4_avx512fp16(lhs.as_ptr().cast(), rhs.as_ptr().cast(), lhs.len())
251255
}
252256
}
253257

254258
#[cfg(all(target_arch = "x86_64", test, not(miri)))]
255259
#[test]
256-
fn reduce_sum_of_xy_v4fp16_test() {
260+
fn reduce_sum_of_xy_v4_avx512fp16_test() {
257261
use rand::Rng;
258262
const EPSILON: f32 = 2.0;
259-
if !crate::is_cpu_detected!("v4fp16") {
260-
println!("test {} ... skipped (v4fp16)", module_path!());
263+
if !crate::is_cpu_detected!("v4") || !crate::is_feature_detected!("avx512fp16") {
264+
println!("test {} ... skipped (v4:avx512fp16)", module_path!());
261265
return;
262266
}
263267
let mut rng = rand::rng();
@@ -272,7 +276,7 @@ mod reduce_sum_of_xy {
272276
for z in 3984..4016 {
273277
let lhs = &lhs[..z];
274278
let rhs = &rhs[..z];
275-
let specialized = unsafe { reduce_sum_of_xy_v4fp16(lhs, rhs) };
279+
let specialized = unsafe { reduce_sum_of_xy_v4_avx512fp16(lhs, rhs) };
276280
let fallback = fallback(lhs, rhs);
277281
assert!(
278282
(specialized - fallback).abs() < EPSILON,
@@ -494,7 +498,7 @@ mod reduce_sum_of_xy {
494498
}
495499
}
496500

497-
#[crate::multiversion(@"v4fp16", @"v4", @"v3", @"a3.512", @"a2:fp16")]
501+
#[crate::multiversion(@"v4:avx512fp16", @"v4", @"v3", @"a3.512", @"a2:fp16")]
498502
pub fn reduce_sum_of_xy(lhs: &[f16], rhs: &[f16]) -> f32 {
499503
assert!(lhs.len() == rhs.len());
500504
let n = lhs.len();
@@ -511,25 +515,29 @@ mod reduce_sum_of_d2 {
511515

512516
#[inline]
513517
#[cfg(target_arch = "x86_64")]
514-
#[crate::target_cpu(enable = "v4fp16")]
515-
pub fn reduce_sum_of_d2_v4fp16(lhs: &[f16], rhs: &[f16]) -> f32 {
518+
#[crate::target_cpu(enable = "v4")]
519+
#[target_feature(enable = "avx512fp16")]
520+
pub fn reduce_sum_of_d2_v4_avx512fp16(lhs: &[f16], rhs: &[f16]) -> f32 {
516521
assert!(lhs.len() == rhs.len());
517522
unsafe {
518523
unsafe extern "C" {
519-
unsafe fn fp16_reduce_sum_of_d2_v4fp16(a: *const (), b: *const (), n: usize)
520-
-> f32;
524+
unsafe fn fp16_reduce_sum_of_d2_v4_avx512fp16(
525+
a: *const (),
526+
b: *const (),
527+
n: usize,
528+
) -> f32;
521529
}
522-
fp16_reduce_sum_of_d2_v4fp16(lhs.as_ptr().cast(), rhs.as_ptr().cast(), lhs.len())
530+
fp16_reduce_sum_of_d2_v4_avx512fp16(lhs.as_ptr().cast(), rhs.as_ptr().cast(), lhs.len())
523531
}
524532
}
525533

526534
#[cfg(all(target_arch = "x86_64", test, not(miri)))]
527535
#[test]
528-
fn reduce_sum_of_d2_v4fp16_test() {
536+
fn reduce_sum_of_d2_v4_avx512fp16_test() {
529537
use rand::Rng;
530538
const EPSILON: f32 = 6.4;
531-
if !crate::is_cpu_detected!("v4fp16") {
532-
println!("test {} ... skipped (v4fp16)", module_path!());
539+
if !crate::is_cpu_detected!("v4") || !crate::is_feature_detected!("avx512fp16") {
540+
println!("test {} ... skipped (v4:avx512fp16)", module_path!());
533541
return;
534542
}
535543
let mut rng = rand::rng();
@@ -544,7 +552,7 @@ mod reduce_sum_of_d2 {
544552
for z in 3984..4016 {
545553
let lhs = &lhs[..z];
546554
let rhs = &rhs[..z];
547-
let specialized = unsafe { reduce_sum_of_d2_v4fp16(lhs, rhs) };
555+
let specialized = unsafe { reduce_sum_of_d2_v4_avx512fp16(lhs, rhs) };
548556
let fallback = fallback(lhs, rhs);
549557
assert!(
550558
(specialized - fallback).abs() < EPSILON,
@@ -774,7 +782,7 @@ mod reduce_sum_of_d2 {
774782
}
775783
}
776784

777-
#[crate::multiversion(@"v4fp16", @"v4", @"v3", @"a3.512", @"a2:fp16")]
785+
#[crate::multiversion(@"v4:avx512fp16", @"v4", @"v3", @"a3.512", @"a2:fp16")]
778786
pub fn reduce_sum_of_d2(lhs: &[f16], rhs: &[f16]) -> f32 {
779787
assert!(lhs.len() == rhs.len());
780788
let n = lhs.len();

crates/simd/src/lib.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
//
1313
// Copyright (c) 2025 TensorChord Inc.
1414

15-
#![cfg_attr(target_arch = "x86_64", feature(avx512_target_feature))]
16-
#![cfg_attr(target_arch = "x86_64", feature(stdarch_x86_avx512))]
17-
#![feature(slice_as_chunks)]
18-
#![feature(select_unpredictable)]
1915
#![allow(unsafe_code)]
2016

2117
mod aligned;
@@ -85,20 +81,6 @@ mod internal {
8581
#[allow(unused_imports)]
8682
pub use is_riscv64_cpu_detected;
8783

88-
#[cfg(target_arch = "x86_64")]
89-
pub fn is_v4fp16_detected() -> bool {
90-
std::arch::is_x86_feature_detected!("avx512fp16")
91-
&& std::arch::is_x86_feature_detected!("avx512bw")
92-
&& std::arch::is_x86_feature_detected!("avx512cd")
93-
&& std::arch::is_x86_feature_detected!("avx512dq")
94-
&& std::arch::is_x86_feature_detected!("avx512vl")
95-
&& std::arch::is_x86_feature_detected!("bmi1")
96-
&& std::arch::is_x86_feature_detected!("bmi2")
97-
&& std::arch::is_x86_feature_detected!("lzcnt")
98-
&& std::arch::is_x86_feature_detected!("movbe")
99-
&& std::arch::is_x86_feature_detected!("popcnt")
100-
}
101-
10284
#[cfg(target_arch = "x86_64")]
10385
pub fn is_v4_detected() -> bool {
10486
std::arch::is_x86_feature_detected!("avx512bw")

crates/simd_macros/src/target.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,6 @@ pub struct TargetCpu {
1919
}
2020

2121
pub const TARGET_CPUS: &[TargetCpu] = &[
22-
// This is a temporary hack, for using AVX512FP16 without unstable features.
23-
TargetCpu {
24-
target_cpu: "v4fp16",
25-
target_arch: "x86_64",
26-
target_features: &[
27-
"avx512bw", "avx512cd", "avx512dq", "avx512vl", // simd
28-
"bmi1", "bmi2", "lzcnt", "movbe", "popcnt", // bit-operations
29-
],
30-
},
3122
TargetCpu {
3223
target_cpu: "v4",
3324
target_arch: "x86_64",

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[toolchain]
2-
channel = "nightly-2025-04-26"
2+
channel = "nightly-2025-06-08"

0 commit comments

Comments
 (0)