Skip to content

[OpenMP] [test] Skip the -mlong-double-80 test on MSVC ABI #81115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2024

Conversation

mstorsjo
Copy link
Member

@mstorsjo mstorsjo commented Feb 8, 2024

Within the MSVC ABI, long doubles are the same as regular 64 bit doubles. This test case, which is compiled with -mlong-double-80, cannot work when libomp has been compiled without that flag, as -mlong-double-80 changes the calling convention for the tested functions.

Within the MSVC ABI, long doubles are the same as regular 64 bit
doubles. This test case, which is compiled with -mlong-double-80,
cannot work when libomp has been compiled without that flag, as
-mlong-double-80 changes the calling convention for the tested
functions.
@mstorsjo mstorsjo added the openmp label Feb 8, 2024
@mstorsjo mstorsjo requested a review from shiltian February 8, 2024 09:51
@llvmbot llvmbot added the openmp:libomp OpenMP host runtime label Feb 8, 2024
@llvmbot
Copy link
Member

llvmbot commented Feb 8, 2024

@llvm/pr-subscribers-openmp

Author: Martin Storsjö (mstorsjo)

Changes

Within the MSVC ABI, long doubles are the same as regular 64 bit doubles. This test case, which is compiled with -mlong-double-80, cannot work when libomp has been compiled without that flag, as -mlong-double-80 changes the calling convention for the tested functions.


Full diff: https://github.com/llvm/llvm-project/pull/81115.diff

1 Files Affected:

  • (modified) openmp/runtime/test/atomic/kmp_atomic_float10_max_min.c (+2-2)
diff --git a/openmp/runtime/test/atomic/kmp_atomic_float10_max_min.c b/openmp/runtime/test/atomic/kmp_atomic_float10_max_min.c
index 82d8cbc19d7a16..72ba1eeb643ef1 100644
--- a/openmp/runtime/test/atomic/kmp_atomic_float10_max_min.c
+++ b/openmp/runtime/test/atomic/kmp_atomic_float10_max_min.c
@@ -28,7 +28,7 @@ extern long double __kmpc_atomic_float10_min_cpt(ident_t *id_ref, int gtid,
 
 int main() {
   int ret = 0;
-#if KMP_ARCH_X86 || KMP_ARCH_X86_64
+#if (KMP_ARCH_X86 || KMP_ARCH_X86_64) && !defined(_MSC_VER)
   long double s = 012.3456; // small
   long double e = 123.4567; // middle
   long double d = 234.5678; // big
@@ -158,6 +158,6 @@ int main() {
     printf("passed\n");
 #else
   printf("Unsupported architecture, skipping test...\n");
-#endif // KMP_ARCH_X86 || KMP_ARCH_X86_64
+#endif // (KMP_ARCH_X86 || KMP_ARCH_X86_64) && !defined(_MSC_VER)
   return ret;
 }

@mstorsjo
Copy link
Member Author

Ping @shiltian

Copy link
Contributor

@shiltian shiltian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

@jhuber6
Copy link
Contributor

jhuber6 commented Feb 15, 2024

Might be better to check for 64-bit doubles in general since that's present on various targets. But probably not a huge deal overall.

This should do it

#include <float.h>
#if (LDBL_MANT_DIG == 53)
// 64-bit double
#elif (LDBL_MANT_DIG == 64)
// 80-bit double
#else
// 128-bit double
#endif

@mstorsjo
Copy link
Member Author

Might be better to check for 64-bit doubles in general since that's present on various targets. But probably not a huge deal overall.

This should do it

#include <float.h>
#if (LDBL_MANT_DIG == 53)
// 64-bit double
#elif (LDBL_MANT_DIG == 64)
// 80-bit double
#else
// 128-bit double
#endif

Hmm, so I kinda wonder how this test is supposed to work in the first place.

On the platforms where this test actually does work, the long doubles already are 80 bit from the start, so adding the -mlong-double-80 option is essentially a no-op. And for other platforms, where long doubles aren't 80 bit, passing -mlong-double-80 breaks the ABI between the calling code and libomp (libomp compiled as usual with whatever is the compiler default for long doubles), so I'm not really sure how that's meant to work at all.

Anyway, without taking on digging up what the point of this test was to begin with, are you ok with me merging this patch to hide the failure in MSVC build modes at least?

@mstorsjo mstorsjo merged commit 4b9c089 into llvm:main Feb 19, 2024
@mstorsjo mstorsjo deleted the openmp-test-long-double branch February 19, 2024 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openmp:libomp OpenMP host runtime openmp
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants