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. |
@@ -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() |
fpetrogalli
May 29, 2018
Collaborator
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.
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.
#include <time.h> | ||
|
||
#if defined(UNDEF_USE_EXTERN_INLINES) |
fpetrogalli
May 29, 2018
Collaborator
This is a workaround specific to this patch. Could you please add a comment as you did in the CMakeLists.txt file?
This is a workaround specific to this patch. Could you please add a comment as you did in the CMakeLists.txt file?
#include <time.h> | ||
|
||
#if defined(UNDEF_USE_EXTERN_INLINES) |
fpetrogalli
May 29, 2018
Collaborator
This is a workaround specific to this patch. Could you please add a comment as you did in the CMakeLists.txt file?
This is a workaround specific to this patch. Could you please add a comment as you did in the CMakeLists.txt file?
#include <time.h> | ||
#include <unistd.h> | ||
#include <sys/time.h> | ||
|
||
#if defined(UNDEF_USE_EXTERN_INLINES) |
fpetrogalli
May 29, 2018
Collaborator
This is a workaround specific to this patch. Could you please add a comment as you did in the CMakeLists.txt file?
This is a workaround specific to this patch. Could you please add a comment as you did in the CMakeLists.txt file?
@@ -7,9 +7,17 @@ | |||
#include <stdlib.h> | |||
#include <stdint.h> | |||
#include <assert.h> | |||
#include <time.h> | |||
|
|||
#if defined(UNDEF_USE_EXTERN_INLINES) |
fpetrogalli
May 29, 2018
Collaborator
This is a workaround specific to this patch. Could you please add a comment as you did in the CMakeLists.txt file?
This is a workaround specific to this patch. Could you please add a comment as you did in the CMakeLists.txt file?
@@ -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); | |||
|
fpetrogalli
May 29, 2018
Collaborator
Please don't change this line, we don't have a coding standard that enforces to remove lines with spaces.
Please don't change this line, we don't have a coding standard that enforces to remove lines with spaces.
@@ -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); | |||
|
fpetrogalli
May 29, 2018
Collaborator
Please don't change this line, we don't have a coding standard that enforces to remove lines with spaces.
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); |
fpetrogalli
May 29, 2018
Collaborator
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.
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.
shibatch
May 30, 2018
Author
Owner
Not all the arguments of printf calls are space-escaped.
I don't think of a good way of fulfilling your request.
Not all the arguments of printf calls are space-escaped.
I don't think of a good way of fulfilling your request.
fpetrogalli
May 30, 2018
Collaborator
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?
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?
shibatch
May 30, 2018
Author
Owner
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
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
fpetrogalli
May 30, 2018
Collaborator
Got it, thank you. Please add your useful answer as a comment to the definition of the function escapeSpace
.
Got it, thank you. Please add your useful answer as a comment to the definition of the function escapeSpace
.
fpetrogalli
May 30, 2018
Collaborator
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.
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.
|
||
# 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) |
fpetrogalli
May 29, 2018
Collaborator
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.
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.
@@ -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. |
fpetrogalli
May 29, 2018
•
Collaborator
Love this! :)
UPDATE: I just realized the changelog should say libsleef
, not libm
.
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); |
fpetrogalli
May 30, 2018
Collaborator
Got it, thank you. Please add your useful answer as a comment to the definition of the function escapeSpace
.
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); |
fpetrogalli
May 30, 2018
Collaborator
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.
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.
@@ -10,6 +10,13 @@ | |||
|
|||
#include "funcproto.h" | |||
|
|||
char *escapeSpace(char *str) { | |||
char *ret = malloc(strlen(str) + 10); |
fpetrogalli
May 30, 2018
Collaborator
This memory allocation is never released. you should modify the content of str
in place, and definitely not return ret
.
This memory allocation is never released. you should modify the content of str
in place, and definitely not return ret
.
shibatch
May 30, 2018
Author
Owner
I think this is harmless, but I added free for these variables.
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.