From a9f415f06a4457c27f4a7e87ff74a79839b03ce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Thu, 7 May 2020 23:54:03 +0200 Subject: [PATCH] add simple avx test Change-Id: Ia17524929672b420e20d9b491fdafd21cc5a928f Reviewed-on: https://review.haiku-os.org/c/haiku/+/2850 Reviewed-by: waddlesplash --- src/tests/system/kernel/Jamfile | 5 +++++ src/tests/system/kernel/hello_avx.c | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/tests/system/kernel/hello_avx.c diff --git a/src/tests/system/kernel/Jamfile b/src/tests/system/kernel/Jamfile index b385aa8a33..91a33a6e2d 100644 --- a/src/tests/system/kernel/Jamfile +++ b/src/tests/system/kernel/Jamfile @@ -13,6 +13,11 @@ SimpleTest fibo_exec : fibo_exec.cpp ; SimpleTest fifo_poll_test : fifo_poll_test.cpp ; +SimpleTest hello_avx : hello_avx.c ; +local avxSource = [ FGristFiles hello_avx.c ] ; +local avxObject = $(avxSource:S=$(SUFOBJ)) ; +CCFLAGS on $(avxObject) = -mavx ; + SimpleTest live_query : live_query.cpp : be diff --git a/src/tests/system/kernel/hello_avx.c b/src/tests/system/kernel/hello_avx.c new file mode 100644 index 0000000000..f84377506d --- /dev/null +++ b/src/tests/system/kernel/hello_avx.c @@ -0,0 +1,25 @@ +/* + * https://www.codeproject.com/Articles/874396/Crunching-Numbers-with-AVX-and-AVX + * 2016, Matt Scarpino, released under the Code Project Open License + * https://www.codeproject.com/info/cpol10.aspx + */ + +#include +#include + +int main() { + + /* Initialize the two argument vectors */ + __m256 evens = _mm256_set_ps(2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0); + __m256 odds = _mm256_set_ps(1.0, 3.0, 5.0, 7.0, 9.0, 11.0, 13.0, 15.0); + + /* Compute the difference between the two vectors */ + __m256 result = _mm256_sub_ps(evens, odds); + + /* Display the elements of the result vector */ + float* f = (float*)&result; + printf("%f %f %f %f %f %f %f %f\n", + f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7]); + + return 0; +}