Skip to content

Commit

Permalink
Add non-SSE wrapper for __kmp_{load,store}_mxcsr
Browse files Browse the repository at this point in the history
Summary:
To be able to successfully build OpenMP on FreeBSD/i386, which still
uses i486 as its default processor, I had to provide wrappers for the
`__kmp_load_mxcsr` and `__kmp_store_mxcsr` functions.

If the compiler signals that SSE is not available, loading and storing
mxcsr does not make sense anway, so in that case the inline functions
are empty.  This gives the minimum amount of code churn.

See also https://svnweb.freebsd.org/changeset/base/345283

Reviewers: emaste, jlpeyton, Hahnfeld

Reviewed By: jlpeyton

Subscribers: hfinkel, krytarowski, jdoerfert, openmp-commits, llvm-commits

Tags: #openmp

Differential Revision: https://reviews.llvm.org/D60916

llvm-svn: 360062
  • Loading branch information
DimitryAndric authored and MrSidims committed May 17, 2019
1 parent 3c72c9d commit 2dd7a42
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions openmp/runtime/src/kmp.h
Expand Up @@ -1243,16 +1243,22 @@ static inline void __kmp_clear_x87_fpu_status_word() {
__asm__ __volatile__("fnclex");
#endif // KMP_MIC
}
#if __SSE__
static inline void __kmp_load_mxcsr(const kmp_uint32 *p) { _mm_setcsr(*p); }
static inline void __kmp_store_mxcsr(kmp_uint32 *p) { *p = _mm_getcsr(); }
#else
static inline void __kmp_load_mxcsr(const kmp_uint32 *p) {}
static inline void __kmp_store_mxcsr(kmp_uint32 *p) { *p = 0; }
#endif
#else
// Windows still has these as external functions in assembly file
extern void __kmp_x86_cpuid(int mode, int mode2, struct kmp_cpuid *p);
extern void __kmp_load_x87_fpu_control_word(const kmp_int16 *p);
extern void __kmp_store_x87_fpu_control_word(kmp_int16 *p);
extern void __kmp_clear_x87_fpu_status_word();
#endif // KMP_OS_UNIX

#define __kmp_load_mxcsr(p) _mm_setcsr(*(p))
static inline void __kmp_load_mxcsr(const kmp_uint32 *p) { _mm_setcsr(*p); }
static inline void __kmp_store_mxcsr(kmp_uint32 *p) { *p = _mm_getcsr(); }
#endif // KMP_OS_UNIX

#define KMP_X86_MXCSR_MASK 0xffffffc0 /* ignore status flags (6 lsb) */

Expand Down

0 comments on commit 2dd7a42

Please sign in to comment.