Skip to content

Commit 0cc3677

Browse files
authored
Merge pull request #3073 from xoviat/embedded
add embedded option
2 parents 558cd54 + 2e8d6e8 commit 0cc3677

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,4 @@ benchmark/*.goto
9191
benchmark/smallscaling
9292
CMakeCache.txt
9393
CMakeFiles/*
94+
.vscode

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ Please note that it is not possible to combine support for different architectur
212212
- **Android**: Supported by the community. Please read <https://github.com/xianyi/OpenBLAS/wiki/How-to-build-OpenBLAS-for-Android>.
213213
- **AIX**: Supported on PPC up to POWER8
214214
- **Haiku**: Supported by the community. We don't actively test the library on this OS.
215-
- **SunOS**: Supported by the community. We don't actively test the library on this OS:
215+
- **SunOS**: Supported by the community. We don't actively test the library on this OS.
216+
- **Cortex-M**: Supported by the community. Please read <https://github.com/xianyi/OpenBLAS/wiki/How-to-use-OpenBLAS-on-Cortex-M>.
216217

217218
## Usage
218219

cmake/system.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,11 @@ if (BINARY64)
233233
endif ()
234234
endif ()
235235

236+
if(EMBEDDED)
237+
set(CCOMMON_OPT "${CCOMMON_OPT} -DOS_EMBEDDED")
238+
set(CCOMMON_OPT "${CCOMMON_OPT} -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16")
239+
endif()
240+
236241
if (NEED_PIC)
237242
if (${CMAKE_C_COMPILER} STREQUAL "IBM")
238243
set(CCOMMON_OPT "${CCOMMON_OPT} -qpic=large")

common.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ extern "C" {
122122
#define ATOM GOTO_ATOM
123123
#undef GOTO_ATOM
124124
#endif
125-
#else
125+
#elif !defined(OS_EMBEDDED)
126126
#include <sys/mman.h>
127127
#ifndef NO_SYSV_IPC
128128
#include <sys/shm.h>
@@ -134,6 +134,9 @@ extern "C" {
134134
#if defined(SMP) || defined(USE_LOCKING)
135135
#include <pthread.h>
136136
#endif
137+
#else
138+
#include <time.h>
139+
#include <math.h>
137140
#endif
138141

139142
#if defined(OS_SUNOS)
@@ -488,10 +491,12 @@ static inline unsigned long long rpcc(void){
488491
struct timespec ts;
489492
clock_gettime(CLOCK_MONOTONIC, &ts);
490493
return (unsigned long long)ts.tv_sec * 1000000000ull + ts.tv_nsec;
491-
#else
494+
#elif !defined(OS_EMBEDDED)
492495
struct timeval tv;
493496
gettimeofday(&tv,NULL);
494497
return (unsigned long long)tv.tv_sec * 1000000000ull + tv.tv_usec * 1000;
498+
#else
499+
return 0;
495500
#endif
496501
}
497502
#define RPCC_DEFINED
@@ -521,6 +526,10 @@ static void __inline blas_lock(volatile BLASULONG *address){
521526
#include "common_linux.h"
522527
#endif
523528

529+
#ifdef OS_EMBEDDED
530+
#define DTB_DEFAULT_ENTRIES 64
531+
#endif
532+
524533
#define MMAP_ACCESS (PROT_READ | PROT_WRITE)
525534

526535
#ifdef __NetBSD__

driver/others/memory.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,16 +1668,23 @@ void gotoblas_dummy_for_PGI(void) {
16681668
#ifndef MEM_LARGE_PAGES
16691669
#define MEM_LARGE_PAGES 0x20000000
16701670
#endif
1671-
#else
1671+
#elif !defined(OS_EMBEDDED)
16721672
#define ALLOC_MMAP
16731673
#define ALLOC_MALLOC
1674+
#else
1675+
#define ALLOC_MALLOC
1676+
1677+
inline int puts(const char *str) { return 0; }
1678+
inline int printf(const char *format, ...) { return 0; }
1679+
inline char *getenv(const char *name) { return ""; }
1680+
inline int atoi(const char *str) { return 0; }
16741681
#endif
16751682

16761683
#include <stdlib.h>
16771684
#include <stdio.h>
16781685
#include <fcntl.h>
16791686

1680-
#if !defined(OS_WINDOWS) || defined(OS_CYGWIN_NT)
1687+
#if (!defined(OS_WINDOWS) || defined(OS_CYGWIN_NT)) && !defined(OS_EMBEDDED)
16811688
#include <sys/mman.h>
16821689
#ifndef NO_SYSV_IPC
16831690
#include <sys/shm.h>

0 commit comments

Comments
 (0)