-
Notifications
You must be signed in to change notification settings - Fork 0
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
NSIMD: Pass architecture choice to compiler #1
base: master
Are you sure you want to change the base?
Conversation
# Pass compiler options to Cactus | ||
echo "BEGIN DEFINE" | ||
echo "NSIMD_${NSIMD_SIMD}" | ||
echo "END DEFINE" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not capture everything NSIMD_OPTIONS
did in cactusamrex/NSIMD
. E.g. it cannot capture the (additional one assumes, even though defines.md
says "one of") flag NSIMD_FMA
.
Looking at the library it seems that NSIMD_OPTIONALS
is not actually used by anything (nor defined in configure.ccl
). So they might just as well be renamed to NSIMD_OPTIONS
and used as in cactusamrex/NSIMD
. Looking at defines.md
they should be present both in Cactus (via the DEFINE
) and when compiling the library itself, yes? An alternative (and more flexible since one can pass values) would be to have a NSIMD_EXTRA_CXXFLAGS
that can set these flags.
In my test it seems that cmake ../ -Dsimd=foobar
is accepted (literally) and foobar
is just what gets tagged on the the file name but is not used to actually set any SIMD extension :-(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be an outdated feature from a previous major release of NSIMD
. Currently the only important option is the architecture which is encoded in the library file name (e.g. sse2
, avx512
) used for linking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grr. GitHub ate my comment. Here we go again.
Alright, so I did some testing to see what the build system and compiler actually do.
I tested by removing or adding the the DEFINE
and CXXFLAGS=
bits of the commit.
I found that:
- for building
libNSIMD_AVX2.so
it is sufficient to have-Dsimd_AVX2
set via CMake to getvmovd
instructions show up in the disassembled output (andmovsd
if one usesNSIMD_SIMD=CPU
) so that fiddling with CXXFLAGS to build the library and have it use AVX2 is not required (have not testedFMA
). - for buidling client code (ie Cactus code using
nsimd_all.h
) I do seem to need theDEFINE
as tested using the NSIMDtutorial.cpp
which switches instructions used for themask_storeu
used based on whetherNSIMD_AVX2
is defined or not (vmovdqa
vsmovslq
).
The NSIMD_FMA
and NSIMD_AVX2
defines are checked for in nsimd.h
but not defined there based on any build time (of libNSIMD_AVX2.so) options as far as I can tell.
Test code is in a branch rhaas/nsimd-test and the disassembled code in the attached txt files (GitHub limits the allowed extensions).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might need we look into vectorization in Z4c benchmarks once more :-)
Define a preprocessor variable with the choice of SIMD architecture. If not set, NSIMD chooses a default.
0578f32
to
4598e8d
Compare
4598e8d
to
24a786e
Compare
I added code for the OPTIONALS (kept the variable name after all):
to build and DEFINE sections. This at least passes the defines to g++ when buliding NSIMD itself (and I see changes in the produced library file). |
Define a preprocessor variable with the choice of SIMD architecture. If not set, NSIMD chooses a default.