Skip to content
Merged
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
1 change: 1 addition & 0 deletions Makefile.wasm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CCOMMON_OPT += -msimd128
4 changes: 4 additions & 0 deletions TargetList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,7 @@ EV6
14.CSKY
CSKY
CK860FV

15. WebAssembly/Emscripten:
WASM128_GENERIC

4 changes: 3 additions & 1 deletion c_check
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ case "$data" in
*ARCH_RISCV64*) architecture=riscv64 ;;
*ARCH_LOONGARCH64*) architecture=loongarch64 ;;
*ARCH_CSKY*) architecture=csky ;;
*ARCH_WASM*) architecture=wasm ;;
esac

defined=0
Expand Down Expand Up @@ -130,7 +131,7 @@ case "$architecture" in
defined=1
;;
arm|arm64) defined=1 ;;
zarch|e2k|alpha|ia64|riscv64|loonarch64)
zarch|e2k|alpha|ia64|riscv64|loonarch64|wasm)
defined=1
BINARY=64
;;
Expand Down Expand Up @@ -254,6 +255,7 @@ case "$data" in
*ARCH_ZARCH*) architecture=zarch ;;
*ARCH_LOONGARCH64*) architecture=loongarch64 ;;
*ARCH_CSKY*) architecture=csky ;;
*ARCH_WASM*) architecture=wasm ;;
esac

binformat='bin32'
Expand Down
13 changes: 13 additions & 0 deletions cmake/prebuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ if (${COMPILER_ID} STREQUAL "GNU")
set(COMPILER_ID "GCC")
endif ()

if (HOST_OS STREQUAL "EMSCRIPTEN")
set (ARCH wasm)
endif()

string(TOUPPER ${ARCH} UC_ARCH)
file(WRITE ${TARGET_CONF_TEMP}
"#define OS_${HOST_OS}\t1\n"
Expand Down Expand Up @@ -1500,6 +1504,15 @@ endif ()
"#define DTB_DEFAULT_ENTRIES 128\n"
"#define DTB_SIZE 4096\n"
"#define L2_ASSOCIATIVE 4\n")
elseif ("${TCORE}" STREQUAL "WASM128_GENERIC")
file(APPEND ${TARGET_CONF_TEMP}
"#define L1_DATA_SIZE 32768\n"
"#define L1_DATA_LINESIZE 32\n"
"#define L2_SIZE 1048576\n"
"#define L2_LINESIZE 32 \n"
"#define DTB_DEFAULT_ENTRIES 128\n"
"#define DTB_SIZE 4096\n"
"#define L2_ASSOCIATIVE 4\n")
elseif ("${TCORE}" STREQUAL "LA64_GENERIC")
file(APPEND ${TARGET_CONF_TEMP}
"#define DTB_DEFAULT_ENTRIES 64\n")
Expand Down
4 changes: 4 additions & 0 deletions cmake/system.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,10 @@ if (DEFINED ARCH)
set(USE_GEMM3M 1)
endif ()

if (EMSCRIPTEN)
set(USE_GEMM3M 0)
endif ()

if (${CORE} STREQUAL "generic")
set(USE_GEMM3M 0)
endif ()
Expand Down
2 changes: 2 additions & 0 deletions cmake/system_check.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ if(CMAKE_CL_64 OR MINGW64)
else()
set(X86_64 1)
endif()
elseif(OS_EMSCRIPTEN)
set(WASM 1)
elseif(MINGW OR (MSVC AND NOT CMAKE_CROSSCOMPILING))
set(X86 1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc.*|power.*|Power.*" OR (CMAKE_SYSTEM_NAME MATCHES "Darwin" AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc.*"))
Expand Down
2 changes: 1 addition & 1 deletion cmake/utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ macro(ParseMakefileVars MAKEFILE_IN)
if (${OSNAME} STREQUAL Windows)
set (OSNAME WINNT)
endif ()
message(STATUS OS ${OSNAME} COMPILER ${C_COMPILER})
#message(STATUS OS ${OSNAME} COMPILER ${C_COMPILER})
set (IfElse 0)
set (ElseSeen 0)
set (SkipIfs 0)
Expand Down
8 changes: 7 additions & 1 deletion common.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,11 @@ typedef int blasint;
#endif
#endif

