mirror of
https://github.com/trholding/llama2.c.git
synced 2026-02-06 11:26:53 +00:00
unikernel support (WIP)
Usage: make run_unik_qemu_x86_64 Run with: qemu-system-x86_64 -m 256m -accel kvm -kernel build/L2E_qemu-x86_64
This commit is contained in:
parent
d588cc1289
commit
f2fee04b35
6
Config.uk
Normal file
6
Config.uk
Normal file
@ -0,0 +1,6 @@
|
||||
### Invisible option for dependencies
|
||||
config L2E_DEPENDENCIES
|
||||
bool
|
||||
default y
|
||||
select LIBMUSL
|
||||
|
||||
332
L2E_amd64_qemu.config
Normal file
332
L2E_amd64_qemu.config
Normal file
@ -0,0 +1,332 @@
|
||||
#
|
||||
# Automatically generated file; DO NOT EDIT.
|
||||
# Unikraft/0.14.0~2ebfa32b Configuration
|
||||
#
|
||||
CONFIG_UK_FULLVERSION="0.14.0~2ebfa32b"
|
||||
CONFIG_UK_CODENAME="Prometheus"
|
||||
CONFIG_UK_ARCH="x86_64"
|
||||
CONFIG_UK_DEFNAME="L2E"
|
||||
|
||||
#
|
||||
# Architecture Selection
|
||||
#
|
||||
CONFIG_ARCH_X86_64=y
|
||||
# CONFIG_ARCH_ARM_64 is not set
|
||||
# CONFIG_ARCH_ARM_32 is not set
|
||||
# CONFIG_MARCH_X86_64_NATIVE is not set
|
||||
CONFIG_MARCH_X86_64_GENERIC=y
|
||||
# CONFIG_MARCH_X86_64_NOCONA is not set
|
||||
# CONFIG_MARCH_X86_64_CORE2 is not set
|
||||
# CONFIG_MARCH_X86_64_COREI7 is not set
|
||||
# CONFIG_MARCH_X86_64_COREI7AVX is not set
|
||||
# CONFIG_MARCH_X86_64_COREI7AVXI is not set
|
||||
# CONFIG_MARCH_X86_64_ATOM is not set
|
||||
# CONFIG_MARCH_X86_64_K8 is not set
|
||||
# CONFIG_MARCH_X86_64_K8SSE3 is not set
|
||||
# CONFIG_MARCH_X86_64_AMDFAM10 is not set
|
||||
# CONFIG_MARCH_X86_64_BTVER1 is not set
|
||||
# CONFIG_MARCH_X86_64_BDVER1 is not set
|
||||
# CONFIG_MARCH_X86_64_BDVER2 is not set
|
||||
# CONFIG_MARCH_X86_64_BDVER3 is not set
|
||||
# CONFIG_MARCH_X86_64_BTVER2 is not set
|
||||
|
||||
#
|
||||
# Processor Features
|
||||
#
|
||||
# CONFIG_X86_64_HAVE_RANDOM is not set
|
||||
# end of Processor Features
|
||||
|
||||
CONFIG_STACK_SIZE_PAGE_ORDER=4
|
||||
# end of Architecture Selection
|
||||
|
||||
#
|
||||
# Platform Configuration
|
||||
#
|
||||
CONFIG_PLAT_KVM=y
|
||||
CONFIG_KVM_BOOT_PROTO_MULTIBOOT=y
|
||||
|
||||
#
|
||||
# Hint: EFI stub depends on OPTIMIZE_PIE
|
||||
#
|
||||
CONFIG_KVM_VMM_QEMU=y
|
||||
# CONFIG_KVM_VMM_FIRECRACKER is not set
|
||||
|
||||
#
|
||||
# Console Options
|
||||
#
|
||||
CONFIG_KVM_KERNEL_VGA_CONSOLE=y
|
||||
CONFIG_KVM_DEBUG_SERIAL_CONSOLE=y
|
||||
CONFIG_KVM_DEBUG_VGA_CONSOLE=y
|
||||
CONFIG_KVM_KERNEL_SERIAL_CONSOLE=y
|
||||
|
||||
#
|
||||
# Serial console configuration
|
||||
#
|
||||
CONFIG_KVM_SERIAL_BAUD_115200=y
|
||||
# CONFIG_KVM_SERIAL_BAUD_57600 is not set
|
||||
# CONFIG_KVM_SERIAL_BAUD_38400 is not set
|
||||
# CONFIG_KVM_SERIAL_BAUD_19200 is not set
|
||||
# end of Serial console configuration
|
||||
# end of Console Options
|
||||
|
||||
CONFIG_KVM_MAX_IRQ_HANDLER_ENTRIES=8
|
||||
# CONFIG_KVM_PCI is not set
|
||||
CONFIG_VIRTIO_BUS=y
|
||||
|
||||
#
|
||||
# Virtio
|
||||
#
|
||||
# end of Virtio
|
||||
|
||||
CONFIG_UKPLAT_ALLOW_GIC=y
|
||||
# CONFIG_PLAT_LINUXU is not set
|
||||
# CONFIG_PLAT_XEN is not set
|
||||
|
||||
#
|
||||
# Platform Interface Options
|
||||
#
|
||||
# CONFIG_UKPLAT_MEMRNAME is not set
|
||||
CONFIG_UKPLAT_MEMREGION_MAX_COUNT=128
|
||||
# CONFIG_UKPLAT_ACPI is not set
|
||||
CONFIG_UKPLAT_LCPU_MAXCOUNT=1
|
||||
# CONFIG_UKPLAT_ISR_ECTX_ASSERTIONS is not set
|
||||
# CONFIG_PAGING is not set
|
||||
# end of Platform Interface Options
|
||||
|
||||
CONFIG_HZ=100
|
||||
# end of Platform Configuration
|
||||
|
||||
#
|
||||
# Library Configuration
|
||||
#
|
||||
# CONFIG_LIBDEVFS is not set
|
||||
# CONFIG_LIBFDT is not set
|
||||
# CONFIG_LIBISRLIB is not set
|
||||
CONFIG_LIBPOSIX_ENVIRON=y
|
||||
|
||||
#
|
||||
# Compiled-in environment variables
|
||||
#
|
||||
CONFIG_LIBPOSIX_ENVIRON_ENVP0="PATH=/bin"
|
||||
CONFIG_LIBPOSIX_ENVIRON_ENVP0_NOTEMPTY=y
|
||||
CONFIG_LIBPOSIX_ENVIRON_ENVP1=""
|
||||
CONFIG_LIBPOSIX_ENVIRON_ENVP2=""
|
||||
CONFIG_LIBPOSIX_ENVIRON_ENVP3=""
|
||||
CONFIG_LIBPOSIX_ENVIRON_ENVP4=""
|
||||
CONFIG_LIBPOSIX_ENVIRON_ENVP5=""
|
||||
CONFIG_LIBPOSIX_ENVIRON_ENVP6=""
|
||||
CONFIG_LIBPOSIX_ENVIRON_ENVP7=""
|
||||
CONFIG_LIBPOSIX_ENVIRON_ENVP8=""
|
||||
CONFIG_LIBPOSIX_ENVIRON_ENVP9=""
|
||||
CONFIG_LIBPOSIX_ENVIRON_ENVP10=""
|
||||
CONFIG_LIBPOSIX_ENVIRON_ENVP11=""
|
||||
CONFIG_LIBPOSIX_ENVIRON_ENVP12=""
|
||||
CONFIG_LIBPOSIX_ENVIRON_ENVP13=""
|
||||
CONFIG_LIBPOSIX_ENVIRON_ENVP14=""
|
||||
CONFIG_LIBPOSIX_ENVIRON_ENVP15=""
|
||||
# end of Compiled-in environment variables
|
||||
|
||||
# CONFIG_LIBPOSIX_ENVIRON_LIBPARAM is not set
|
||||
# CONFIG_LIBPOSIX_EVENT is not set
|
||||
CONFIG_LIBPOSIX_FUTEX=y
|
||||
# CONFIG_LIBPOSIX_FUTEX_DEBUG is not set
|
||||
# CONFIG_LIBPOSIX_FUTEX_TEST is not set
|
||||
# CONFIG_LIBPOSIX_LIBDL is not set
|
||||
CONFIG_LIBPOSIX_PROCESS=y
|
||||
CONFIG_LIBPOSIX_PROCESS_PIDS=y
|
||||
CONFIG_LIBPOSIX_PROCESS_MAX_PID=31
|
||||
CONFIG_LIBPOSIX_PROCESS_INIT_PIDS=y
|
||||
CONFIG_LIBPOSIX_PROCESS_CLONE=y
|
||||
# CONFIG_LIBPOSIX_PROCESS_DEBUG is not set
|
||||
# CONFIG_LIBPOSIX_SOCKET is not set
|
||||
# CONFIG_LIBPOSIX_SYSINFO is not set
|
||||
CONFIG_LIBPOSIX_TIME=y
|
||||
# CONFIG_LIBPOSIX_USER is not set
|
||||
# CONFIG_LIBRAMFS is not set
|
||||
CONFIG_LIBSYSCALL_SHIM=y
|
||||
CONFIG_LIBSYSCALL_SHIM_NOWRAPPER=y
|
||||
# CONFIG_LIBSYSCALL_SHIM_HANDLER is not set
|
||||
|
||||
#
|
||||
# Debugging
|
||||
#
|
||||
# CONFIG_LIBSYSCALL_SHIM_DEBUG_SYSCALLS is not set
|
||||
# CONFIG_LIBSYSCALL_SHIM_DEBUG is not set
|
||||
CONFIG_LIBSYSCALL_SHIM_LEGACY_VERBOSE=y
|
||||
# end of Debugging
|
||||
|
||||
# CONFIG_LIBUBSAN is not set
|
||||
# CONFIG_LIBUK9P is not set
|
||||
CONFIG_LIBUKALLOC=y
|
||||
# CONFIG_LIBUKALLOC_IFMALLOC is not set
|
||||
# CONFIG_LIBUKALLOC_IFSTATS is not set
|
||||
CONFIG_LIBUKALLOCBBUDDY=y
|
||||
# CONFIG_LIBUKALLOCBBUDDY_FREELIST_SANITY is not set
|
||||
# CONFIG_LIBUKALLOCPOOL is not set
|
||||
# CONFIG_LIBUKALLOCREGION is not set
|
||||
CONFIG_LIBUKARGPARSE=y
|
||||
# CONFIG_LIBUKARGPARSE_TEST is not set
|
||||
# CONFIG_LIBUKBLKDEV is not set
|
||||
CONFIG_LIBUKBOOT=y
|
||||
CONFIG_LIBUKBOOT_BANNER_NONE=y
|
||||
# CONFIG_LIBUKBOOT_BANNER_MINIMAL is not set
|
||||
# CONFIG_LIBUKBOOT_BANNER_CLASSIC is not set
|
||||
# CONFIG_LIBUKBOOT_BANNER_POWEREDBY is not set
|
||||
# CONFIG_LIBUKBOOT_BANNER_POWEREDBY_ANSI is not set
|
||||
# CONFIG_LIBUKBOOT_BANNER_POWEREDBY_ANSI2 is not set
|
||||
# CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EA is not set
|
||||
# CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EAANSI is not set
|
||||
# CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EAANSI2 is not set
|
||||
# CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8 is not set
|
||||
# CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8ANSI is not set
|
||||
# CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8ANSI2 is not set
|
||||
CONFIG_LIBUKBOOT_MAXNBARGS=60
|
||||
CONFIG_LIBUKBOOT_INITBBUDDY=y
|
||||
# CONFIG_LIBUKBOOT_INITREGION is not set
|
||||
# CONFIG_LIBUKBOOT_NOALLOC is not set
|
||||
CONFIG_LIBUKBOOT_INITSCHEDCOOP=y
|
||||
# CONFIG_LIBUKBOOT_NOSCHED is not set
|
||||
CONFIG_LIBUKBUS=y
|
||||
# CONFIG_LIBUKCPIO is not set
|
||||
CONFIG_LIBUKDEBUG=y
|
||||
CONFIG_LIBUKDEBUG_PRINTK=y
|
||||
# CONFIG_LIBUKDEBUG_PRINTK_INFO is not set
|
||||
# CONFIG_LIBUKDEBUG_PRINTK_WARN is not set
|
||||
CONFIG_LIBUKDEBUG_PRINTK_ERR=y
|
||||
# CONFIG_LIBUKDEBUG_PRINTK_CRIT is not set
|
||||
# CONFIG_LIBUKDEBUG_PRINTD is not set
|
||||
# CONFIG_LIBUKDEBUG_NOREDIR is not set
|
||||
CONFIG_LIBUKDEBUG_REDIR_PRINTD=y
|
||||
# CONFIG_LIBUKDEBUG_REDIR_PRINTK is not set
|
||||
CONFIG_LIBUKDEBUG_PRINT_TIME=y
|
||||
# CONFIG_LIBUKDEBUG_PRINT_THREAD is not set
|
||||
# CONFIG_LIBUKDEBUG_PRINT_CALLER is not set
|
||||
CONFIG_LIBUKDEBUG_PRINT_SRCNAME=y
|
||||
# CONFIG_LIBUKDEBUG_ANSI_COLOR is not set
|
||||
# CONFIG_LIBUKDEBUG_ENABLE_ASSERT is not set
|
||||
# CONFIG_LIBUKDEBUG_TRACEPOINTS is not set
|
||||
# CONFIG_LIBUKFALLOC is not set
|
||||
# CONFIG_LIBUKFALLOCBUDDY is not set
|
||||
CONFIG_LIBUKLIBID=y
|
||||
# CONFIG_LIBUKLIBPARAM is not set
|
||||
CONFIG_LIBUKLOCK=y
|
||||
CONFIG_LIBUKLOCK_SEMAPHORE=y
|
||||
CONFIG_LIBUKLOCK_MUTEX=y
|
||||
# CONFIG_LIBUKLOCK_MUTEX_METRICS is not set
|
||||
CONFIG_LIBUKLOCK_RWLOCK=y
|
||||
CONFIG_LIBUKMMAP=y
|
||||
# CONFIG_LIBUKMMAP_TEST is not set
|
||||
# CONFIG_LIBUKMPI is not set
|
||||
# CONFIG_LIBUKNETDEV is not set
|
||||
# CONFIG_LIBUKNOFAULT is not set
|
||||
# CONFIG_LIBUKRING is not set
|
||||
# CONFIG_LIBUKRUST is not set
|
||||
CONFIG_LIBUKSCHED=y
|
||||
CONFIG_LIBUKSCHED_TCB_INIT=y
|
||||
# CONFIG_LIBUKSCHED_DEBUG is not set
|
||||
CONFIG_LIBUKSCHEDCOOP=y
|
||||
CONFIG_LIBUKSGLIST=y
|
||||
CONFIG_LIBUKSIGNAL=y
|
||||
# CONFIG_LIBUKSP is not set
|
||||
# CONFIG_LIBUKSTORE is not set
|
||||
CONFIG_LIBUKSTREAMBUF=y
|
||||
# CONFIG_LIBUKSTREAMBUF_TEST is not set
|
||||
# CONFIG_LIBUKSWRAND is not set
|
||||
# CONFIG_LIBUKTEST is not set
|
||||
CONFIG_LIBUKTIMECONV=y
|
||||
# CONFIG_LIBUKVMEM is not set
|
||||
CONFIG_LIBVFSCORE=y
|
||||
|
||||
#
|
||||
# vfscore: Configuration
|
||||
#
|
||||
CONFIG_LIBVFSCORE_PIPE_SIZE_ORDER=16
|
||||
# CONFIG_LIBVFSCORE_NONLARGEFILE is not set
|
||||
# CONFIG_LIBVFSCORE_AUTOMOUNT_ROOTFS is not set
|
||||
# CONFIG_LIBVFSCORE_FSTAB is not set
|
||||
# end of vfscore: Configuration
|
||||
|
||||
CONFIG_HAVE_BOOTENTRY=y
|
||||
CONFIG_HAVE_LIBC=y
|
||||
CONFIG_HAVE_TIME=y
|
||||
CONFIG_HAVE_SCHED=y
|
||||
CONFIG_LIBMUSL=y
|
||||
CONFIG_LIBMUSL_AIO=y
|
||||
# CONFIG_LIBMUSL_COMPLEX is not set
|
||||
CONFIG_LIBMUSL_CONF=y
|
||||
CONFIG_LIBMUSL_CRYPT=y
|
||||
CONFIG_LIBMUSL_CTYPE=y
|
||||
CONFIG_LIBMUSL_DIRENT=y
|
||||
CONFIG_LIBMUSL_ENV=y
|
||||
CONFIG_LIBMUSL_ERRNO=y
|
||||
CONFIG_LIBMUSL_EXIT=y
|
||||
CONFIG_LIBMUSL_FCNTL=y
|
||||
CONFIG_LIBMUSL_FENV=y
|
||||
CONFIG_LIBMUSL_INTERNAL=y
|
||||
CONFIG_LIBMUSL_IPC=y
|
||||
CONFIG_LIBMUSL_LDSO=y
|
||||
CONFIG_LIBMUSL_LEGACY=y
|
||||
CONFIG_LIBMUSL_LINUX=y
|
||||
CONFIG_LIBMUSL_LOCALE=y
|
||||
CONFIG_LIBMUSL_LOCALE_LEGACY=y
|
||||
CONFIG_LIBMUSL_MALLOC=y
|
||||
CONFIG_LIBMUSL_MATH=y
|
||||
CONFIG_LIBMUSL_MISC=y
|
||||
CONFIG_LIBMUSL_MMAN=y
|
||||
CONFIG_LIBMUSL_MQ=y
|
||||
CONFIG_LIBMUSL_MULTIBYTE=y
|
||||
CONFIG_LIBMUSL_NETWORK=y
|
||||
CONFIG_LIBMUSL_PASSWD=y
|
||||
CONFIG_LIBMUSL_PRNG=y
|
||||
CONFIG_LIBMUSL_PROCESS=y
|
||||
CONFIG_LIBMUSL_REGEX=y
|
||||
CONFIG_LIBMUSL_SCHED=y
|
||||
CONFIG_LIBMUSL_SEARCH=y
|
||||
CONFIG_LIBMUSL_SELECT=y
|
||||
CONFIG_LIBMUSL_SETJMP=y
|
||||
CONFIG_LIBMUSL_SIGNAL=y
|
||||
CONFIG_LIBMUSL_STAT=y
|
||||
CONFIG_LIBMUSL_STDIO=y
|
||||
CONFIG_LIBMUSL_STDLIB=y
|
||||
CONFIG_LIBMUSL_STRING=y
|
||||
CONFIG_LIBMUSL_TEMP=y
|
||||
CONFIG_LIBMUSL_TERMIOS=y
|
||||
CONFIG_LIBMUSL_THREAD=y
|
||||
CONFIG_LIBMUSL_FORCE_THREAD=y
|
||||
CONFIG_LIBMUSL_TIME=y
|
||||
CONFIG_LIBMUSL_UNISTD=y
|
||||
# end of Library Configuration
|
||||
|
||||
#
|
||||
# Application Options
|
||||
#
|
||||
CONFIG_L2E_DEPENDENCIES=y
|
||||
# end of Application Options
|
||||
|
||||
#
|
||||
# Build Options
|
||||
#
|
||||
# CONFIG_OPTIMIZE_NONE is not set
|
||||
CONFIG_OPTIMIZE_PERF=y
|
||||
# CONFIG_OPTIMIZE_SIZE is not set
|
||||
|
||||
#
|
||||
# Hint: Specify a CPU type to get most benefits from performance optimization
|
||||
#
|
||||
CONFIG_OPTIMIZE_NOOMITFP=y
|
||||
CONFIG_OPTIMIZE_DEADELIM=y
|
||||
CONFIG_OPTIMIZE_LTO=y
|
||||
# CONFIG_OPTIMIZE_PIE is not set
|
||||
# CONFIG_DEBUG_SYMBOLS_LVL0 is not set
|
||||
# CONFIG_DEBUG_SYMBOLS_LVL1 is not set
|
||||
# CONFIG_DEBUG_SYMBOLS_LVL2 is not set
|
||||
CONFIG_DEBUG_SYMBOLS_LVL3=y
|
||||
# CONFIG_OPTIMIZE_WARNISERROR is not set
|
||||
# CONFIG_OPTIMIZE_SYMFILE is not set
|
||||
CONFIG_OPTIMIZE_COMPRESS=y
|
||||
# CONFIG_RECORD_BUILDTIME is not set
|
||||
CONFIG_CROSS_COMPILE=""
|
||||
CONFIG_LLVM_TARGET_ARCH=""
|
||||
# end of Build Options
|
||||
|
||||
CONFIG_UK_NAME="L2E"
|
||||
11
Makefile
11
Makefile
@ -170,6 +170,11 @@ run_clang_static_strlit: run.c
|
||||
./strlit -i emb_Model_data $(MOD_PATH) model.h
|
||||
./strlit -i emb_Tokenizer_data $(TOK_PATH) tokenizer.h
|
||||
clang -Ofast -static -march=native -D STRLIT -D LLOOP run.c -lm -o run
|
||||
|
||||
# Unikraft Unikernel build
|
||||
.PHONY: run_unik_qemu_x86_64
|
||||
run_unik_qemu_x86_64: run.c
|
||||
make -f Makefile.unikernel
|
||||
|
||||
# run all tests
|
||||
.PHONY: test
|
||||
@ -184,3 +189,9 @@ testc:
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f run run.com model.h tokenizer.h strlit run.com.dbg *~
|
||||
make -f Makefile.unikernel clean
|
||||
|
||||
.PHONY: distclean
|
||||
distclean:
|
||||
rm -f run run.com model.h tokenizer.h strlit run.com.dbg *~
|
||||
make -f Makefile.unikernel distclean
|
||||
|
||||
5
Makefile.uk
Normal file
5
Makefile.uk
Normal file
@ -0,0 +1,5 @@
|
||||
$(eval $(call addlib,l2e))
|
||||
L2E_SRCS-y += $(L2E_BASE)/run.c
|
||||
L2E_SRCS-y += $(L2E_BASE)/model.h
|
||||
L2E_SRCS-y += $(L2E_BASE)/tokenizer.h
|
||||
L2E_CFLAGS-y += -DUNIK
|
||||
16
Makefile.unikernel
Normal file
16
Makefile.unikernel
Normal file
@ -0,0 +1,16 @@
|
||||
UK_ROOT ?= $(PWD)/UNIK/unikraft
|
||||
UK_LIBS ?= $(PWD)/UNIK/libs
|
||||
LIBS := $(UK_LIBS)/musl
|
||||
# Model / Tokenizer Paths
|
||||
MOD_PATH = out/model.bin
|
||||
TOK_PATH = tokenizer.bin
|
||||
|
||||
all:
|
||||
cp L2E_amd64_qemu.config .config
|
||||
gcc -Ofast strliteral.c -o strlit
|
||||
./strlit -i emb_Model_data $(MOD_PATH) model.h
|
||||
./strlit -i emb_Tokenizer_data $(TOK_PATH) tokenizer.h
|
||||
@$(MAKE) -C $(UK_ROOT) A=$(PWD) L=$(LIBS)
|
||||
|
||||
$(MAKECMDGOALS):
|
||||
@$(MAKE) -C $(UK_ROOT) A=$(PWD) L=$(LIBS) $(MAKECMDGOALS)
|
||||
Loading…
Reference in New Issue
Block a user