From 0bff057a874a706e25ac5e02474327ed50f95444 Mon Sep 17 00:00:00 2001 From: Werner Saar Date: Fri, 25 Mar 2016 13:03:02 +0100 Subject: [PATCH 1/6] added optimized dcopy kernel for POWER8 --- kernel/power/KERNEL.POWER8 | 2 +- kernel/power/dcopy.c | 131 ++++++++++++++++++++++ kernel/power/dcopy_microk_power8.c | 174 +++++++++++++++++++++++++++++ 3 files changed, 306 insertions(+), 1 deletion(-) create mode 100644 kernel/power/dcopy.c create mode 100644 kernel/power/dcopy_microk_power8.c diff --git a/kernel/power/KERNEL.POWER8 b/kernel/power/KERNEL.POWER8 index 5fb44cbdb..a0e4ac3f9 100644 --- a/kernel/power/KERNEL.POWER8 +++ b/kernel/power/KERNEL.POWER8 @@ -116,7 +116,7 @@ DAXPYKERNEL = daxpy.c ZAXPYKERNEL = zaxpy.c # #SCOPYKERNEL = ../arm/copy.c -#DCOPYKERNEL = ../arm/copy.c +DCOPYKERNEL = dcopy.c #CCOPYKERNEL = ../arm/zcopy.c #ZCOPYKERNEL = ../arm/zcopy.c # diff --git a/kernel/power/dcopy.c b/kernel/power/dcopy.c new file mode 100644 index 000000000..059c0e5a9 --- /dev/null +++ b/kernel/power/dcopy.c @@ -0,0 +1,131 @@ +/*************************************************************************** +Copyright (c) 2013-2016, The OpenBLAS Project +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the +distribution. +3. Neither the name of the OpenBLAS project nor the names of +its contributors may be used to endorse or promote products +derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*****************************************************************************/ + +/************************************************************************************** +* 2016/03/25 Werner Saar (wernsaar@googlemail.com) +* BLASTEST : OK +* CTEST : OK +* TEST : OK +* LAPACK-TEST : OK +**************************************************************************************/ + +#include "common.h" + +#if defined(POWER8) +#include "dcopy_microk_power8.c" +#endif + +#ifndef HAVE_KERNEL_32 + +static void dcopy_kernel_32(BLASLONG n, FLOAT *x, FLOAT *y) +{ + + BLASLONG i=0; + FLOAT f0, f1, f2, f3, f4, f5, f6, f7; + FLOAT *x1=x; + FLOAT *y1=y; + + while ( i 0 ) + { + dcopy_kernel_32(n1, x, y); + i=n1; + } + + while(i < n) + { + y[i] = x[i] ; + i++ ; + + } + + + } + else + { + + while(i < n) + { + y[iy] = x[ix] ; + ix += inc_x ; + iy += inc_y ; + i++ ; + + } + + } + return(0); + + +} + + diff --git a/kernel/power/dcopy_microk_power8.c b/kernel/power/dcopy_microk_power8.c new file mode 100644 index 000000000..04f7db556 --- /dev/null +++ b/kernel/power/dcopy_microk_power8.c @@ -0,0 +1,174 @@ +/*************************************************************************** +Copyright (c) 2013-2016, The OpenBLAS Project +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the +distribution. +3. Neither the name of the OpenBLAS project nor the names of +its contributors may be used to endorse or promote products +derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*****************************************************************************/ + +/************************************************************************************** +* 2016/03/25 Werner Saar (wernsaar@googlemail.com) +* BLASTEST : OK +* CTEST : OK +* TEST : OK +* LAPACK-TEST : OK +**************************************************************************************/ + +#define HAVE_KERNEL_32 1 + +static void dcopy_kernel_32( BLASLONG n, FLOAT *x, FLOAT *y) __attribute__ ((noinline)); + +static void dcopy_kernel_32( BLASLONG n, FLOAT *x, FLOAT *y) +{ + + + BLASLONG i = n; + BLASLONG o16 = 16; + BLASLONG o32 = 32; + BLASLONG o48 = 48; + BLASLONG o64 = 64; + BLASLONG o80 = 80; + BLASLONG o96 = 96; + BLASLONG o112 = 112; + FLOAT *x1=x; + FLOAT *y1=y; + BLASLONG pre = 384; + BLASLONG alpha=0; + + __asm__ __volatile__ + ( + + "lxvd2x 40, 0, %2 \n\t" + "lxvd2x 41, %5, %2 \n\t" + "lxvd2x 42, %6, %2 \n\t" + "lxvd2x 43, %7, %2 \n\t" + "lxvd2x 44, %8, %2 \n\t" + "lxvd2x 45, %9, %2 \n\t" + "lxvd2x 46, %10, %2 \n\t" + "lxvd2x 47, %11, %2 \n\t" + + "addi %2, %2, 128 \n\t" + + "lxvd2x 50, 0, %2 \n\t" + "lxvd2x 51, %5, %2 \n\t" + "lxvd2x 52, %6, %2 \n\t" + "lxvd2x 53, %7, %2 \n\t" + "lxvd2x 54, %8, %2 \n\t" + "lxvd2x 55, %9, %2 \n\t" + "lxvd2x 56, %10, %2 \n\t" + "lxvd2x 57, %11, %2 \n\t" + + "addi %2, %2, 128 \n\t" + + "addic. %0 , %0 , -32 \n\t" + "ble 2f \n\t" + + ".align 5 \n\t" + "1: \n\t" + + "stxvd2x 40, 0, %1 \n\t" + "stxvd2x 41, %5, %1 \n\t" + "lxvd2x 40, 0, %2 \n\t" + "lxvd2x 41, %5, %2 \n\t" + "stxvd2x 42, %6, %1 \n\t" + "stxvd2x 43, %7, %1 \n\t" + "lxvd2x 42, %6, %2 \n\t" + "lxvd2x 43, %7, %2 \n\t" + "stxvd2x 44, %8, %1 \n\t" + "stxvd2x 45, %9, %1 \n\t" + "lxvd2x 44, %8, %2 \n\t" + "lxvd2x 45, %9, %2 \n\t" + "stxvd2x 46, %10, %1 \n\t" + "stxvd2x 47, %11, %1 \n\t" + "lxvd2x 46, %10, %2 \n\t" + "lxvd2x 47, %11, %2 \n\t" + + + "addi %1, %1, 128 \n\t" + "addi %2, %2, 128 \n\t" + + "stxvd2x 50, 0, %1 \n\t" + "stxvd2x 51, %5, %1 \n\t" + "lxvd2x 50, 0, %2 \n\t" + "lxvd2x 51, %5, %2 \n\t" + "stxvd2x 52, %6, %1 \n\t" + "stxvd2x 53, %7, %1 \n\t" + "lxvd2x 52, %6, %2 \n\t" + "lxvd2x 53, %7, %2 \n\t" + "stxvd2x 54, %8, %1 \n\t" + "stxvd2x 55, %9, %1 \n\t" + "lxvd2x 54, %8, %2 \n\t" + "lxvd2x 55, %9, %2 \n\t" + "stxvd2x 56, %10, %1 \n\t" + "stxvd2x 57, %11, %1 \n\t" + "lxvd2x 56, %10, %2 \n\t" + "lxvd2x 57, %11, %2 \n\t" + + "addi %1, %1, 128 \n\t" + "addi %2, %2, 128 \n\t" + + "addic. %0 , %0 , -32 \n\t" + "bgt 1b \n\t" + + "2: \n\t" + + "stxvd2x 40, 0, %1 \n\t" + "stxvd2x 41, %5, %1 \n\t" + "stxvd2x 42, %6, %1 \n\t" + "stxvd2x 43, %7, %1 \n\t" + "stxvd2x 44, %8, %1 \n\t" + "stxvd2x 45, %9, %1 \n\t" + "stxvd2x 46, %10, %1 \n\t" + "stxvd2x 47, %11, %1 \n\t" + + "addi %1, %1, 128 \n\t" + + "stxvd2x 50, 0, %1 \n\t" + "stxvd2x 51, %5, %1 \n\t" + "stxvd2x 52, %6, %1 \n\t" + "stxvd2x 53, %7, %1 \n\t" + "stxvd2x 54, %8, %1 \n\t" + "stxvd2x 55, %9, %1 \n\t" + "stxvd2x 56, %10, %1 \n\t" + "stxvd2x 57, %11, %1 \n\t" + + + : + : + "r" (i), // 0 + "r" (y1), // 1 + "r" (x1), // 2 + "r" (alpha), // 3 + "r" (pre), // 4 + "r" (o16), // 5 + "r" (o32), // 6 + "r" (o48), // 7 + "r" (o64), // 8 + "r" (o80), // 9 + "r" (o96), // 10 + "r" (o112) // 11 + : "cr0", "%0", "%2" , "%1", "memory" + ); + +} + + From 7316a879301235148c0501ad3f6be243a48a1b58 Mon Sep 17 00:00:00 2001 From: Werner Saar Date: Fri, 25 Mar 2016 14:35:43 +0100 Subject: [PATCH 2/6] added optimized dswap kernel for POWER8 --- kernel/power/KERNEL.POWER8 | 2 +- kernel/power/dswap.c | 154 ++++++++++++++++++++++++ kernel/power/dswap_microk_power8.c | 180 +++++++++++++++++++++++++++++ 3 files changed, 335 insertions(+), 1 deletion(-) create mode 100644 kernel/power/dswap.c create mode 100644 kernel/power/dswap_microk_power8.c diff --git a/kernel/power/KERNEL.POWER8 b/kernel/power/KERNEL.POWER8 index a0e4ac3f9..fc6a729fe 100644 --- a/kernel/power/KERNEL.POWER8 +++ b/kernel/power/KERNEL.POWER8 @@ -141,7 +141,7 @@ DSCALKERNEL = dscal.c #ZSCALKERNEL = zscal.c # #SSWAPKERNEL = ../arm/swap.c -#DSWAPKERNEL = ../arm/swap.c +DSWAPKERNEL = dswap.c #CSWAPKERNEL = ../arm/zswap.c #ZSWAPKERNEL = ../arm/zswap.c # diff --git a/kernel/power/dswap.c b/kernel/power/dswap.c new file mode 100644 index 000000000..fd2dec9c4 --- /dev/null +++ b/kernel/power/dswap.c @@ -0,0 +1,154 @@ +/*************************************************************************** +Copyright (c) 2013-2016, The OpenBLAS Project +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the +distribution. +3. Neither the name of the OpenBLAS project nor the names of +its contributors may be used to endorse or promote products +derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*****************************************************************************/ + +/************************************************************************************** +* 2016/03/25 Werner Saar (wernsaar@googlemail.com) +* BLASTEST : OK +* CTEST : OK +* TEST : OK +* LAPACK-TEST : OK +**************************************************************************************/ + +#include "common.h" + +#if defined(POWER8) +#include "dswap_microk_power8.c" +#endif + +#ifndef HAVE_KERNEL_32 + +static void dswap_kernel_32(BLASLONG n, FLOAT *x, FLOAT *y) +{ + + BLASLONG i=0; + FLOAT f0, f1, f2, f3, f4, f5, f6, f7; + FLOAT g0, g1, g2, g3, g4, g5, g6, g7; + FLOAT *x1=x; + FLOAT *y1=y; + + while ( i 0 ) + { + dswap_kernel_32(n1, x, y); + i=n1; + } + + while(i < n) + { + temp = y[i]; + y[i] = x[i] ; + x[i] = temp; + i++ ; + + } + + + } + else + { + + while(i < n) + { + temp = y[iy]; + y[iy] = x[ix] ; + x[ix] = temp; + ix += inc_x ; + iy += inc_y ; + i++ ; + + } + + } + return(0); + + +} + + diff --git a/kernel/power/dswap_microk_power8.c b/kernel/power/dswap_microk_power8.c new file mode 100644 index 000000000..77747c3b9 --- /dev/null +++ b/kernel/power/dswap_microk_power8.c @@ -0,0 +1,180 @@ +/*************************************************************************** +Copyright (c) 2013-2016, The OpenBLAS Project +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the +distribution. +3. Neither the name of the OpenBLAS project nor the names of +its contributors may be used to endorse or promote products +derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*****************************************************************************/ + +/************************************************************************************** +* 2016/03/25 Werner Saar (wernsaar@googlemail.com) +* BLASTEST : OK +* CTEST : OK +* TEST : OK +* LAPACK-TEST : OK +**************************************************************************************/ + +#define HAVE_KERNEL_32 1 + +static void dswap_kernel_32( BLASLONG n, FLOAT *x, FLOAT *y) __attribute__ ((noinline)); + +static void dswap_kernel_32( BLASLONG n, FLOAT *x, FLOAT *y) +{ + + + BLASLONG i = n; + BLASLONG o16 = 16; + BLASLONG o32 = 32; + BLASLONG o48 = 48; + BLASLONG o64 = 64; + BLASLONG o80 = 80; + BLASLONG o96 = 96; + BLASLONG o112 = 112; + FLOAT *x1=x; + FLOAT *y1=y; + FLOAT *x2=x+1; + FLOAT *y2=y+1; + BLASLONG pre = 384; + BLASLONG alpha=0; + + __asm__ __volatile__ + ( + + "addi %3, %3, -8 \n\t" + "addi %4, %4, -8 \n\t" + + ".align 5 \n\t" + "1: \n\t" + + "lxvd2x 32, 0, %2 \n\t" + "lxvd2x 33, %5, %2 \n\t" + "lxvd2x 34, %6, %2 \n\t" + "lxvd2x 35, %7, %2 \n\t" + "lxvd2x 36, %8, %2 \n\t" + "lxvd2x 37, %9, %2 \n\t" + "lxvd2x 38, %10, %2 \n\t" + "lxvd2x 39, %11, %2 \n\t" + + "addi %2, %2, 128 \n\t" + + "lxvd2x 40, 0, %2 \n\t" + "lxvd2x 41, %5, %2 \n\t" + "lxvd2x 42, %6, %2 \n\t" + "lxvd2x 43, %7, %2 \n\t" + "lxvd2x 44, %8, %2 \n\t" + "lxvd2x 45, %9, %2 \n\t" + "lxvd2x 46, %10, %2 \n\t" + "lxvd2x 47, %11, %2 \n\t" + + "addi %2, %2, 128 \n\t" + + "lxvd2x 48, 0, %1 \n\t" + "lxvd2x 49, %5, %1 \n\t" + "lxvd2x 50, %6, %1 \n\t" + "lxvd2x 51, %7, %1 \n\t" + "lxvd2x 52, %8, %1 \n\t" + "lxvd2x 53, %9, %1 \n\t" + "lxvd2x 54, %10, %1 \n\t" + "lxvd2x 55, %11, %1 \n\t" + + "addi %1, %1, 128 \n\t" + + "lxvd2x 56, 0, %1 \n\t" + "lxvd2x 57, %5, %1 \n\t" + "lxvd2x 58, %6, %1 \n\t" + "lxvd2x 59, %7, %1 \n\t" + "lxvd2x 60, %8, %1 \n\t" + "lxvd2x 61, %9, %1 \n\t" + "lxvd2x 62, %10, %1 \n\t" + "lxvd2x 63, %11, %1 \n\t" + + "addi %1, %1, 128 \n\t" + + "stxvd2x 32, 0, %3 \n\t" + "stxvd2x 33, %5, %3 \n\t" + "stxvd2x 34, %6, %3 \n\t" + "stxvd2x 35, %7, %3 \n\t" + "stxvd2x 36, %8, %3 \n\t" + "stxvd2x 37, %9, %3 \n\t" + "stxvd2x 38, %10, %3 \n\t" + "stxvd2x 39, %11, %3 \n\t" + + "addi %3, %3, 128 \n\t" + + "stxvd2x 40, 0, %3 \n\t" + "stxvd2x 41, %5, %3 \n\t" + "stxvd2x 42, %6, %3 \n\t" + "stxvd2x 43, %7, %3 \n\t" + "stxvd2x 44, %8, %3 \n\t" + "stxvd2x 45, %9, %3 \n\t" + "stxvd2x 46, %10, %3 \n\t" + "stxvd2x 47, %11, %3 \n\t" + + "addi %3, %3, 128 \n\t" + + "stxvd2x 48, 0, %4 \n\t" + "stxvd2x 49, %5, %4 \n\t" + "stxvd2x 50, %6, %4 \n\t" + "stxvd2x 51, %7, %4 \n\t" + "stxvd2x 52, %8, %4 \n\t" + "stxvd2x 53, %9, %4 \n\t" + "stxvd2x 54, %10, %4 \n\t" + "stxvd2x 55, %11, %4 \n\t" + + "addi %4, %4, 128 \n\t" + + "stxvd2x 56, 0, %4 \n\t" + "stxvd2x 57, %5, %4 \n\t" + "stxvd2x 58, %6, %4 \n\t" + "stxvd2x 59, %7, %4 \n\t" + "stxvd2x 60, %8, %4 \n\t" + "stxvd2x 61, %9, %4 \n\t" + "stxvd2x 62, %10, %4 \n\t" + "stxvd2x 63, %11, %4 \n\t" + + "addi %4, %4, 128 \n\t" + + "addic. %0 , %0 , -32 \n\t" + "bgt 1b \n\t" + + "2: \n\t" + + : + : + "r" (i), // 0 + "r" (y1), // 1 + "r" (x1), // 2 + "r" (y2), // 3 + "r" (x2), // 4 + "r" (o16), // 5 + "r" (o32), // 6 + "r" (o48), // 7 + "r" (o64), // 8 + "r" (o80), // 9 + "r" (o96), // 10 + "r" (o112) // 11 + : "cr0", "%0", "%2" , "%1", "%3", "%4", "memory" + ); + +} + + From 12f209b7b0bfbb2f6dda8c7259187b161a03511f Mon Sep 17 00:00:00 2001 From: Werner Saar Date: Fri, 25 Mar 2016 15:27:34 +0100 Subject: [PATCH 3/6] added optimized zswap kernel for POWER8 --- kernel/power/KERNEL.POWER8 | 2 +- kernel/power/zcopy.c | 140 +++++++++++++++++++++++ kernel/power/zcopy_microk_power8.c | 174 +++++++++++++++++++++++++++++ 3 files changed, 315 insertions(+), 1 deletion(-) create mode 100644 kernel/power/zcopy.c create mode 100644 kernel/power/zcopy_microk_power8.c diff --git a/kernel/power/KERNEL.POWER8 b/kernel/power/KERNEL.POWER8 index fc6a729fe..4f410b005 100644 --- a/kernel/power/KERNEL.POWER8 +++ b/kernel/power/KERNEL.POWER8 @@ -118,7 +118,7 @@ ZAXPYKERNEL = zaxpy.c #SCOPYKERNEL = ../arm/copy.c DCOPYKERNEL = dcopy.c #CCOPYKERNEL = ../arm/zcopy.c -#ZCOPYKERNEL = ../arm/zcopy.c +ZCOPYKERNEL = zcopy.c # SDOTKERNEL = sdot.c DDOTKERNEL = ddot.c diff --git a/kernel/power/zcopy.c b/kernel/power/zcopy.c new file mode 100644 index 000000000..a7658f7ab --- /dev/null +++ b/kernel/power/zcopy.c @@ -0,0 +1,140 @@ +/*************************************************************************** +Copyright (c) 2013-2016, The OpenBLAS Project +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the +distribution. +3. Neither the name of the OpenBLAS project nor the names of +its contributors may be used to endorse or promote products +derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*****************************************************************************/ + +/************************************************************************************** +* 2016/03/25 Werner Saar (wernsaar@googlemail.com) +* BLASTEST : OK +* CTEST : OK +* TEST : OK +* LAPACK-TEST : OK +**************************************************************************************/ + +#include "common.h" + +#if defined(POWER8) +#include "zcopy_microk_power8.c" +#endif + +#ifndef HAVE_KERNEL_16 + +static void zcopy_kernel_16(BLASLONG n, FLOAT *x, FLOAT *y) +{ + + BLASLONG i=0; + FLOAT f0, f1, f2, f3, f4, f5, f6, f7; + FLOAT *x1=x; + FLOAT *y1=y; + + while ( i 0 ) + { + zcopy_kernel_16(n1, x, y); + i=n1; + ix=n1*2; + iy=n1*2; + } + + while(i < n) + { + y[iy] = x[iy] ; + y[iy+1] = x[ix+1] ; + ix+=2; + iy+=2; + i++ ; + + } + + + } + else + { + + BLASLONG inc_x2 = 2 * inc_x; + BLASLONG inc_y2 = 2 * inc_y; + + while(i < n) + { + y[iy] = x[ix] ; + y[iy+1] = x[ix+1] ; + ix += inc_x2 ; + iy += inc_y2 ; + i++ ; + + } + + } + return(0); + + +} + + diff --git a/kernel/power/zcopy_microk_power8.c b/kernel/power/zcopy_microk_power8.c new file mode 100644 index 000000000..73abe084e --- /dev/null +++ b/kernel/power/zcopy_microk_power8.c @@ -0,0 +1,174 @@ +/*************************************************************************** +Copyright (c) 2013-2016, The OpenBLAS Project +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the +distribution. +3. Neither the name of the OpenBLAS project nor the names of +its contributors may be used to endorse or promote products +derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*****************************************************************************/ + +/************************************************************************************** +* 2016/03/25 Werner Saar (wernsaar@googlemail.com) +* BLASTEST : OK +* CTEST : OK +* TEST : OK +* LAPACK-TEST : OK +**************************************************************************************/ + +#define HAVE_KERNEL_16 1 + +static void zcopy_kernel_16( BLASLONG n, FLOAT *x, FLOAT *y) __attribute__ ((noinline)); + +static void zcopy_kernel_16( BLASLONG n, FLOAT *x, FLOAT *y) +{ + + + BLASLONG i = n; + BLASLONG o16 = 16; + BLASLONG o32 = 32; + BLASLONG o48 = 48; + BLASLONG o64 = 64; + BLASLONG o80 = 80; + BLASLONG o96 = 96; + BLASLONG o112 = 112; + FLOAT *x1=x; + FLOAT *y1=y; + BLASLONG pre = 384; + BLASLONG alpha=0; + + __asm__ __volatile__ + ( + + "lxvd2x 40, 0, %2 \n\t" + "lxvd2x 41, %5, %2 \n\t" + "lxvd2x 42, %6, %2 \n\t" + "lxvd2x 43, %7, %2 \n\t" + "lxvd2x 44, %8, %2 \n\t" + "lxvd2x 45, %9, %2 \n\t" + "lxvd2x 46, %10, %2 \n\t" + "lxvd2x 47, %11, %2 \n\t" + + "addi %2, %2, 128 \n\t" + + "lxvd2x 50, 0, %2 \n\t" + "lxvd2x 51, %5, %2 \n\t" + "lxvd2x 52, %6, %2 \n\t" + "lxvd2x 53, %7, %2 \n\t" + "lxvd2x 54, %8, %2 \n\t" + "lxvd2x 55, %9, %2 \n\t" + "lxvd2x 56, %10, %2 \n\t" + "lxvd2x 57, %11, %2 \n\t" + + "addi %2, %2, 128 \n\t" + + "addic. %0 , %0 , -16 \n\t" + "ble 2f \n\t" + + ".align 5 \n\t" + "1: \n\t" + + "stxvd2x 40, 0, %1 \n\t" + "stxvd2x 41, %5, %1 \n\t" + "lxvd2x 40, 0, %2 \n\t" + "lxvd2x 41, %5, %2 \n\t" + "stxvd2x 42, %6, %1 \n\t" + "stxvd2x 43, %7, %1 \n\t" + "lxvd2x 42, %6, %2 \n\t" + "lxvd2x 43, %7, %2 \n\t" + "stxvd2x 44, %8, %1 \n\t" + "stxvd2x 45, %9, %1 \n\t" + "lxvd2x 44, %8, %2 \n\t" + "lxvd2x 45, %9, %2 \n\t" + "stxvd2x 46, %10, %1 \n\t" + "stxvd2x 47, %11, %1 \n\t" + "lxvd2x 46, %10, %2 \n\t" + "lxvd2x 47, %11, %2 \n\t" + + + "addi %1, %1, 128 \n\t" + "addi %2, %2, 128 \n\t" + + "stxvd2x 50, 0, %1 \n\t" + "stxvd2x 51, %5, %1 \n\t" + "lxvd2x 50, 0, %2 \n\t" + "lxvd2x 51, %5, %2 \n\t" + "stxvd2x 52, %6, %1 \n\t" + "stxvd2x 53, %7, %1 \n\t" + "lxvd2x 52, %6, %2 \n\t" + "lxvd2x 53, %7, %2 \n\t" + "stxvd2x 54, %8, %1 \n\t" + "stxvd2x 55, %9, %1 \n\t" + "lxvd2x 54, %8, %2 \n\t" + "lxvd2x 55, %9, %2 \n\t" + "stxvd2x 56, %10, %1 \n\t" + "stxvd2x 57, %11, %1 \n\t" + "lxvd2x 56, %10, %2 \n\t" + "lxvd2x 57, %11, %2 \n\t" + + "addi %1, %1, 128 \n\t" + "addi %2, %2, 128 \n\t" + + "addic. %0 , %0 , -16 \n\t" + "bgt 1b \n\t" + + "2: \n\t" + + "stxvd2x 40, 0, %1 \n\t" + "stxvd2x 41, %5, %1 \n\t" + "stxvd2x 42, %6, %1 \n\t" + "stxvd2x 43, %7, %1 \n\t" + "stxvd2x 44, %8, %1 \n\t" + "stxvd2x 45, %9, %1 \n\t" + "stxvd2x 46, %10, %1 \n\t" + "stxvd2x 47, %11, %1 \n\t" + + "addi %1, %1, 128 \n\t" + + "stxvd2x 50, 0, %1 \n\t" + "stxvd2x 51, %5, %1 \n\t" + "stxvd2x 52, %6, %1 \n\t" + "stxvd2x 53, %7, %1 \n\t" + "stxvd2x 54, %8, %1 \n\t" + "stxvd2x 55, %9, %1 \n\t" + "stxvd2x 56, %10, %1 \n\t" + "stxvd2x 57, %11, %1 \n\t" + + + : + : + "r" (i), // 0 + "r" (y1), // 1 + "r" (x1), // 2 + "r" (alpha), // 3 + "r" (pre), // 4 + "r" (o16), // 5 + "r" (o32), // 6 + "r" (o48), // 7 + "r" (o64), // 8 + "r" (o80), // 9 + "r" (o96), // 10 + "r" (o112) // 11 + : "cr0", "%0", "%2" , "%1", "memory" + ); + +} + + From ecc0bc981313fa94ad5ae1ef22288733cc6fd18a Mon Sep 17 00:00:00 2001 From: Werner Saar Date: Fri, 25 Mar 2016 16:06:56 +0100 Subject: [PATCH 4/6] added optimized scopy kernel for POWER8 --- kernel/power/KERNEL.POWER8 | 2 +- kernel/power/scopy.c | 131 +++++++++++++++++++++++++++++ kernel/power/scopy_microk_power8.c | 131 +++++++++++++++++++++++++++++ 3 files changed, 263 insertions(+), 1 deletion(-) create mode 100644 kernel/power/scopy.c create mode 100644 kernel/power/scopy_microk_power8.c diff --git a/kernel/power/KERNEL.POWER8 b/kernel/power/KERNEL.POWER8 index 4f410b005..dee0c2660 100644 --- a/kernel/power/KERNEL.POWER8 +++ b/kernel/power/KERNEL.POWER8 @@ -115,7 +115,7 @@ DAXPYKERNEL = daxpy.c #CAXPYKERNEL = ../arm/zaxpy.c ZAXPYKERNEL = zaxpy.c # -#SCOPYKERNEL = ../arm/copy.c +SCOPYKERNEL = scopy.c DCOPYKERNEL = dcopy.c #CCOPYKERNEL = ../arm/zcopy.c ZCOPYKERNEL = zcopy.c diff --git a/kernel/power/scopy.c b/kernel/power/scopy.c new file mode 100644 index 000000000..167c29bab --- /dev/null +++ b/kernel/power/scopy.c @@ -0,0 +1,131 @@ +/*************************************************************************** +Copyright (c) 2013-2016, The OpenBLAS Project +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the +distribution. +3. Neither the name of the OpenBLAS project nor the names of +its contributors may be used to endorse or promote products +derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*****************************************************************************/ + +/************************************************************************************** +* 2016/03/25 Werner Saar (wernsaar@googlemail.com) +* BLASTEST : OK +* CTEST : OK +* TEST : OK +* LAPACK-TEST : OK +**************************************************************************************/ + +#include "common.h" + +#if defined(POWER8) +#include "scopy_microk_power8.c" +#endif + +#ifndef HAVE_KERNEL_32 + +static void scopy_kernel_32(BLASLONG n, FLOAT *x, FLOAT *y) +{ + + BLASLONG i=0; + FLOAT f0, f1, f2, f3, f4, f5, f6, f7; + FLOAT *x1=x; + FLOAT *y1=y; + + while ( i 0 ) + { + scopy_kernel_32(n1, x, y); + i=n1; + } + + while(i < n) + { + y[i] = x[i] ; + i++ ; + + } + + + } + else + { + + while(i < n) + { + y[iy] = x[ix] ; + ix += inc_x ; + iy += inc_y ; + i++ ; + + } + + } + return(0); + + +} + + diff --git a/kernel/power/scopy_microk_power8.c b/kernel/power/scopy_microk_power8.c new file mode 100644 index 000000000..2e08e3561 --- /dev/null +++ b/kernel/power/scopy_microk_power8.c @@ -0,0 +1,131 @@ +/*************************************************************************** +Copyright (c) 2013-2016, The OpenBLAS Project +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the +distribution. +3. Neither the name of the OpenBLAS project nor the names of +its contributors may be used to endorse or promote products +derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*****************************************************************************/ + +/************************************************************************************** +* 2016/03/25 Werner Saar (wernsaar@googlemail.com) +* BLASTEST : OK +* CTEST : OK +* TEST : OK +* LAPACK-TEST : OK +**************************************************************************************/ + +#define HAVE_KERNEL_32 1 + +static void scopy_kernel_32( BLASLONG n, FLOAT *x, FLOAT *y) __attribute__ ((noinline)); + +static void scopy_kernel_32( BLASLONG n, FLOAT *x, FLOAT *y) +{ + + + BLASLONG i = n; + BLASLONG o16 = 16; + BLASLONG o32 = 32; + BLASLONG o48 = 48; + BLASLONG o64 = 64; + BLASLONG o80 = 80; + BLASLONG o96 = 96; + BLASLONG o112 = 112; + FLOAT *x1=x; + FLOAT *y1=y; + BLASLONG pre = 384; + BLASLONG alpha=0; + + __asm__ __volatile__ + ( + + "lxvw4x 40, 0, %2 \n\t" + "lxvw4x 41, %5, %2 \n\t" + "lxvw4x 42, %6, %2 \n\t" + "lxvw4x 43, %7, %2 \n\t" + "lxvw4x 44, %8, %2 \n\t" + "lxvw4x 45, %9, %2 \n\t" + "lxvw4x 46, %10, %2 \n\t" + "lxvw4x 47, %11, %2 \n\t" + + "addi %2, %2, 128 \n\t" + + "addic. %0 , %0 , -32 \n\t" + "ble 2f \n\t" + + ".align 5 \n\t" + "1: \n\t" + + "stxvw4x 40, 0, %1 \n\t" + "stxvw4x 41, %5, %1 \n\t" + "lxvw4x 40, 0, %2 \n\t" + "lxvw4x 41, %5, %2 \n\t" + "stxvw4x 42, %6, %1 \n\t" + "stxvw4x 43, %7, %1 \n\t" + "lxvw4x 42, %6, %2 \n\t" + "lxvw4x 43, %7, %2 \n\t" + "stxvw4x 44, %8, %1 \n\t" + "stxvw4x 45, %9, %1 \n\t" + "lxvw4x 44, %8, %2 \n\t" + "lxvw4x 45, %9, %2 \n\t" + "stxvw4x 46, %10, %1 \n\t" + "stxvw4x 47, %11, %1 \n\t" + "lxvw4x 46, %10, %2 \n\t" + "lxvw4x 47, %11, %2 \n\t" + + + "addi %1, %1, 128 \n\t" + "addi %2, %2, 128 \n\t" + + "addic. %0 , %0 , -32 \n\t" + "bgt 1b \n\t" + + "2: \n\t" + + "stxvw4x 40, 0, %1 \n\t" + "stxvw4x 41, %5, %1 \n\t" + "stxvw4x 42, %6, %1 \n\t" + "stxvw4x 43, %7, %1 \n\t" + "stxvw4x 44, %8, %1 \n\t" + "stxvw4x 45, %9, %1 \n\t" + "stxvw4x 46, %10, %1 \n\t" + "stxvw4x 47, %11, %1 \n\t" + + : + : + "r" (i), // 0 + "r" (y1), // 1 + "r" (x1), // 2 + "r" (alpha), // 3 + "r" (pre), // 4 + "r" (o16), // 5 + "r" (o32), // 6 + "r" (o48), // 7 + "r" (o64), // 8 + "r" (o80), // 9 + "r" (o96), // 10 + "r" (o112) // 11 + : "cr0", "%0", "%2" , "%1", "memory" + ); + +} + + From 828c849b446723401e10d05f0974d57982adab09 Mon Sep 17 00:00:00 2001 From: Werner Saar Date: Fri, 25 Mar 2016 16:54:25 +0100 Subject: [PATCH 5/6] added optimized ccopy kernel for POWER8 --- kernel/power/KERNEL.POWER8 | 2 +- kernel/power/ccopy.c | 140 +++++++++++++++++++++++ kernel/power/ccopy_microk_power8.c | 174 +++++++++++++++++++++++++++++ 3 files changed, 315 insertions(+), 1 deletion(-) create mode 100644 kernel/power/ccopy.c create mode 100644 kernel/power/ccopy_microk_power8.c diff --git a/kernel/power/KERNEL.POWER8 b/kernel/power/KERNEL.POWER8 index dee0c2660..576ad506d 100644 --- a/kernel/power/KERNEL.POWER8 +++ b/kernel/power/KERNEL.POWER8 @@ -117,7 +117,7 @@ ZAXPYKERNEL = zaxpy.c # SCOPYKERNEL = scopy.c DCOPYKERNEL = dcopy.c -#CCOPYKERNEL = ../arm/zcopy.c +CCOPYKERNEL = ccopy.c ZCOPYKERNEL = zcopy.c # SDOTKERNEL = sdot.c diff --git a/kernel/power/ccopy.c b/kernel/power/ccopy.c new file mode 100644 index 000000000..ce7d67475 --- /dev/null +++ b/kernel/power/ccopy.c @@ -0,0 +1,140 @@ +/*************************************************************************** +Copyright (c) 2013-2016, The OpenBLAS Project +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the +distribution. +3. Neither the name of the OpenBLAS project nor the names of +its contributors may be used to endorse or promote products +derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*****************************************************************************/ + +/************************************************************************************** +* 2016/03/25 Werner Saar (wernsaar@googlemail.com) +* BLASTEST : OK +* CTEST : OK +* TEST : OK +* LAPACK-TEST : OK +**************************************************************************************/ + +#include "common.h" + +#if defined(POWER8) +#include "ccopy_microk_power8.c" +#endif + +#ifndef HAVE_KERNEL_32 + +static void ccopy_kernel_32(BLASLONG n, FLOAT *x, FLOAT *y) +{ + + BLASLONG i=0; + FLOAT f0, f1, f2, f3, f4, f5, f6, f7; + FLOAT *x1=x; + FLOAT *y1=y; + + while ( i 0 ) + { + ccopy_kernel_32(n1, x, y); + i=n1; + ix=n1*2; + iy=n1*2; + } + + while(i < n) + { + y[iy] = x[iy] ; + y[iy+1] = x[ix+1] ; + ix+=2; + iy+=2; + i++ ; + + } + + + } + else + { + + BLASLONG inc_x2 = 2 * inc_x; + BLASLONG inc_y2 = 2 * inc_y; + + while(i < n) + { + y[iy] = x[ix] ; + y[iy+1] = x[ix+1] ; + ix += inc_x2 ; + iy += inc_y2 ; + i++ ; + + } + + } + return(0); + + +} + + diff --git a/kernel/power/ccopy_microk_power8.c b/kernel/power/ccopy_microk_power8.c new file mode 100644 index 000000000..95b3559ba --- /dev/null +++ b/kernel/power/ccopy_microk_power8.c @@ -0,0 +1,174 @@ +/*************************************************************************** +Copyright (c) 2013-2016, The OpenBLAS Project +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the +distribution. +3. Neither the name of the OpenBLAS project nor the names of +its contributors may be used to endorse or promote products +derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*****************************************************************************/ + +/************************************************************************************** +* 2016/03/25 Werner Saar (wernsaar@googlemail.com) +* BLASTEST : OK +* CTEST : OK +* TEST : OK +* LAPACK-TEST : OK +**************************************************************************************/ + +#define HAVE_KERNEL_32 1 + +static void ccopy_kernel_32( BLASLONG n, FLOAT *x, FLOAT *y) __attribute__ ((noinline)); + +static void ccopy_kernel_32( BLASLONG n, FLOAT *x, FLOAT *y) +{ + + + BLASLONG i = n; + BLASLONG o16 = 16; + BLASLONG o32 = 32; + BLASLONG o48 = 48; + BLASLONG o64 = 64; + BLASLONG o80 = 80; + BLASLONG o96 = 96; + BLASLONG o112 = 112; + FLOAT *x1=x; + FLOAT *y1=y; + BLASLONG pre = 384; + BLASLONG alpha=0; + + __asm__ __volatile__ + ( + + "lxvw4x 40, 0, %2 \n\t" + "lxvw4x 41, %5, %2 \n\t" + "lxvw4x 42, %6, %2 \n\t" + "lxvw4x 43, %7, %2 \n\t" + "lxvw4x 44, %8, %2 \n\t" + "lxvw4x 45, %9, %2 \n\t" + "lxvw4x 46, %10, %2 \n\t" + "lxvw4x 47, %11, %2 \n\t" + + "addi %2, %2, 128 \n\t" + + "lxvw4x 50, 0, %2 \n\t" + "lxvw4x 51, %5, %2 \n\t" + "lxvw4x 52, %6, %2 \n\t" + "lxvw4x 53, %7, %2 \n\t" + "lxvw4x 54, %8, %2 \n\t" + "lxvw4x 55, %9, %2 \n\t" + "lxvw4x 56, %10, %2 \n\t" + "lxvw4x 57, %11, %2 \n\t" + + "addi %2, %2, 128 \n\t" + + "addic. %0 , %0 , -32 \n\t" + "ble 2f \n\t" + + ".align 5 \n\t" + "1: \n\t" + + "stxvw4x 40, 0, %1 \n\t" + "stxvw4x 41, %5, %1 \n\t" + "lxvw4x 40, 0, %2 \n\t" + "lxvw4x 41, %5, %2 \n\t" + "stxvw4x 42, %6, %1 \n\t" + "stxvw4x 43, %7, %1 \n\t" + "lxvw4x 42, %6, %2 \n\t" + "lxvw4x 43, %7, %2 \n\t" + "stxvw4x 44, %8, %1 \n\t" + "stxvw4x 45, %9, %1 \n\t" + "lxvw4x 44, %8, %2 \n\t" + "lxvw4x 45, %9, %2 \n\t" + "stxvw4x 46, %10, %1 \n\t" + "stxvw4x 47, %11, %1 \n\t" + "lxvw4x 46, %10, %2 \n\t" + "lxvw4x 47, %11, %2 \n\t" + + + "addi %1, %1, 128 \n\t" + "addi %2, %2, 128 \n\t" + + "stxvw4x 50, 0, %1 \n\t" + "stxvw4x 51, %5, %1 \n\t" + "lxvw4x 50, 0, %2 \n\t" + "lxvw4x 51, %5, %2 \n\t" + "stxvw4x 52, %6, %1 \n\t" + "stxvw4x 53, %7, %1 \n\t" + "lxvw4x 52, %6, %2 \n\t" + "lxvw4x 53, %7, %2 \n\t" + "stxvw4x 54, %8, %1 \n\t" + "stxvw4x 55, %9, %1 \n\t" + "lxvw4x 54, %8, %2 \n\t" + "lxvw4x 55, %9, %2 \n\t" + "stxvw4x 56, %10, %1 \n\t" + "stxvw4x 57, %11, %1 \n\t" + "lxvw4x 56, %10, %2 \n\t" + "lxvw4x 57, %11, %2 \n\t" + + "addi %1, %1, 128 \n\t" + "addi %2, %2, 128 \n\t" + + "addic. %0 , %0 , -32 \n\t" + "bgt 1b \n\t" + + "2: \n\t" + + "stxvw4x 40, 0, %1 \n\t" + "stxvw4x 41, %5, %1 \n\t" + "stxvw4x 42, %6, %1 \n\t" + "stxvw4x 43, %7, %1 \n\t" + "stxvw4x 44, %8, %1 \n\t" + "stxvw4x 45, %9, %1 \n\t" + "stxvw4x 46, %10, %1 \n\t" + "stxvw4x 47, %11, %1 \n\t" + + "addi %1, %1, 128 \n\t" + + "stxvw4x 50, 0, %1 \n\t" + "stxvw4x 51, %5, %1 \n\t" + "stxvw4x 52, %6, %1 \n\t" + "stxvw4x 53, %7, %1 \n\t" + "stxvw4x 54, %8, %1 \n\t" + "stxvw4x 55, %9, %1 \n\t" + "stxvw4x 56, %10, %1 \n\t" + "stxvw4x 57, %11, %1 \n\t" + + + : + : + "r" (i), // 0 + "r" (y1), // 1 + "r" (x1), // 2 + "r" (alpha), // 3 + "r" (pre), // 4 + "r" (o16), // 5 + "r" (o32), // 6 + "r" (o48), // 7 + "r" (o64), // 8 + "r" (o80), // 9 + "r" (o96), // 10 + "r" (o112) // 11 + : "cr0", "%0", "%2" , "%1", "memory" + ); + +} + + From 3d9a50e8414ac7d9b547d43f864fcde0ed542e26 Mon Sep 17 00:00:00 2001 From: Werner Saar Date: Fri, 25 Mar 2016 17:34:55 +0100 Subject: [PATCH 6/6] added optimized sswap kernel for POWER8 --- kernel/power/KERNEL.POWER8 | 2 +- kernel/power/sswap.c | 154 +++++++++++++++++++++++++++++ kernel/power/sswap_microk_power8.c | 136 +++++++++++++++++++++++++ 3 files changed, 291 insertions(+), 1 deletion(-) create mode 100644 kernel/power/sswap.c create mode 100644 kernel/power/sswap_microk_power8.c diff --git a/kernel/power/KERNEL.POWER8 b/kernel/power/KERNEL.POWER8 index 576ad506d..0f4516812 100644 --- a/kernel/power/KERNEL.POWER8 +++ b/kernel/power/KERNEL.POWER8 @@ -140,7 +140,7 @@ DSCALKERNEL = dscal.c #CSCALKERNEL = ../arm/zscal.c #ZSCALKERNEL = zscal.c # -#SSWAPKERNEL = ../arm/swap.c +SSWAPKERNEL = sswap.c DSWAPKERNEL = dswap.c #CSWAPKERNEL = ../arm/zswap.c #ZSWAPKERNEL = ../arm/zswap.c diff --git a/kernel/power/sswap.c b/kernel/power/sswap.c new file mode 100644 index 000000000..932652b37 --- /dev/null +++ b/kernel/power/sswap.c @@ -0,0 +1,154 @@ +/*************************************************************************** +Copyright (c) 2013-2016, The OpenBLAS Project +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the +distribution. +3. Neither the name of the OpenBLAS project nor the names of +its contributors may be used to endorse or promote products +derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*****************************************************************************/ + +/************************************************************************************** +* 2016/03/25 Werner Saar (wernsaar@googlemail.com) +* BLASTEST : OK +* CTEST : OK +* TEST : OK +* LAPACK-TEST : OK +**************************************************************************************/ + +#include "common.h" + +#if defined(POWER8) +#include "sswap_microk_power8.c" +#endif + +#ifndef HAVE_KERNEL_32 + +static void sswap_kernel_32(BLASLONG n, FLOAT *x, FLOAT *y) +{ + + BLASLONG i=0; + FLOAT f0, f1, f2, f3, f4, f5, f6, f7; + FLOAT g0, g1, g2, g3, g4, g5, g6, g7; + FLOAT *x1=x; + FLOAT *y1=y; + + while ( i 0 ) + { + sswap_kernel_32(n1, x, y); + i=n1; + } + + while(i < n) + { + temp = y[i]; + y[i] = x[i] ; + x[i] = temp; + i++ ; + + } + + + } + else + { + + while(i < n) + { + temp = y[iy]; + y[iy] = x[ix] ; + x[ix] = temp; + ix += inc_x ; + iy += inc_y ; + i++ ; + + } + + } + return(0); + + +} + + diff --git a/kernel/power/sswap_microk_power8.c b/kernel/power/sswap_microk_power8.c new file mode 100644 index 000000000..c48e743de --- /dev/null +++ b/kernel/power/sswap_microk_power8.c @@ -0,0 +1,136 @@ +/*************************************************************************** +Copyright (c) 2013-2016, The OpenBLAS Project +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the +distribution. +3. Neither the name of the OpenBLAS project nor the names of +its contributors may be used to endorse or promote products +derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*****************************************************************************/ + +/************************************************************************************** +* 2016/03/25 Werner Saar (wernsaar@googlemail.com) +* BLASTEST : OK +* CTEST : OK +* TEST : OK +* LAPACK-TEST : OK +**************************************************************************************/ + +#define HAVE_KERNEL_32 1 + +static void sswap_kernel_32( BLASLONG n, FLOAT *x, FLOAT *y) __attribute__ ((noinline)); + +static void sswap_kernel_32( BLASLONG n, FLOAT *x, FLOAT *y) +{ + + + BLASLONG i = n; + BLASLONG o16 = 16; + BLASLONG o32 = 32; + BLASLONG o48 = 48; + BLASLONG o64 = 64; + BLASLONG o80 = 80; + BLASLONG o96 = 96; + BLASLONG o112 = 112; + FLOAT *x1=x; + FLOAT *y1=y; + FLOAT *x2=x+1; + FLOAT *y2=y+1; + BLASLONG pre = 384; + BLASLONG alpha=0; + + __asm__ __volatile__ + ( + + "addi %3, %3, -4 \n\t" + "addi %4, %4, -4 \n\t" + + ".align 5 \n\t" + "1: \n\t" + + "lxvw4x 32, 0, %2 \n\t" + "lxvw4x 33, %5, %2 \n\t" + "lxvw4x 34, %6, %2 \n\t" + "lxvw4x 35, %7, %2 \n\t" + "lxvw4x 36, %8, %2 \n\t" + "lxvw4x 37, %9, %2 \n\t" + "lxvw4x 38, %10, %2 \n\t" + "lxvw4x 39, %11, %2 \n\t" + + "addi %2, %2, 128 \n\t" + + "lxvw4x 48, 0, %1 \n\t" + "lxvw4x 49, %5, %1 \n\t" + "lxvw4x 50, %6, %1 \n\t" + "lxvw4x 51, %7, %1 \n\t" + "lxvw4x 52, %8, %1 \n\t" + "lxvw4x 53, %9, %1 \n\t" + "lxvw4x 54, %10, %1 \n\t" + "lxvw4x 55, %11, %1 \n\t" + + "addi %1, %1, 128 \n\t" + + "stxvw4x 32, 0, %3 \n\t" + "stxvw4x 33, %5, %3 \n\t" + "stxvw4x 34, %6, %3 \n\t" + "stxvw4x 35, %7, %3 \n\t" + "stxvw4x 36, %8, %3 \n\t" + "stxvw4x 37, %9, %3 \n\t" + "stxvw4x 38, %10, %3 \n\t" + "stxvw4x 39, %11, %3 \n\t" + + "addi %3, %3, 128 \n\t" + + "stxvw4x 48, 0, %4 \n\t" + "stxvw4x 49, %5, %4 \n\t" + "stxvw4x 50, %6, %4 \n\t" + "stxvw4x 51, %7, %4 \n\t" + "stxvw4x 52, %8, %4 \n\t" + "stxvw4x 53, %9, %4 \n\t" + "stxvw4x 54, %10, %4 \n\t" + "stxvw4x 55, %11, %4 \n\t" + + "addi %4, %4, 128 \n\t" + + "addic. %0 , %0 , -32 \n\t" + "bgt 1b \n\t" + + "2: \n\t" + + : + : + "r" (i), // 0 + "r" (y1), // 1 + "r" (x1), // 2 + "r" (y2), // 3 + "r" (x2), // 4 + "r" (o16), // 5 + "r" (o32), // 6 + "r" (o48), // 7 + "r" (o64), // 8 + "r" (o80), // 9 + "r" (o96), // 10 + "r" (o112) // 11 + : "cr0", "%0", "%2" , "%1", "%3", "%4", "memory" + ); + +} + +