#ifdef __EMSCRIPTEN__
#if defined(ARCH_WASM)
#ifndef YIELDING
#define YIELDING
#endif
#endif

#if defined(_MSC_VER) && !defined(__clang__)
#undef YIELDING // MSVC doesn't support assembly code
Expand Down Expand Up @@ -498,6 +500,10 @@ please https://github.com/xianyi/OpenBLAS/issues/246
#include "common_csky.h"
#endif

#ifdef ARCH_WASM
#include "common_wasm.h"
#endif

#ifndef ASSEMBLER
#ifdef OS_WINDOWSSTORE
typedef char env_var_t[MAX_PATH];
Expand Down
91 changes: 91 additions & 0 deletions common_wasm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*****************************************************************************
Copyright (c) 2011-2014, 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 COPYRIGHT OWNER 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.
**********************************************************************************/

/*********************************************************************/
/* Copyright 2009, 2010 The University of Texas at Austin. */
/* 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. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
/* AUSTIN ``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 UNIVERSITY OF TEXAS AT */
/* AUSTIN 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. */
/* */
/* The views and conclusions contained in the software and */
/* documentation are those of the authors and should not be */
/* interpreted as representing official policies, either expressed */
/* or implied, of The University of Texas at Austin. */
/*********************************************************************/

#ifndef COMMON_WASM
#define COMMON_WASM

#define MB __sync_synchronize()
#define WMB __sync_synchronize()
#define RMB __sync_synchronize()

#ifndef ASSEMBLER


static inline int blas_quickdivide(blasint x, blasint y){
return x / y;
}

#endif

#define BUFFER_SIZE ( 16 << 20)
#define SEEK_ADDRESS

#endif

2 changes: 1 addition & 1 deletion ctest.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ ARCH_CSKY
#endif

#if defined(__EMSCRIPTEN__)
ARCH_RISCV64
ARCH_WASM
OS_WINDOWS
#endif

Expand Down
50 changes: 25 additions & 25 deletions ctest/c_cblat3c.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,10 @@ int /* Main program */ main(void)
real r__1;

