mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
OpenBLAS
Also don't add br2_local by default, default params are insane.
This commit is contained in:
34
README.adoc
34
README.adoc
@@ -2015,6 +2015,34 @@ External open source benchmarks. We will try to create Buildroot packages for th
|
|||||||
* http://parsec.cs.princeton.edu/ Mentioned on docs: http://gem5.org/PARSEC_benchmarks
|
* http://parsec.cs.princeton.edu/ Mentioned on docs: http://gem5.org/PARSEC_benchmarks
|
||||||
* http://www.m5sim.org/Splash_benchmarks
|
* http://www.m5sim.org/Splash_benchmarks
|
||||||
|
|
||||||
|
===== BLAS
|
||||||
|
|
||||||
|
Buildroot supports it, which makes everything just trivial:
|
||||||
|
|
||||||
|
....
|
||||||
|
printf 'BR2_PACKAGE_OPENBLAS=y\n' >> br2_local
|
||||||
|
printf 'BR2_TARGET_ROOTFS_EXT2_SIZE="128M"\n' >> br2_local
|
||||||
|
./build -a arm -g -i br2_local -- kernel_module-reconfigure
|
||||||
|
....
|
||||||
|
|
||||||
|
and then inside the guest run our test program:
|
||||||
|
|
||||||
|
....
|
||||||
|
/openblas.out
|
||||||
|
....
|
||||||
|
|
||||||
|
For x86, you also need:
|
||||||
|
|
||||||
|
....
|
||||||
|
printf 'BR2_PACKAGE_OPENBLAS_TARGET="NEHALEM"\n' >> br2_local
|
||||||
|
....
|
||||||
|
|
||||||
|
to overcome this bug: https://bugs.busybox.net/show_bug.cgi?id=10856
|
||||||
|
|
||||||
|
....
|
||||||
|
sgemm_kernel.o: No such file or directory
|
||||||
|
....
|
||||||
|
|
||||||
===== PARSEC benchmark
|
===== PARSEC benchmark
|
||||||
|
|
||||||
We have ported parts of the link:http://parsec.cs.princeton.edu[PARSEC benchmark] for cross compilation at: https://github.com/cirosantilli/parsec-benchmark See the documentation on that repo to find out which benchmarks have been ported. Furthermore, some of the benchmarks were are segfaulting, see link:parsec-benchmark/test.sh[]
|
We have ported parts of the link:http://parsec.cs.princeton.edu[PARSEC benchmark] for cross compilation at: https://github.com/cirosantilli/parsec-benchmark See the documentation on that repo to find out which benchmarks have been ported. Furthermore, some of the benchmarks were are segfaulting, see link:parsec-benchmark/test.sh[]
|
||||||
@@ -2541,12 +2569,14 @@ dmesg
|
|||||||
|
|
||||||
We provide the following mechanisms:
|
We provide the following mechanisms:
|
||||||
|
|
||||||
* `br2_local`: a gitignored file that gets appended to the `.config`. Get started with:
|
* `./build -i br2_local`: append the file `br2_local` to a single build. Must be passed every time you run `./build`.
|
||||||
|
+
|
||||||
|
For convenience, we already gitignore `br2_local` for you.
|
||||||
+
|
+
|
||||||
....
|
....
|
||||||
cp br2_local.off br2_local
|
cp br2_local.off br2_local
|
||||||
....
|
....
|
||||||
* `./build -i somefile`: append `somefile` to a single build. Must be passed every time you run `./build`.
|
+
|
||||||
* `./build -c 'BR2_SOM_OPTION="myval"'`: append a single option to a single build.
|
* `./build -c 'BR2_SOM_OPTION="myval"'`: append a single option to a single build.
|
||||||
|
|
||||||
=== ccache
|
=== ccache
|
||||||
|
|||||||
3
build
3
build
@@ -57,9 +57,6 @@ while getopts 'a:c:Cgj:i:kK:lp:qS:v' OPT; do
|
|||||||
done
|
done
|
||||||
shift $(($OPTIND - 1))
|
shift $(($OPTIND - 1))
|
||||||
extra_make_args="$extra_make_args $@"
|
extra_make_args="$extra_make_args $@"
|
||||||
if [ -f br2_local ]; then
|
|
||||||
config_fragments="$config_fragments br2_local"
|
|
||||||
fi
|
|
||||||
case "$arch" in
|
case "$arch" in
|
||||||
x86_64)
|
x86_64)
|
||||||
defconfig=qemu_x86_64_defconfig
|
defconfig=qemu_x86_64_defconfig
|
||||||
|
|||||||
@@ -8,8 +8,12 @@ KERNEL_MODULE_VERSION = 1.0
|
|||||||
KERNEL_MODULE_SITE = $(BR2_EXTERNAL_KERNEL_MODULE_PATH)
|
KERNEL_MODULE_SITE = $(BR2_EXTERNAL_KERNEL_MODULE_PATH)
|
||||||
KERNEL_MODULE_SITE_METHOD = local
|
KERNEL_MODULE_SITE_METHOD = local
|
||||||
|
|
||||||
|
ifeq ($(BR2_PACKAGE_OPENBLAS),y)
|
||||||
|
KERNEL_MODULE_DEPENDENCIES += openblas
|
||||||
|
endif
|
||||||
|
|
||||||
define KERNEL_MODULE_BUILD_CMDS
|
define KERNEL_MODULE_BUILD_CMDS
|
||||||
$(MAKE) -C '$(@D)/user' CC="$(TARGET_CC)" LD="$(TARGET_LD)"
|
$(MAKE) -C '$(@D)/user' BR2_PACKAGE_OPENBLAS="$(BR2_PACKAGE_OPENBLAS)" CC="$(TARGET_CC)" LD="$(TARGET_LD)"
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define KERNEL_MODULE_INSTALL_TARGET_CMDS
|
define KERNEL_MODULE_INSTALL_TARGET_CMDS
|
||||||
|
|||||||
@@ -2,14 +2,20 @@
|
|||||||
|
|
||||||
CFLAGS_EXTRA ?= -ggdb3 -fopenmp -O0 -std=c99 -Wall -Werror -Wextra
|
CFLAGS_EXTRA ?= -ggdb3 -fopenmp -O0 -std=c99 -Wall -Werror -Wextra
|
||||||
IN_EXT ?= .c
|
IN_EXT ?= .c
|
||||||
|
LIBS :=
|
||||||
OUT_EXT ?= .out
|
OUT_EXT ?= .out
|
||||||
|
|
||||||
OUTS := $(addsuffix $(OUT_EXT), $(basename $(wildcard *$(IN_EXT))))
|
OUTS := $(addsuffix $(OUT_EXT), $(basename $(wildcard *$(IN_EXT))))
|
||||||
|
ifeq ($(BR2_PACKAGE_OPENBLAS),y)
|
||||||
|
LIBS += -lopenblas
|
||||||
|
else
|
||||||
|
OUTS := $(filter-out openblas.out,$(OUTS))
|
||||||
|
endif
|
||||||
|
|
||||||
all: $(OUTS)
|
all: $(OUTS)
|
||||||
|
|
||||||
%$(OUT_EXT): %$(IN_EXT)
|
%$(OUT_EXT): %$(IN_EXT)
|
||||||
$(CC) $(CFLAGS) $(CFLAGS_EXTRA) -o '$@' '$<'
|
$(CC) $(CFLAGS) $(CFLAGS_EXTRA) -o '$@' '$<' $(LIBS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *'$(OUT_EXT)'
|
rm -f *'$(OUT_EXT)'
|
||||||
|
|||||||
18
kernel_module/user/openblas.c
Normal file
18
kernel_module/user/openblas.c
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
OpenBLAS hello world, initially adapted from:
|
||||||
|
https://stackoverflow.com/questions/49227682/gem5-can-not-simulate-my-program-that-calls-openblas-functions-with-an-fatal-err
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <cblas.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
size_t i = 0;
|
||||||
|
double A[6] = {1.0,2.0,1.0,-3.0,4.0,-1.0};
|
||||||
|
double B[6] = {1.0,2.0,1.0,-3.0,4.0,-1.0};
|
||||||
|
double C[9] = {.5,.5,.5,.5,.5,.5,.5,.5,.5};
|
||||||
|
cblas_dgemm(CblasColMajor, CblasNoTrans, CblasTrans,3,3,2,1,A, 3, B, 3,2,C,3);
|
||||||
|
for(i = 0; i < 9; i++)
|
||||||
|
printf("%f ", C[i]);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
1
run
1
run
@@ -70,6 +70,7 @@ fi
|
|||||||
root_dir="$(pwd)"
|
root_dir="$(pwd)"
|
||||||
buildroot_dir="${root_dir}/buildroot"
|
buildroot_dir="${root_dir}/buildroot"
|
||||||
out_dir="${root_dir}/buildroot/output.${arch_dir}~"
|
out_dir="${root_dir}/buildroot/output.${arch_dir}~"
|
||||||
|
images_dir="${out_dir}/images"
|
||||||
|
|
||||||
if "$gem5"; then
|
if "$gem5"; then
|
||||||
build_dir="${out_dir}/build/gem5-1.0"
|
build_dir="${out_dir}/build/gem5-1.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user