mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-27 20:14:27 +01:00
Merge branch 'master' of github.com:cirosantilli/linux-kernel-module-cheat
This commit is contained in:
30
README.adoc
30
README.adoc
@@ -4164,7 +4164,6 @@ Buildroot built-in libraries, mostly under Libraries > Other:
|
|||||||
|
|
||||||
* Armadillo `C++`: linear algebra
|
* Armadillo `C++`: linear algebra
|
||||||
* fftw: Fourier transform
|
* fftw: Fourier transform
|
||||||
* Eigen: linear algebra
|
|
||||||
* Flann
|
* Flann
|
||||||
* GSL: various
|
* GSL: various
|
||||||
* liblinear
|
* liblinear
|
||||||
@@ -4174,21 +4173,21 @@ Buildroot built-in libraries, mostly under Libraries > Other:
|
|||||||
|
|
||||||
There are not yet enabled, but it should be easy to so, see: <<add-new-buildroot-packages>>
|
There are not yet enabled, but it should be easy to so, see: <<add-new-buildroot-packages>>
|
||||||
|
|
||||||
|
===== OpenMP
|
||||||
|
|
||||||
|
Implemented by GCC itself, so just a toolchain configuration, no external libs, and we enable it by default:
|
||||||
|
|
||||||
|
....
|
||||||
|
/openmp.out
|
||||||
|
....
|
||||||
|
|
||||||
===== BLAS
|
===== BLAS
|
||||||
|
|
||||||
Buildroot supports it, which makes everything just trivial:
|
Buildroot supports it, which makes everything just trivial:
|
||||||
|
|
||||||
....
|
....
|
||||||
./build \
|
./build -a arm -B 'BR2_PACKAGE_OPENBLAS=y' -k
|
||||||
-a arm \
|
./run -F '/openblas.out'
|
||||||
-B 'BR2_PACKAGE_OPENBLAS=y' \
|
|
||||||
;
|
|
||||||
....
|
|
||||||
|
|
||||||
and then inside the guest run our test program:
|
|
||||||
|
|
||||||
....
|
|
||||||
/openblas.out
|
|
||||||
....
|
....
|
||||||
|
|
||||||
For x86, you also need:
|
For x86, you also need:
|
||||||
@@ -4203,6 +4202,15 @@ to overcome this bug: https://bugs.busybox.net/show_bug.cgi?id=10856
|
|||||||
sgemm_kernel.o: No such file or directory
|
sgemm_kernel.o: No such file or directory
|
||||||
....
|
....
|
||||||
|
|
||||||
|
===== Eigen
|
||||||
|
|
||||||
|
Header only linear algebra library supported by Buildroot:
|
||||||
|
|
||||||
|
....
|
||||||
|
./build -B 'BR2_PACKAGE_EIGEN=y' -k
|
||||||
|
./run -F '/eigen.out'
|
||||||
|
....
|
||||||
|
|
||||||
===== 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. Some of the benchmarks were are segfaulting, they are documented in that repo.
|
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. Some of the benchmarks were are segfaulting, they are documented in that repo.
|
||||||
|
|||||||
@@ -11,9 +11,14 @@ KERNEL_MODULE_SITE_METHOD = local
|
|||||||
ifeq ($(BR2_PACKAGE_OPENBLAS),y)
|
ifeq ($(BR2_PACKAGE_OPENBLAS),y)
|
||||||
KERNEL_MODULE_DEPENDENCIES += openblas
|
KERNEL_MODULE_DEPENDENCIES += openblas
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(BR2_PACKAGE_EIGEN),y)
|
||||||
|
KERNEL_MODULE_DEPENDENCIES += eigen
|
||||||
|
endif
|
||||||
|
|
||||||
define KERNEL_MODULE_BUILD_CMDS
|
define KERNEL_MODULE_BUILD_CMDS
|
||||||
$(MAKE) -C '$(@D)/user' $(TARGET_CONFIGURE_OPTS) BR2_PACKAGE_OPENBLAS="$(BR2_PACKAGE_OPENBLAS)"
|
$(MAKE) -C '$(@D)/user' $(TARGET_CONFIGURE_OPTS) \
|
||||||
|
BR2_PACKAGE_OPENBLAS="$(BR2_PACKAGE_OPENBLAS)" \
|
||||||
|
BR2_PACKAGE_EIGEN="$(BR2_PACKAGE_EIGEN)"
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define KERNEL_MODULE_INSTALL_TARGET_CMDS
|
define KERNEL_MODULE_INSTALL_TARGET_CMDS
|
||||||
|
|||||||
@@ -1,21 +1,31 @@
|
|||||||
.PHONY: all clean
|
.PHONY: all clean
|
||||||
|
|
||||||
CFLAGS_EXTRA ?= -fopenmp -std=c99 -Wall -Werror -Wextra
|
CFLAGS_EXTRA ?= -fopenmp -std=c99 -Wall -Werror -Wextra
|
||||||
IN_EXT ?= .c
|
IN_EXT_C ?= .c
|
||||||
|
IN_EXT_CXX ?= .cpp
|
||||||
LIBS :=
|
LIBS :=
|
||||||
OUT_EXT ?= .out
|
OUT_EXT ?= .out
|
||||||
|
|
||||||
OUTS := $(addsuffix $(OUT_EXT), $(basename $(wildcard *$(IN_EXT))))
|
OUTS := $(foreach IN_EXT,$(IN_EXT_C) $(IN_EXT_CXX),$(addsuffix $(OUT_EXT), $(basename $(wildcard *$(IN_EXT)))))
|
||||||
ifeq ($(BR2_PACKAGE_OPENBLAS),y)
|
ifeq ($(BR2_PACKAGE_OPENBLAS),y)
|
||||||
LIBS += -lopenblas
|
LIBS += -lopenblas
|
||||||
else
|
else
|
||||||
OUTS := $(filter-out openblas.out,$(OUTS))
|
OUTS := $(filter-out openblas$(OUT_EXT),$(OUTS))
|
||||||
|
endif
|
||||||
|
ifeq ($(BR2_PACKAGE_EIGEN),y)
|
||||||
|
# Header only.
|
||||||
|
#LIBS += -leigen
|
||||||
|
else
|
||||||
|
OUTS := $(filter-out eigen%$(OUT_EXT),$(OUTS))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
all: $(OUTS)
|
all: $(OUTS)
|
||||||
|
|
||||||
%$(OUT_EXT): %$(IN_EXT)
|
%$(OUT_EXT): %$(IN_EXT_C)
|
||||||
$(CC) $(CFLAGS) $(CFLAGS_EXTRA) -o '$@' '$<' $(LIBS)
|
$(CC) $(CFLAGS) $(CFLAGS_EXTRA) -o '$@' '$<' $(LIBS)
|
||||||
|
|
||||||
|
%$(OUT_EXT): %$(IN_EXT_CXX)
|
||||||
|
$(CXX) $(CXXFLAGS) $(CXXFLAGS_EXTRA) -o '$@' '$<' $(LIBS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *'$(OUT_EXT)'
|
rm -f *'$(OUT_EXT)'
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ These programs can also be compiled and used on host.
|
|||||||
|
|
||||||
. Standalone
|
. Standalone
|
||||||
.. link:hello.c[]
|
.. link:hello.c[]
|
||||||
|
.. link:hello_cpp.cpp[]
|
||||||
.. link:myinsmod.c[]
|
.. link:myinsmod.c[]
|
||||||
.. link:myrmmod.c[]
|
.. link:myrmmod.c[]
|
||||||
.. link:sched_getaffinity.c[]
|
.. link:sched_getaffinity.c[]
|
||||||
@@ -29,3 +30,7 @@ These programs can also be compiled and used on host.
|
|||||||
.. link:ioctl.c[]
|
.. link:ioctl.c[]
|
||||||
.. link:netlink.c[]
|
.. link:netlink.c[]
|
||||||
.. link:poll.c[]
|
.. link:poll.c[]
|
||||||
|
. Buildroot libraries
|
||||||
|
.. link:eigen.cpp[]
|
||||||
|
.. link:openmp.c[]
|
||||||
|
.. link:openblas.c[]
|
||||||
|
|||||||
14
kernel_module/user/eigen.cpp
Normal file
14
kernel_module/user/eigen.cpp
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
/* Official hello world. */
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <eigen3/Eigen/Dense>
|
||||||
|
using Eigen::MatrixXd;
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
MatrixXd m(2,2);
|
||||||
|
m(0,0) = 3;
|
||||||
|
m(1,0) = 2.5;
|
||||||
|
m(0,1) = -1;
|
||||||
|
m(1,1) = m(1,0) + m(0,1);
|
||||||
|
std::cout << m << std::endl;
|
||||||
|
}
|
||||||
5
kernel_module/user/hello_cpp.cpp
Normal file
5
kernel_module/user/hello_cpp.cpp
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::cout << "hello world" << std::endl;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user