-
Notifications
You must be signed in to change notification settings - Fork 132
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
Add VSX support #195
Add VSX support #195
Conversation
@shibatch ok , will do, do you which unit test in pytorch exercises sleef ? |
@avmgithub I don't fully understand you mean, but please check if ctest in sleef passes. |
@shibatch I cloned and checkedout commit ca35e1a . I hope that is the correct one. Here were my steps: here is the error: Once I corrected the error above. All built fine. I then ran "make test" 69% tests passed, 8 tests failed out of 26 Total Test time (real) = 29.56 sec The following tests FAILED: |
Can I see the output from cmake? |
sure , here it is |
Your compiler is too old. Try using clang-5 or later, or gcc-8. |
I'll see what I can do, unfortunately most of ppc64le users use the OS distro gcc. Right now we're supporting RH 7.4 which comes with gcc 4.8. Even if I switch to the latest Advanced Toolkit for ppc64le it only goes to gcc 7.3.1 and that becomes a problem with pytorch as pytorch only seem to support gcc 6. |
I see, but I think it's basically impossible to support VSX with gcc 4.8. |
Configure.cmake
Outdated
@@ -192,7 +208,7 @@ if(CMAKE_C_COMPILER_ID MATCHES "(GNU|Clang)") | |||
# src/arch/helpervecext.h:88 | |||
string(CONCAT FLAGS_WALL ${FLAGS_WALL} " -Wno-psabi") | |||
set(FLAGS_ENABLE_NEON32 "-mfpu=neon") | |||
endif(CMAKE_C_COMPILER_ID MATCHES "GNU") | |||
endif() |
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.
It is good practice to enclose the if condition in the endif
statement. We don't have a coding format, but i think we should keep it. Please revert this change.
src/dft-tester/fftwtest1d.c
Outdated
#include <time.h> | ||
|
||
#if defined(UNDEF_USE_EXTERN_INLINES) |
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 is a workaround specific to this patch. Could you please add a comment as you did in the CMakeLists.txt file?
src/dft-tester/fftwtest2d.c
Outdated
#include <time.h> | ||
|
||
#if defined(UNDEF_USE_EXTERN_INLINES) |
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 is a workaround specific to this patch. Could you please add a comment as you did in the CMakeLists.txt file?
src/dft-tester/measuredft.c
Outdated
#include <time.h> | ||
#include <unistd.h> | ||
#include <sys/time.h> | ||
|
||
#if defined(UNDEF_USE_EXTERN_INLINES) |
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 is a workaround specific to this patch. Could you please add a comment as you did in the CMakeLists.txt file?
src/dft-tester/naivetest.c
Outdated
@@ -7,9 +7,17 @@ | |||
#include <stdlib.h> | |||
#include <stdint.h> | |||
#include <assert.h> | |||
#include <time.h> | |||
|
|||
#if defined(UNDEF_USE_EXTERN_INLINES) |
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 is a workaround specific to this patch. Could you please add a comment as you did in the CMakeLists.txt file?
src/libm/sleefsimddp.c
Outdated
@@ -268,7 +277,7 @@ EXPORT CONST vdouble xsin(vdouble d) { | |||
d = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_C), d); | |||
d = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_C), d); | |||
d = vmla_vd_vd_vd_vd(vadd_vd_vd_vd(dqh, dql), vcast_vd_d(-PI_D), d); | |||
|
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.
Please don't change this line, we don't have a coding standard that enforces to remove lines with spaces.
src/libm/sleefsimddp.c
Outdated
@@ -289,7 +298,7 @@ EXPORT CONST vdouble xsin(vdouble d) { | |||
vor_vo_vo_vo(visnegzero_vo_vd(r), | |||
vgt_vo_vd_vd(vabs_vd_vd(r), vcast_vd_d(TRIGRANGEMAX)))), | |||
vcast_vd_d(-0.0), u); | |||
|
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.
Please don't change this line, we don't have a coding standard that enforces to remove lines with spaces.
char *vfloatname = argv[4]; | ||
char *vintname = argv[5]; | ||
char *vint2name = argv[6]; | ||
char *vdoublename = argv[3], *vdoublename_escspace = escapeSpace(vdoublename); |
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.
Can you do it the other way around, so that you don't have to change the variable used in the printf calls? We have a patch downstream that adds the AArch64 Vector PCS attribute [1] to the renaming functions (of course, we will upstream it), your changes will you be easier to merge if you leave the original name in the printf calls.
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.
Not all the arguments of printf calls are space-escaped.
I don't think of a good way of fulfilling your request.
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.
Let me put it this way: how is it possible that argv[3]
has spaces in it? Wouldn't a space break the argument in two arguments?
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.
In altivec or VSX intrinsics, vector data types are like "vector float".
https://gcc.gnu.org/onlinedocs/gcc/PowerPC-AltiVec_002fVSX-Built-in-Functions.html
http://openpowerfoundation.org/wp-content/uploads/resources/leabi/content/dbdoclet.50655245_56497.html
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.
Got it, thank you. Please add your useful answer as a comment to the definition of the function escapeSpace
.
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.
h
Hi @shibatch , sorry for bothering you again with this. I had a second (or maybe third!!) thought, and if my understanding is correctly, the following variables don't have space in their names, unless when targeting VSX:
vdoublename
vfloatname
vintname
vint2name
Given that the function escapeSpace
do not modify the values of those variables when not targeting VSX, I'd rather have you redefine them as follows:
char *vdoublename = escapeSpace(argv[3]);
char *vfloatname = escapeSpace(argv[4]);
char *vintname = escapeSpace(argv[5]);
char *vint2name = escapeSpace(argv[6]);
This should keep the functionality of the current patch, without the need to modify the variables name in the printf calls.
Configure.cmake
Outdated
|
||
# When cross compiling for ppc64, this bug-workaround is needed | ||
if(CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64") | ||
set(COMMON_TARGET_DEFINITIONS ${COMMON_TARGET_DEFINITIONS} UNDEF_USE_EXTERN_INLINES=1) |
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.
I have commented all the places where you use this define, asking to add a comment saying that the use of UNDEF_USE_EXTERN_INLINES
is platform specific.
I was thinking, instead of adding the comments, how about making the variable names specific to PPC64, so there is not doubt it target specific? May I ask you to change it to POWER64_UNDEF_USE_EXTERN_INLINES
? With this name change, I am happy for you to avoid adding the comments all around.
CHANGELOG.md
Outdated
@@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. | |||
- 3.5-ULP versions of sinh, cosh, tanh, sinhf, coshf, tanhf, and the | |||
corresponding testing functionalities are added. | |||
https://github.com/shibatch/sleef/pull/192 | |||
- Power VSX target support is added to libm. |
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.
Love this! :)
UPDATE: I just realized the changelog should say libsleef
, not libm
.
char *vfloatname = argv[4]; | ||
char *vintname = argv[5]; | ||
char *vint2name = argv[6]; | ||
char *vdoublename = argv[3], *vdoublename_escspace = escapeSpace(vdoublename); |
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.
Got it, thank you. Please add your useful answer as a comment to the definition of the function escapeSpace
.
char *vfloatname = argv[4]; | ||
char *vintname = argv[5]; | ||
char *vint2name = argv[6]; | ||
char *vdoublename = argv[3], *vdoublename_escspace = escapeSpace(vdoublename); |
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.
h
Hi @shibatch , sorry for bothering you again with this. I had a second (or maybe third!!) thought, and if my understanding is correctly, the following variables don't have space in their names, unless when targeting VSX:
vdoublename
vfloatname
vintname
vint2name
Given that the function escapeSpace
do not modify the values of those variables when not targeting VSX, I'd rather have you redefine them as follows:
char *vdoublename = escapeSpace(argv[3]);
char *vfloatname = escapeSpace(argv[4]);
char *vintname = escapeSpace(argv[5]);
char *vint2name = escapeSpace(argv[6]);
This should keep the functionality of the current patch, without the need to modify the variables name in the printf calls.
src/libm/mkrename.c
Outdated
@@ -10,6 +10,13 @@ | |||
|
|||
#include "funcproto.h" | |||
|
|||
char *escapeSpace(char *str) { | |||
char *ret = malloc(strlen(str) + 10); |
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 memory allocation is never released. you should modify the content of str
in place, and definitely not return ret
.
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.
I think this is harmless, but I added free for these variables.
The contents of vdoublename and other variables are used for its own type name and part of typedef name. So, we need both the original one and the replaced one. They cannot be unified. |
@shibatch Sigh - apologies, now I have seen it. Sorry for keeping you on this. |
Thank you for adding this new target @shibatch! This shows all the goodness of SLEEF! |
This patch adds support for POWER VSX.
clang-5.0 and later is supported at this time.
gcc-8 should be able to compile the VSX code, but I haven't checked.
@avmgithub Please check if this works on your environment.