Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
23 changes: 23 additions & 0 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,29 @@ please https://github.com/xianyi/OpenBLAS/issues/246
#define BLAS3_MEM_ALLOC_THRESHOLD 32
#endif

/***
For GCC/Clang, always use -fvisibility=hidden. Then mark exported function
implementations with OPENBLAS_EXPORT. For MSVC, using `__declspec` onces makes
the default atrribute for any function in the entire shared object hidden
(observed behaviour, documentation source needed).
**/
#if defined (_WIN32) || defined (__CYGWIN__)
# if defined (__GNUC__)
/* GCC */
# define OPENBLAS_EXPORT __attribute__ ((dllexport))
# define OPENBLAS_IMPORT __attribute__ ((dllimport))
# else
/* MSVC */
# define OPENBLAS_EXPORT __declspec(dllexport)
# define OPENBLAS_IMPORT __declspec(dllimport)
# endif
#else
/* All other platforms. */
# define OPENBLAS_EXPORT __attribute__ ((visibility ("default")))
# define OPENBLAS_IMPORT
#endif


#ifdef QUAD_PRECISION
#include "common_quad.h"
#endif
Expand Down
8 changes: 8 additions & 0 deletions common_loongarch64.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,14 @@ static inline int get_cpu_model(char *model_name) {
#if defined(ASSEMBLER) && !defined(NEEDPARAM)

#define PROLOGUE \
.text ;\
.align 5 ;\
.globl REALNAME ;\
.hidden REALNAME ;\
.type REALNAME, @function ;\
REALNAME: ;\

#define PROLOGUE_EXPORT \
.text ;\
.align 5 ;\
.globl REALNAME ;\
Expand Down
6 changes: 6 additions & 0 deletions common_mips.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ static inline int blas_quickdivide(blasint x, blasint y){
#define PROLOGUE \
.arm ;\
.global REALNAME ;\
.hidden REALNAME ;\
REALNAME:

#define PROLOGUE_EXPORT \
.arm ;\
.global REALNAME ;\
REALNAME:

#define EPILOGUE
Expand Down
12 changes: 12 additions & 0 deletions common_mips64.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,18 @@ static inline int blas_quickdivide(blasint x, blasint y){
#endif

#define PROLOGUE \
.text ;\
.set ASSEMBLER_ARCH ;\
.align 5 ;\
.globl REALNAME ;\
.hidden REALNAME ;\
.ent REALNAME ;\
.type REALNAME, @function ;\
REALNAME: ;\
.set noreorder ;\
.set nomacro

#define PROLOGUE_EXPORT \
.text ;\
.set ASSEMBLER_ARCH ;\
.align 5 ;\
Expand Down
29 changes: 29 additions & 0 deletions common_power.h
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,13 @@ static inline int blas_quickdivide(blasint x, blasint y){
#if defined(OS_LINUX) || defined(OS_FREEBSD)
#ifndef __64BIT__
#define PROLOGUE \
.section .text;\
.align 6;\
.globl REALNAME;\
.hidden REALNAME ;\
.type REALNAME, @function;\
REALNAME:
#define PROLOGUE_EXPORT \
.section .text;\
.align 6;\
.globl REALNAME;\
Expand All @@ -541,6 +548,13 @@ static inline int blas_quickdivide(blasint x, blasint y){
#else
#if _CALL_ELF == 2
#define PROLOGUE \
.section .text;\
.align 6;\
.globl REALNAME;\
.hidden REALNAME ;\
.type REALNAME, @function;\
REALNAME:
#define PROLOGUE_EXPORT \
.section .text;\
.align 6;\
.globl REALNAME;\
Expand All @@ -549,6 +563,21 @@ static inline int blas_quickdivide(blasint x, blasint y){
#define EPILOGUE .size REALNAME, .-REALNAME
#else
#define PROLOGUE \
.section .text;\
.align 5;\
.globl REALNAME;\
.hidden REALNAME ;\
.section ".opd","aw";\
.align 3;\
REALNAME:;\
.quad .REALNAME, .TOC.@tocbase, 0;\
.previous;\
.size REALNAME, 24;\
.type .REALNAME, @function;\
.globl .REALNAME;\
.hidden .REALNAME ;\
.REALNAME:
#define PROLOGUE_EXPORT \
.section .text;\
.align 5;\
.globl REALNAME;\
Expand Down
22 changes: 20 additions & 2 deletions common_x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ static __inline int blas_quickdivide(unsigned int x, unsigned int y){
#endif

#ifdef OS_DARWIN
#define PROLOGUE .text;.align 5; .globl REALNAME; REALNAME:
#define PROLOGUE .text;.align 5; .globl REALNAME; .hidden REALNAME; REALNAME:
#define PROLOGUE_EXPORT .text;.align 5; .globl REALNAME; REALNAME:
#define EPILOGUE .subsections_via_symbols
#define PROFCODE
#endif
Expand All @@ -319,6 +320,14 @@ static __inline int blas_quickdivide(unsigned int x, unsigned int y){

#if defined(OS_WINNT) || defined(OS_CYGWIN_NT) || defined(OS_INTERIX)
#define PROLOGUE \
.text; \
.align 16; \
.globl REALNAME ;\
.hidden REALNAME ;\
.def REALNAME;.scl 2;.type 32;.endef; \
REALNAME:

#define PROLOGUE_EXPORT \
.text; \
.align 16; \
.globl REALNAME ;\
Expand All @@ -339,7 +348,16 @@ static __inline int blas_quickdivide(unsigned int x, unsigned int y){
.text; \
.align 16; \
.globl REALNAME ;\
.type REALNAME, @function; \
.hidden REALNAME ;\
.type REALNAME, @function; \
REALNAME: \
_CET_ENDBR

#define PROLOGUE_EXPORT \
.text; \
.align 16; \
.globl REALNAME ;\
.type REALNAME, @function; \
REALNAME: \
_CET_ENDBR

Expand Down
22 changes: 20 additions & 2 deletions common_x86_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ static __inline unsigned int blas_quickdivide(unsigned int x, unsigned int y){
#endif

#ifdef OS_DARWIN
#define PROLOGUE .text;.align 5; .globl REALNAME; REALNAME:
#define PROLOGUE .text;.align 5; .globl REALNAME; .hidden REALNAME; REALNAME:
#define PROLOGUE_EXPORT .text;.align 5; .globl REALNAME; REALNAME:
#define EPILOGUE .subsections_via_symbols
#define PROFCODE
#endif
Expand Down Expand Up @@ -441,6 +442,14 @@ static __inline unsigned int blas_quickdivide(unsigned int x, unsigned int y){
.text; \
.align 16; \
.globl REALNAME ;\
.hidden REALNAME ; \
.def REALNAME;.scl 2;.type 32;.endef; \
REALNAME:

#define PROLOGUE_EXPORT \
.text; \
.align 16; \
.globl REALNAME ;\
.def REALNAME;.scl 2;.type 32;.endef; \
REALNAME:

Expand All @@ -454,7 +463,16 @@ static __inline unsigned int blas_quickdivide(unsigned int x, unsigned int y){
.text; \
.align 512; \
.globl REALNAME ;\
.type REALNAME, @function; \
.hidden REALNAME ;\
.type REALNAME, @function; \
REALNAME: \
_CET_ENDBR

#define PROLOGUE_EXPORT \
.text; \
.align 512; \
.globl REALNAME ;\
.type REALNAME, @function; \
REALNAME: \
_CET_ENDBR

Expand Down
2 changes: 2 additions & 0 deletions driver/others/blas_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,7 @@ if (openblas_threads_callback_) {
return 0;
}

OPENBLAS_EXPORT
void goto_set_num_threads(int num_threads) {

long i;
Expand Down Expand Up @@ -933,6 +934,7 @@ void goto_set_num_threads(int num_threads) {

}

OPENBLAS_EXPORT
void openblas_set_num_threads(int num_threads) {
goto_set_num_threads(num_threads);

Expand Down
4 changes: 4 additions & 0 deletions driver/others/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ int blas_get_cpu_number(void){
#endif


OPENBLAS_EXPORT
int openblas_get_num_procs(void) {
#ifndef SMP
return 1;
Expand All @@ -508,6 +509,7 @@ int openblas_get_num_procs(void) {
#endif
}

OPENBLAS_EXPORT
int openblas_get_num_threads(void) {
#ifndef SMP
return 1;
Expand Down Expand Up @@ -2071,6 +2073,7 @@ int blas_get_cpu_number(void){
#endif


OPENBLAS_EXPORT
int openblas_get_num_procs(void) {
#ifndef SMP
return 1;
Expand All @@ -2079,6 +2082,7 @@ int openblas_get_num_procs(void) {
#endif
}

OPENBLAS_EXPORT
int openblas_get_num_threads(void) {
#ifndef SMP
return 1;
Expand Down
2 changes: 2 additions & 0 deletions driver/others/openblas_get_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ char *gotoblas_corename(void);
static char tmp_config_str[256];
int openblas_get_parallel(void);

OPENBLAS_EXPORT
char* CNAME(void) {
char tmpstr[20];
strcpy(tmp_config_str, openblas_config_str);
Expand All @@ -93,6 +94,7 @@ char tmpstr[20];
}


OPENBLAS_EXPORT
char* openblas_get_corename(void) {
#ifndef DYNAMIC_ARCH
return CHAR_CORENAME;
Expand Down
1 change: 1 addition & 0 deletions driver/others/openblas_get_num_procs.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

extern int openblas_get_num_procs(void);

OPENBLAS_EXPORT
int openblas_get_num_procs_(void) {
return openblas_get_num_procs();
}
1 change: 1 addition & 0 deletions driver/others/openblas_get_num_threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

extern int openblas_get_num_threads(void);

OPENBLAS_EXPORT
int openblas_get_num_threads_(void) {
return openblas_get_num_threads();
}
3 changes: 3 additions & 0 deletions driver/others/openblas_get_parallel.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ static int parallel = 0;
#endif


OPENBLAS_EXPORT

#ifdef NEEDBUNDERSCORE
int CNAME(void) {
return parallel;
}

OPENBLAS_EXPORT
int NAME(void) {
return parallel;
}
Expand Down
3 changes: 3 additions & 0 deletions driver/others/openblas_set_num_threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
extern void openblas_set_num_threads(int num_threads) ;
extern int openblas_get_num_threads(void) ;

OPENBLAS_EXPORT
void openblas_set_num_threads_(int* num_threads){
openblas_set_num_threads(*num_threads);
}
Expand All @@ -53,9 +54,11 @@ int openblas_set_num_threads_local(int num_threads){
#else
//Single thread

OPENBLAS_EXPORT
void openblas_set_num_threads(int num_threads) {
}

OPENBLAS_EXPORT
void openblas_set_num_threads_(int* num_threads){

}
Expand Down
1 change: 1 addition & 0 deletions interface/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
TOPDIR = ..
include $(TOPDIR)/Makefile.system


SUPPORT_GEMM3M = 0

ifeq ($(ARCH), x86)
Expand Down
1 change: 1 addition & 0 deletions interface/asum.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "functable.h"
#endif

OPENBLAS_EXPORT
#ifndef CBLAS

FLOATRET NAME(blasint *N, FLOAT *x, blasint *INCX){
Expand Down
1 change: 1 addition & 0 deletions interface/axpby.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "functable.h"
#endif

OPENBLAS_EXPORT
#ifndef CBLAS

void NAME(blasint *N, FLOAT *ALPHA, FLOAT *x, blasint *INCX, FLOAT *BETA, FLOAT *y, blasint *INCY)
Expand Down
3 changes: 3 additions & 0 deletions interface/axpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
#else
#define MULTI_THREAD_MINIMAL 10000
#endif


OPENBLAS_EXPORT
#ifndef CBLAS

void NAME(blasint *N, FLOAT *ALPHA, FLOAT *x, blasint *INCX, FLOAT *y, blasint *INCY){
Expand Down
1 change: 1 addition & 0 deletions interface/bf16dot.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "functable.h"
#endif

OPENBLAS_EXPORT
#ifndef CBLAS
float NAME(blasint *N, bfloat16 *x, blasint *INCX, bfloat16 *y, blasint *INCY){
BLASLONG n = *N;
Expand Down
1 change: 1 addition & 0 deletions interface/bf16to.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#else
#endif

OPENBLAS_EXPORT
#ifndef CBLAS
void NAME(blasint *N, bfloat16 *in, blasint *INC_IN, FLOAT_TYPE *out, blasint *INC_OUT){
BLASLONG n = *N;
Expand Down
1 change: 1 addition & 0 deletions interface/copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "functable.h"
#endif

OPENBLAS_EXPORT
#ifndef CBLAS

void NAME(blasint *N, FLOAT *x, blasint *INCX, FLOAT *y, blasint *INCY){
Expand Down
1 change: 1 addition & 0 deletions interface/dot.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "functable.h"
#endif

OPENBLAS_EXPORT
#ifndef CBLAS

FLOATRET NAME(blasint *N, FLOAT *x, blasint *INCX, FLOAT *y, blasint *INCY){
Expand Down
Loading
Loading