/* Local variables */
integer nalf, idim[9];
logical same;
integer nbet, ntra;
logical rewi;
static integer nalf, idim[9];
static logical same;
static integer nbet, ntra;
static logical rewi;
extern /* Subroutine */ int cchk1_(char *, real *, real *, integer *,
integer *, logical *, logical *, logical *, integer *, integer *,
integer *, complex *, integer *, complex *, integer *, complex *,
Expand All @@ -306,35 +306,35 @@ int /* Main program */ main(void)
integer *, complex *, integer *, complex *, integer *, complex *,
complex *, complex *, complex *, complex *, complex *, complex *,
complex *, complex *, real *, complex *, integer *);
complex c__[4225] /* was [65][65] */;
real g[65];
integer i__, j, n;
logical fatal;
complex w[130];
static complex c__[4225] /* was [65][65] */;
static real g[65];
static integer i__, j, n;
static logical fatal;
static complex w[130];
extern /* Subroutine */ int cmmch_(char *, char *, integer *, integer *,
integer *, complex *, complex *, integer *, complex *, integer *,
complex *, complex *, integer *, complex *, real *, complex *,
integer *, real *, real *, logical *, integer *, logical *);
extern real sdiff_(real *, real *);
logical trace;
integer nidim;
char snaps[32];
integer isnum;
logical ltest[9];
complex aa[4225], ab[8450] /* was [65][130] */, bb[4225], cc[4225], as[
static logical trace;
static integer nidim;
static char snaps[32];
static integer isnum;
static logical ltest[9];
static complex aa[4225], ab[8450] /* was [65][130] */, bb[4225], cc[4225], as[
4225], bs[4225], cs[4225], ct[65];
logical sfatal, corder;
char snamet[12], transa[1], transb[1];
real thresh;
logical rorder;
static logical sfatal, corder;
static char snamet[12], transa[1], transb[1];
static real thresh;
static logical rorder;
extern /* Subroutine */ void cc3chke_(char *);
integer layout;
logical ltestt, tsterr;
complex alf[7];
static integer layout;
static logical ltestt, tsterr;
static complex alf[7];
extern logical lce_(complex *, complex *, integer *);
complex bet[7];
real eps, err;
char tmpchar;
static complex bet[7];
static real eps, err;
static char tmpchar;

/* Test program for the COMPLEX Level 3 Blas. */

Expand Down
18 changes: 18 additions & 0 deletions getarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,20 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#else
#endif

#ifdef FORCE_WASM128_GENERIC
#define FORCE
#define ARCHITECTURE "WASM"
#define SUBARCHITECTURE "WASM128_GENERIC"
#define SUBDIRNAME "wasm"
#define ARCHCONFIG "-DWASM128_GENERIC " \
"-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=32 " \
"-DL2_SIZE=1048576 -DL2_LINESIZE=32 " \
"-DDTB_DEFAULT_ENTRIES=128 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=4 "
#define LIBNAME "wasm128"
#define CORENAME "WASM128_GENERIC"
#else
#endif

#ifdef FORCE_CORTEXA15
#define FORCE
#define ARCHITECTURE "ARM"
Expand Down Expand Up @@ -1949,6 +1963,10 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define OPENBLAS_SUPPORTED
#endif

#ifdef __wasm__
#define OPENBLAS_SUPPORTED
#endif

#ifndef OPENBLAS_SUPPORTED
#error "This arch/CPU is not supported by OpenBLAS."
#endif
Expand Down
4 changes: 2 additions & 2 deletions kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function (build_core TARGET_CORE KDIR TSUFFIX KERNEL_DEFINITIONS)
endif ()

if (${ADD_COMMONOBJS})
if (X86)
if (X86 AND NOT EMSCRIPTEN)
if (NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
GenerateNamedObjects("${KERNELDIR}/cpuid.S" "" "" false "" "" true)
else()
Expand Down Expand Up @@ -235,7 +235,7 @@ function (build_core TARGET_CORE KDIR TSUFFIX KERNEL_DEFINITIONS)
# Makefile.L3
set(USE_TRMM false)
string(TOUPPER ${TARGET_CORE} UC_TARGET_CORE)
if (ARM OR ARM64 OR RISCV64 OR (UC_TARGET_CORE MATCHES LONGSOON3B) OR (UC_TARGET_CORE MATCHES GENERIC) OR (UC_TARGET_CORE MATCHES HASWELL) OR (UC_TARGET_CORE MATCHES ZEN) OR (UC_TARGET_CORE MATCHES SKYLAKEX) OR (UC_TARGET_CORE MATCHES COOPERLAKE) OR (UC_TARGET_CORE MATCHES SAPPHIRERAPIDS))
if (ARM OR ARM64 OR RISCV64 OR WASM OR (UC_TARGET_CORE MATCHES LONGSOON3B) OR (UC_TARGET_CORE MATCHES GENERIC) OR (UC_TARGET_CORE MATCHES HASWELL) OR (UC_TARGET_CORE MATCHES ZEN) OR (UC_TARGET_CORE MATCHES SKYLAKEX) OR (UC_TARGET_CORE MATCHES COOPERLAKE) OR (UC_TARGET_CORE MATCHES SAPPHIRERAPIDS))
set(USE_TRMM true)
endif ()
if (ZARCH OR (UC_TARGET_CORE MATCHES POWER8) OR (UC_TARGET_CORE MATCHES POWER9) OR (UC_TARGET_CORE MATCHES POWER10))
Expand Down
4 changes: 4 additions & 0 deletions kernel/Makefile.L3
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ ifeq ($(ARCH), riscv64)
USE_TRMM = 1
endif

ifeq ($(ARCH), wasm)
USE_TRMM = 1
endif

ifneq ($(DYNAMIC_ARCH), 1)
ifeq ($(TARGET), GENERIC)
USE_TRMM = 1
Expand Down
Loading
Loading