From 696a24e6c7a8d9af5b818a4cd020836a14236bef Mon Sep 17 00:00:00 2001 From: Juan ESCOBAR <juan.escobar@aero.obs-mip.fr> Date: Tue, 13 Sep 2022 17:30:16 +0200 Subject: [PATCH] Juan 13/09/2022: add new ARCH_SRC/cray_gu/gu.c , for Automatic Gradual Underflow on CPU (like GPU) --- src/ARCH_SRC/cray_gu/gu.c | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/ARCH_SRC/cray_gu/gu.c diff --git a/src/ARCH_SRC/cray_gu/gu.c b/src/ARCH_SRC/cray_gu/gu.c new file mode 100644 index 000000000..24581c7e0 --- /dev/null +++ b/src/ARCH_SRC/cray_gu/gu.c @@ -0,0 +1,45 @@ +/* + +* Copyright -2022 Hewlett Packard Enterprise Development LP + +*/ + +void __cce_floatingpt_gu( void ); // Gradual Underflow. + + + +static void (*p)(void) __attribute__((section(".init_array"))) = __cce_floatingpt_gu; + + + +#define DENORMS_ARE_ZEROS 6 + +#define FLUSH_TO_ZERO_MASK 15 + + + +void __cce_floatingpt_gu( void ) + +{ + + unsigned long gu_src = (1 << DENORMS_ARE_ZEROS); + + unsigned long gu_dst = (1 << FLUSH_TO_ZERO_MASK); + + + + do { + + unsigned long __mxcsr; + + __asm__ volatile("stmxcsr %0" : : "m" (__mxcsr)); + + __mxcsr &= ~(gu_src | gu_dst); + + __asm__ volatile("ldmxcsr %0" : : "m" (__mxcsr)); + + } + + while (0); + +} -- GitLab