Skip to content
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

Create a valid Neoverse N1 target. #623

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions config/neoversen1/bli_cntx_init_neoversen1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*

BLIS
An object-based framework for developing high-performance BLAS-like
libraries.

Copyright (C) 2014, The University of Texas at Austin

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 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.
- Neither the name(s) of the copyright holder(s) 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 COPYRIGHT
HOLDER 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.

*/

#include "blis.h"

void bli_cntx_init_neoversen1( cntx_t* cntx )
{
blksz_t blkszs[ BLIS_NUM_BLKSZS ];

// Set default kernel blocksizes and functions.
bli_cntx_init_neoversen1_ref( cntx );

// -------------------------------------------------------------------------

// Update the context with optimized native gemm micro-kernels and
// their storage preferences.
bli_cntx_set_l3_nat_ukrs
(
2,
BLIS_GEMM_UKR, BLIS_FLOAT, bli_sgemm_armv8a_asm_8x12, FALSE,
BLIS_GEMM_UKR, BLIS_DOUBLE, bli_dgemm_armv8a_asm_6x8, FALSE,
cntx
);

// Initialize level-3 blocksize objects with architecture-specific values.
// s d c z
bli_blksz_init_easy( &blkszs[ BLIS_MR ], 8, 6, -1, -1 );
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, that's great to see neoverse n1 tuning. Can I ask you how you came up with these blocksize values ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! To be honest I just wanted the compiler to generate tuned neoverse-n1 code with this patch so blocksize values were taken from thunderx2. If BLIS has a standard procedure to generate those value I am all up for it, please just let me know.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I value what you did, however i don't have the answer for this.
@devinamatthews any pointer you could share ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@egaudry Do you think the fine tuning is essential to merge?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a clear interface and arch detection makes sense indeed, however without proper tuning, mergers/reviewers might not see this as a priority.
Just guessing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jeff Diamond has better tuning parameters for N1.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeffhammond Thanks for commenting. Could you please point me to Jeff Diamond so I could ask him if he is able to share his parameters please?

bli_blksz_init_easy( &blkszs[ BLIS_NR ], 12, 8, -1, -1 );
bli_blksz_init_easy( &blkszs[ BLIS_MC ], 120, 120, -1, -1 );
bli_blksz_init_easy( &blkszs[ BLIS_KC ], 640, 240, -1, -1 );
bli_blksz_init_easy( &blkszs[ BLIS_NC ], 3072, 3072, -1, -1 );

// Update the context with the current architecture's register and cache
// blocksizes (and multiples) for native execution.
bli_cntx_set_blkszs
(
BLIS_NAT, 5,
BLIS_NC, &blkszs[ BLIS_NC ], BLIS_NR,
BLIS_KC, &blkszs[ BLIS_KC ], BLIS_KR,
BLIS_MC, &blkszs[ BLIS_MC ], BLIS_MR,
BLIS_NR, &blkszs[ BLIS_NR ], BLIS_NR,
BLIS_MR, &blkszs[ BLIS_MR ], BLIS_MR,
cntx
);
}

42 changes: 42 additions & 0 deletions config/neoversen1/bli_family_neoversen1.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*

BLIS
An object-based framework for developing high-performance BLAS-like
libraries.

Copyright (C) 2014, The University of Texas at Austin

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 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.
- Neither the name(s) of the copyright holder(s) 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 COPYRIGHT
HOLDER 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.

*/

//#ifndef BLIS_FAMILY_H
//#define BLIS_FAMILY_H


// -- MEMORY ALLOCATION --------------------------------------------------------

#define BLIS_SIMD_ALIGN_SIZE 16

90 changes: 90 additions & 0 deletions config/neoversen1/make_defs.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#
#
# BLIS
# An object-based framework for developing high-performance BLAS-like
# libraries.
#
# Copyright (C) 2014, The University of Texas at Austin
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# - Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# - 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.
# - Neither the name(s) of the copyright holder(s) 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 COPYRIGHT
# HOLDER 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.
#
#


# Declare the name of the current configuration and add it to the
# running list of configurations included by common.mk.
THIS_CONFIG := neoversen1
#CONFIGS_INCL += $(THIS_CONFIG)

#
# --- Determine the C compiler and related flags ---
#

# NOTE: The build system will append these variables with various
# general-purpose/configuration-agnostic flags in common.mk. You
# may specify additional flags here as needed.
CPPROCFLAGS := -D_GNU_SOURCE
CMISCFLAGS :=
CPICFLAGS :=
CWARNFLAGS :=

ifneq ($(DEBUG_TYPE),off)
CDBGFLAGS := -g
endif

ifeq ($(DEBUG_TYPE),noopt)
COPTFLAGS := -O0
else
COPTFLAGS := -O2 -mcpu=neoverse-n1
endif

# Flags specific to optimized kernels.
CKOPTFLAGS := $(COPTFLAGS) -O3 -ftree-vectorize
ifeq ($(CC_VENDOR),gcc)
CKVECFLAGS := -mcpu=neoverse-n1
else
ifeq ($(CC_VENDOR),clang)
CKVECFLAGS := -mcpu=neoverse-n1
else
$(error gcc or clang is required for this configuration.)
endif
endif

# Flags specific to reference kernels.
CROPTFLAGS := $(CKOPTFLAGS)
ifeq ($(CC_VENDOR),gcc)
CRVECFLAGS := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
else
ifeq ($(CC_VENDOR),clang)
CRVECFLAGS := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
else
CRVECFLAGS := $(CKVECFLAGS)
endif
endif

# Store all of the variables here to new variables containing the
# configuration name.
$(eval $(call store-make-defs,$(THIS_CONFIG)))

3 changes: 2 additions & 1 deletion config_registry
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ x86_64: intel64 amd64 amd64_legacy
intel64: skx knl haswell sandybridge penryn generic
amd64_legacy: excavator steamroller piledriver bulldozer generic
amd64: zen3 zen2 zen generic
arm64: armsve firestorm thunderx2 cortexa57 cortexa53 generic
arm64: neoversen1 armsve firestorm thunderx2 cortexa57 cortexa53 generic
arm32: cortexa15 cortexa9 generic

# Intel architectures.
Expand All @@ -32,6 +32,7 @@ piledriver: piledriver
bulldozer: bulldozer

# ARM architectures.
neoversen1: neoversen1/armv8a
armsve: armsve/armsve
a64fx: a64fx/armsve
firestorm: firestorm/armv8a
Expand Down
4 changes: 4 additions & 0 deletions frame/base/bli_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ void bli_arch_set_id( void )
#endif

// ARM microarchitectures.
#ifdef BLIS_FAMILY_NEOVERSEN1
id = BLIS_ARCH_NEOVERSEN1;
#endif
#ifdef BLIS_FAMILY_ARMSVE
id = BLIS_ARCH_ARMSVE;
#endif
Expand Down Expand Up @@ -270,6 +273,7 @@ static char* config_name[ BLIS_NUM_ARCHS ] =
"piledriver",
"bulldozer",

"neoversen1",
"armsve",
"a64fx",
"firestorm",
Expand Down
4 changes: 2 additions & 2 deletions frame/base/bli_cpuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -1127,9 +1127,9 @@ static uint32_t get_coretype
case 0xd03: // Cortex A53
return BLIS_ARCH_CORTEXA53;
#endif
#ifdef BLIS_CONFIG_THUNDERX2
#ifdef BLIS_CONFIG_NEOVERSEN1
case 0xd0c: // Neoverse N1 (and Graviton G2?)
return BLIS_ARCH_THUNDERX2; //placeholder for N1
return BLIS_ARCH_NEOVERSEN1; //placeholder for N1
#endif
}
break;
Expand Down
1 change: 1 addition & 0 deletions frame/base/bli_cpuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ bool bli_cpuid_is_piledriver( uint32_t family, uint32_t model, uint32_t features
bool bli_cpuid_is_bulldozer( uint32_t family, uint32_t model, uint32_t features );

// ARM
bool bli_cpuid_is_neoversen1( uint32_t model, uint32_t part, uint32_t features );
bool bli_cpuid_is_thunderx2( uint32_t model, uint32_t part, uint32_t features );
bool bli_cpuid_is_cortexa57( uint32_t model, uint32_t part, uint32_t features );
bool bli_cpuid_is_cortexa53( uint32_t model, uint32_t part, uint32_t features );
Expand Down
5 changes: 5 additions & 0 deletions frame/base/bli_gks.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ void bli_gks_init( void )
#endif

// ARM architectures
#ifdef BLIS_CONFIG_NEOVERSEN1
bli_gks_register_cntx( BLIS_ARCH_NEOVERSEN1, bli_cntx_init_neoversen1,
bli_cntx_init_neoversen1_ref,
bli_cntx_init_neoversen1_ind );
#endif
#ifdef BLIS_CONFIG_A64FX
bli_gks_register_cntx( BLIS_ARCH_A64FX, bli_cntx_init_a64fx,
bli_cntx_init_a64fx_ref,
Expand Down
6 changes: 6 additions & 0 deletions frame/include/bli_arch_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ CNTX_INIT_PROTS( bulldozer )

// -- ARM architectures --

#ifdef BLIS_CONFIG_NEOVERSEN1
CNTX_INIT_PROTS( neoversen1 )
#endif
#ifdef BLIS_CONFIG_ARMSVE
CNTX_INIT_PROTS( armsve )
#endif
Expand Down Expand Up @@ -212,6 +215,9 @@ CNTX_INIT_PROTS( generic )

// -- ARM architectures --

#ifdef BLIS_FAMILY_NEOVERSEN1
#include "bli_family_neoversen1.h"
#endif
#ifdef BLIS_FAMILY_ARMSVE
#include "bli_family_armsve.h"
#endif
Expand Down
1 change: 1 addition & 0 deletions frame/include/bli_type_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,7 @@ typedef enum
BLIS_ARCH_BULLDOZER,

// ARM
BLIS_ARCH_NEOVERSEN1,
BLIS_ARCH_ARMSVE,
BLIS_ARCH_A64FX,
BLIS_ARCH_FIRESTORM,
Expand Down