ealanos: Compilable and runnable version of MxTasking hello world example.

This commit is contained in:
Michael Mueller
2025-05-11 22:06:49 +02:00
parent 284ed952f5
commit 48832c32b5
18 changed files with 297 additions and 126 deletions

View File

@@ -13,9 +13,11 @@ vpath %.h ${INC_DIR}
CUSTOM_CXX = /usr/local/genode/tool/bin/clang++
CUSTOM_CC = /usr/local/genode/tool/bin/clang
CUSTOM_CXX_LIB := $(CROSS_DEV_PREFIX)g++
CUSTOM_LD := $(CROSS_DEV_PREFIX)/g++
CC_OPT += --target=x86_64-genode --sysroot=/does/not/exist --gcc-toolchain=$(GENODE_GCC_TOOLCHAIN_DIR) -DCLANG_CXX11_ATOMICS
CC_OPT += -std=c++20 -pedantic -Wall \
CC_OPT += -std=c++20 -pedantic -femulated-tls -Wall \
-Wno-invalid-offsetof -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization \
-Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Woverloaded-virtual \
-Wredundant-decls -Wshadow -Wsign-promo -Wstrict-overflow=5 -Wswitch-default -Wundef \
@@ -24,5 +26,6 @@ CC_OPT += -std=c++20 -pedantic -Wall \
CC_OPT += $(addprefix -I ,$(INC_DIR))
CC_CXX_WARN_STRICT =
LIBS += base libm libc stdcxx
EXT_OBJECTS += /usr/local/genode/tool/lib/clang/14.0.5/lib/linux/libclang_rt.builtins-x86_64.a /usr/local/genode/tool/lib/libatomic.a

View File

@@ -0,0 +1,60 @@
set build_components {
core init hoitaja timer lib/ld lib/vfs lib/libm lib/libc lib/stdcxx lib/mxtasking app/hello_world
}
build $build_components
create_boot_directory
install_config {
<config prio_levels="32" verbose="true">
<parent-provides>
<service name="LOG"/>
<service name="PD"/>
<service name="CPU"/>
<service name="ROM"/>
<service name="RAM"/>
<service name="IRQ"/>
<service name="IO_MEM"/>
<service name="IO_PORT"/>
<service name="CAP"/>
<service name="RM"/>
<service name="SIGNAL"/>
<service name="TRACE"/>
</parent-provides>
<default-route>
<any-service><parent/><any-child/></any-service>
</default-route>
<default caps="2000"/>
<affinity-space width="64" height="1"/>
<start name="timer">
<resource name="RAM" quantum="3M"/>
<provides><service name="Timer"/></provides>
<route>
<any-service><parent/><any-child/></any-service>
</route>
</start>
<start name="cell1" priority="-1" caps="16000">
<binary name="hello_mxtask"/>
<resource name="RAM" quantum="48G"/>
<config>
<vfs> <dir name="dev">
<log/>
<inline name="rtc">2022-07-20 14:30</inline>
</dir>
</vfs>
<libc stdout="/dev/log" stderr="/dev/log" rtc="/dev/rtc"/>
</config>
</start>
<!--
<start name="cell2" priority="-2">
<binary name="empty_cell"/>
<resource name="RAM" quantum="3M"/>
</start>
-->
</config>
}
build_boot_image [build_artifacts]
append qemu_args " -nographic "
run_genode_until forever

View File

@@ -0,0 +1,59 @@
#include "mx/util/core_set.h"
#include <cstddef>
#include <iostream>
#include <mx/tasking/runtime.h>
#include <libc/component.h>
class HelloWorldTask : public mx::tasking::TaskInterface
{
public:
constexpr HelloWorldTask() = default;
~HelloWorldTask() override = default;
mx::tasking::TaskResult execute(const std::uint16_t core_id) override
{
std::cout << "Hello World" << std::endl;
// Stop MxTasking runtime after this task.
return mx::tasking::TaskResult::make_stop(core_id);
}
};
int mx_main(Libc::Env &env)
{
unsigned num_cores = env.cpu().affinity_space().total();
// Define which cores will be used (1 core here).
const auto cores = mx::util::core_set::build(num_cores, mx::util::core_set::NUMAAware);
{ // Scope for the MxTasking runtime.
std::size_t qouta = env.pd().avail_ram().value;
std::cout << "Remaining memory quota " << qouta << std::endl;
// Create a runtime for the given cores.
mx::tasking::runtime_guard _{env, true,cores};
std::cout << "MxTasking initialized." << std::endl;
// Create an instance of the HelloWorldTask with the current core as first
// parameter. The core is required for memory allocation.
auto *hello_world_task = mx::tasking::runtime::new_task<HelloWorldTask>(cores.front());
std::cout << "task object is at " << static_cast<void*>(hello_world_task) << std::endl;
// Annotate the task to run on the first core.
hello_world_task->annotate(cores.front());
// Schedule the task.
mx::tasking::runtime::spawn(*hello_world_task);
std::cout << "Remaining memory quota " << env.pd().avail_ram().value << std::endl;
std::cout << "Consumed RAM qouta " << (qouta - env.pd().avail_ram().value) << std::endl;
}
return 0;
}
void Libc::Component::construct(Libc::Env &env)
{
Libc::with_libc([&]() {
mx_main(env);
});
}

View File

@@ -0,0 +1,27 @@
TARGET = hello_mxtask
SRC_CC = main.cc
LIBS += base libm libc stdcxx mxtasking
INC_DIR += $(REP_DIR)/src/lib
INC_DIR += $(REP_DIR)/include
INC_DIR += $(REP_DIR)/include/ealanos/util
INC_DIR += $(call select_from_repositories,src/lib/libc)
INC_DIR += $(call select_from_repositories,src/lib/libc)/spec/x86_64
vpath %.h ${INC_DIR}
CC_CXX_WARN_STRICT =
CC_OPT += $(addprefix -I, $(INC_DIR))
CUSTOM_CXX_LIB := $(CROSS_DEV_PREFIX)g++
CUSTOM_CXX = /usr/local/genode/tool/bin/clang++
CUSTOM_CC = /usr/local/genode/tool/bin/clang
GENODE_GCC_TOOLCHAIN_DIR := /usr/local/genode/tool/23.05
LD_OPT += --allow-multiple-definition
CC_OPT += --target=x86_64-genode --sysroot=/does/not/exist --gcc-toolchain=$(GENODE_GCC_TOOLCHAIN_DIR) -DCLANG_CXX11_ATOMICS --rtlib=libgcc -DCLANG_DEFAULT_UNWINDLIB="libunwind" -femulated-tls
CC_OPT += -std=c++20 -pedantic -Wall \
-Wno-invalid-offsetof -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization \
-Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Woverloaded-virtual \
-Wredundant-decls -Wshadow -Wsign-promo -Wstrict-overflow=5 -Wswitch-default -Wundef \
-Wno-unused -Wold-style-cast -Wno-uninitialized -O2 -g
EXT_OBJECTS += /usr/local/genode/tool/lib/libatomic.a /usr/local/genode/tool/23.05/lib/gcc/x86_64-pc-elf/12.3.0/libgcc_eh.a /usr/local/genode/tool/lib/clang/14.0.5/lib/linux/libclang_rt.builtins-x86_64.a

View File

@@ -26,7 +26,7 @@ public:
*/
static constexpr bool local_garbage_collection() { return false; }
static constexpr std::size_t min_block_size() { return 2048; }
static constexpr std::size_t min_block_size() { return 64; }
static constexpr std::size_t superblock_cutoff() { return 1024 * min_block_size();}
};
} // namespace mx::memory

View File

@@ -1,4 +1,5 @@
#include "dynamic_size_allocator.h"
#include "ealanos/memory/hamstraaja.h"
#include "global_heap.h"
#include <algorithm>
#include <cassert>
@@ -6,6 +7,8 @@
using namespace mx::memory::dynamic;
Ealan::Memory::Hamstraaja<mx::memory::config::min_block_size(), mx::memory::config::superblock_cutoff()> *mx::memory::GlobalHeap::_heap;
AllocationBlock::AllocationBlock(const std::uint32_t id, const std::uint8_t numa_node_id, const std::size_t size)
: _id(id), _numa_node_id(numa_node_id), _size(size), _available_size(size)
{

View File

@@ -33,33 +33,6 @@
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/optional \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/utility \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/vector \
/home/mml/genode-igb/repos/ealanos/src/lib/mx/memory/global_heap.h \
/home/mml/genode-igb/repos/ealanos/src/lib/mx/memory/alignment_helper.h \
/home/mml/genode-igb/repos/ealanos/include/ealanos/util/json.hpp \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/algorithm \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/ciso646 \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/cstddef \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/initializer_list \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/iosfwd \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/memory \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/numeric \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/string \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/forward_list \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/map \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/tuple \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/unordered_map \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/valarray \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/exception \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/stdexcept \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/limits \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/cmath \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/cstdio \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/cstring \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/istream \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/clocale \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/cstdlib \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/ios \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/ostream \
/home/mml/genode-igb/repos/ealanos/include/ealanos/memory/hamstraaja.h \
/home/mml/genode-igb/repos/ealanos/include/ealanos/memory/coreheap.h \
/home/mml/genode-igb/repos/ealanos/include/ealanos/memory/superblock.h \
@@ -146,6 +119,33 @@
/home/mml/genode-igb/repos/base/include/base/allocator_avl.h \
/home/mml/genode-igb/repos/base/include/base/tslab.h \
/home/mml/genode-igb/repos/base/include/base/slab.h \
/home/mml/genode-igb/repos/ealanos/src/lib/mx/memory/global_heap.h \
/home/mml/genode-igb/repos/ealanos/src/lib/mx/memory/alignment_helper.h \
/home/mml/genode-igb/repos/ealanos/include/ealanos/util/json.hpp \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/algorithm \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/ciso646 \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/cstddef \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/initializer_list \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/iosfwd \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/memory \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/numeric \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/string \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/forward_list \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/map \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/tuple \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/unordered_map \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/valarray \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/exception \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/stdexcept \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/limits \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/cmath \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/cstdio \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/cstring \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/istream \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/clocale \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/cstdlib \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/ios \
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/ostream \
/home/mml/genode-igb/repos/ealanos/src/lib/mx/system/cpu.h \
/home/mml/genode-igb/repos/ealanos/src/lib/mx/tasking/config.h
@@ -215,60 +215,6 @@
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/vector:
/home/mml/genode-igb/repos/ealanos/src/lib/mx/memory/global_heap.h:
/home/mml/genode-igb/repos/ealanos/src/lib/mx/memory/alignment_helper.h:
/home/mml/genode-igb/repos/ealanos/include/ealanos/util/json.hpp:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/algorithm:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/ciso646:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/cstddef:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/initializer_list:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/iosfwd:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/memory:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/numeric:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/string:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/forward_list:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/map:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/tuple:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/unordered_map:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/valarray:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/exception:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/stdexcept:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/limits:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/cmath:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/cstdio:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/cstring:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/istream:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/clocale:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/cstdlib:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/ios:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/ostream:
/home/mml/genode-igb/repos/ealanos/include/ealanos/memory/hamstraaja.h:
/home/mml/genode-igb/repos/ealanos/include/ealanos/memory/coreheap.h:
@@ -441,6 +387,60 @@
/home/mml/genode-igb/repos/base/include/base/slab.h:
/home/mml/genode-igb/repos/ealanos/src/lib/mx/memory/global_heap.h:
/home/mml/genode-igb/repos/ealanos/src/lib/mx/memory/alignment_helper.h:
/home/mml/genode-igb/repos/ealanos/include/ealanos/util/json.hpp:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/algorithm:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/ciso646:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/cstddef:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/initializer_list:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/iosfwd:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/memory:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/numeric:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/string:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/forward_list:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/map:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/tuple:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/unordered_map:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/valarray:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/exception:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/stdexcept:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/limits:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/cmath:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/cstdio:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/cstring:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/istream:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/clocale:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/c_global/cstdlib:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/ios:
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/ostream:
/home/mml/genode-igb/repos/ealanos/src/lib/mx/system/cpu.h:
/home/mml/genode-igb/repos/ealanos/src/lib/mx/tasking/config.h:

View File

@@ -34,7 +34,8 @@ public:
*/
static void *allocate(const std::uint8_t numa_node_id, const std::size_t size)
{
return _heap->alloc(size, numa_node_id); //numa_alloc_onnode(size, numa_node_id);
void *ptr = _heap->alloc(size, numa_node_id); // numa_alloc_onnode(size, numa_node_id);
return ptr;
}
/**
@@ -57,4 +58,4 @@ public:
*/
static void free(void *memory, const std::size_t size, [[maybe_unused]] const std::uint8_t numa_node_id) { _heap->free(memory); }
};
} // namespace mx::memory
} // namespace mx::memory

View File

@@ -59,7 +59,7 @@ public:
* Frees the given memory using systems free.
* @param address Memory to free.
*/
void free(const std::uint16_t /*worker_id*/, void *address) noexcept override { std::free(address); }
void free(const std::uint16_t /*worker_id*/, void *address) noexcept override { memory::GlobalHeap::free(address, 0, 0); }
[[nodiscard]] std::unordered_map<std::string, std::vector<std::pair<std::uintptr_t, std::uintptr_t>>>
allocated_chunks() override

View File

@@ -16,7 +16,7 @@ class TaskSquad;
* and synchronization of concurrent accesses to the same data
* object, done by tasks.
*/
class annotation
class Annotation
{
public:
enum execution_destination : std::uint8_t
@@ -36,25 +36,25 @@ public:
mixed = 2U
};
constexpr annotation() noexcept = default;
explicit constexpr annotation(const std::uint16_t worker_id) noexcept : _destination(worker_id) {}
explicit constexpr annotation(const execution_destination destination) noexcept : _destination(destination) {}
constexpr annotation(const enum access_intention access_intention, const resource::ptr resource) noexcept
constexpr Annotation() noexcept = default;
explicit constexpr Annotation(const std::uint16_t worker_id) noexcept : _destination(worker_id) {}
explicit constexpr Annotation(const execution_destination destination) noexcept : _destination(destination) {}
constexpr Annotation(const enum access_intention access_intention, const resource::ptr resource) noexcept
: _access_intention(access_intention), _destination(resource)
{
}
constexpr annotation(const enum access_intention access_intention, const resource::ptr resource,
constexpr Annotation(const enum access_intention access_intention, const resource::ptr resource,
const PrefetchDescriptor prefetch_descriptor) noexcept
: _access_intention(access_intention), _destination(resource),
_prefetch_hint(PrefetchHint{prefetch_descriptor, resource})
{
}
constexpr annotation(const annotation &) noexcept = default;
constexpr annotation(annotation &&) noexcept = default;
~annotation() = default;
constexpr Annotation(const Annotation &) noexcept = default;
constexpr Annotation(Annotation &&) noexcept = default;
~Annotation() = default;
annotation &operator=(const annotation &) noexcept = default;
annotation &operator=(annotation &&) noexcept = default;
Annotation &operator=(const Annotation &) noexcept = default;
Annotation &operator=(Annotation &&) noexcept = default;
[[nodiscard]] bool is_readonly() const noexcept { return _access_intention == access_intention::readonly; }
[[nodiscard]] priority priority() const noexcept { return _priority; }
@@ -94,7 +94,7 @@ public:
void set(const PrefetchHint prefetch_hint) noexcept { _prefetch_hint = prefetch_hint; }
void cycles(const std::uint16_t cycles) noexcept { _cycles = cycles; }
bool operator==(const annotation &other) const noexcept
bool operator==(const Annotation &other) const noexcept
{
return _access_intention == other._access_intention && _priority == other._priority &&
_destination == other._destination && _prefetch_hint == other._prefetch_hint;

View File

@@ -94,7 +94,7 @@ public:
{
}
~TaskCounter() noexcept { delete[] this->_counter; }
~TaskCounter() noexcept { mx::memory::GlobalHeap::free(this->_counter,0,0); }
TaskCounter &operator=(const TaskCounter &) = delete;

View File

@@ -66,8 +66,9 @@ public:
if (_resource_allocator == nullptr)
{
/// Only called the first time.
_resource_allocator.reset(new (memory::GlobalHeap::allocate_cache_line_aligned(
sizeof(memory::dynamic::local::Allocator))) memory::dynamic::local::Allocator(core_set));
_resource_allocator.reset(new (memory::GlobalHeap::allocate_cache_line_aligned(sizeof(
memory::dynamic::local::Allocator))) memory::dynamic::local::Allocator(core_set));
util::Logger::info_if(system::Environment::is_debug(), "Created resource allocator");
}
else if (_resource_allocator->is_free())
{
@@ -86,8 +87,10 @@ public:
// Create a new task allocator.
if (use_system_allocator)
{
_task_allocator.reset(new (memory::GlobalHeap::allocate_cache_line_aligned(sizeof(
memory::SystemTaskAllocator<config::task_size()>))) memory::SystemTaskAllocator<config::task_size()>());
_task_allocator.reset(new (memory::GlobalHeap::allocate_cache_line_aligned(
sizeof(memory::SystemTaskAllocator<config::task_size()>)))
memory::SystemTaskAllocator<config::task_size()>());
util::Logger::info_if(system::Environment::is_debug(), "Created task allocator");
}
else
{
@@ -100,8 +103,9 @@ public:
const auto need_new_scheduler = _scheduler == nullptr || *_scheduler != core_set;
if (need_new_scheduler)
{
_scheduler.reset(new (memory::GlobalHeap::allocate_cache_line_aligned(sizeof(Scheduler)))
Scheduler(core_set, prefetch_distance, *_resource_allocator));
_scheduler.reset(new (memory::GlobalHeap::allocate_cache_line_aligned(
sizeof(Scheduler))) Scheduler(core_set, prefetch_distance, *_resource_allocator));
util::Logger::info_if(system::Environment::is_debug(), "Created new task scheduler and worker thread pool");
}
else
{
@@ -113,6 +117,7 @@ public:
{
_resource_builder = std::make_unique<mx::resource::Builder>(*_scheduler, *_resource_allocator);
}
util::Logger::info_if(system::Environment::is_debug(), "Started MxTasking in DEBUG mode.");
return true;
}
@@ -155,7 +160,7 @@ public:
*/
static std::uint16_t spawn(const mx::resource::ptr squad, const std::uint16_t local_worker_id) noexcept
{
return spawn(squad, annotation::resource_boundness::mixed, local_worker_id);
return spawn(squad, Annotation::resource_boundness::mixed, local_worker_id);
}
/**
@@ -165,7 +170,7 @@ public:
* @param boundness Boundness of the squad.
* @param local_worker_id Worker, the spawn request came from.
*/
static std::uint16_t spawn(const mx::resource::ptr squad, const enum annotation::resource_boundness boundness,
static std::uint16_t spawn(const mx::resource::ptr squad, const enum Annotation::resource_boundness boundness,
const std::uint16_t local_worker_id) noexcept
{
return _scheduler->dispatch(squad, boundness, local_worker_id);

View File

@@ -1,11 +1,16 @@
#include "scheduler.h"
#include "mx/system/environment.h"
#include "mx/util/logger.h"
#include "runtime.h"
#include <mx/memory/global_heap.h>
#include <mx/synchronization/synchronization.h>
#include <mx/system/cpu.h>
#include <mx/system/thread.h>
#include <string>
#include <thread>
#include <vector>
#include <iostream>
using namespace mx::tasking;
@@ -26,7 +31,9 @@ Scheduler::Scheduler(const mx::util::core_set &core_set, const PrefetchDistance
this->_task_tracer.emplace(profiling::TaskTracer{this->_core_set.count_cores()});
}
/// Create worker.
/// Create worker.
std::cout << "Creating workers for coreset " << this->_core_set << std::endl;
for (auto worker_id = std::uint16_t(0U); worker_id < this->_core_set.count_cores(); ++worker_id)
{
/// The core the worker is binded to.
@@ -36,10 +43,15 @@ Scheduler::Scheduler(const mx::util::core_set &core_set, const PrefetchDistance
const auto numa_node_id = system::cpu::node_id(core_id);
this->_worker_numa_node_map[worker_id] = numa_node_id;
this->_worker[worker_id] = new (memory::GlobalHeap::allocate(numa_node_id, sizeof(Worker)))
Worker(this->_core_set.count_cores(), worker_id, core_id, this->_is_running, prefetch_distance,
this->_epoch_manager[worker_id], this->_epoch_manager.global_epoch(), this->_task_counter,
this->_task_tracer);
this->_worker[worker_id] = static_cast<Worker*>(memory::GlobalHeap::allocate(numa_node_id, sizeof(Worker)));
std::cout << "Creating worker " << worker_id << " at " << this->_worker[worker_id];
new (static_cast<void *>(this->_worker[worker_id]))
Worker(this->_core_set.count_cores(), worker_id, core_id, this->_is_running,
prefetch_distance, this->_epoch_manager[worker_id],
this->_epoch_manager.global_epoch(), this->_task_counter, this->_task_tracer);
util::Logger::info_if(system::Environment::is_debug(), "Created worker threads");
}
}
@@ -62,6 +74,7 @@ void Scheduler::start_and_wait()
auto *worker = this->_worker[worker_id];
worker_threads[worker_id] = std::thread([worker] { worker->execute(); });
util::Logger::info_if(system::Environment::is_debug(), "Created worker thread " + std::to_string(worker_id) + " of size " + std::to_string(sizeof(std::thread)));
//system::thread::pin(worker_threads[worker_id], worker->core_id());
//system::thread::name(worker_threads[worker_id], "mx::worker#" + std::to_string(worker_id));
}
@@ -262,7 +275,7 @@ std::uint16_t Scheduler::dispatch(TaskInterface &first, TaskInterface &last, con
return local_worker_id;
}
std::uint16_t Scheduler::dispatch(const mx::resource::ptr squad, const enum annotation::resource_boundness boundness,
std::uint16_t Scheduler::dispatch(const mx::resource::ptr squad, const enum Annotation::resource_boundness boundness,
const std::uint16_t local_worker_id) noexcept
{
auto *dispatch_task = runtime::new_task<TaskSquadSpawnTask>(local_worker_id, *squad.get<TaskSquad>());

View File

@@ -203,6 +203,7 @@
/home/mml/genode-igb/contrib/stdcxx-4eddc2a55a80ed5d3a50fee3f5c25e7ac42afd72/include/stdcxx/std/set \
/home/mml/genode-igb/repos/ealanos/src/lib/mx/util/maybe_atomic.h \
/home/mml/genode-igb/repos/ealanos/src/lib/mx/tasking/profiling/idle_profiler.h \
/home/mml/genode-igb/repos/ealanos/src/lib/mx/util/logger.h \
/home/mml/genode-igb/repos/ealanos/src/lib/mx/tasking/runtime.h \
/home/mml/genode-igb/repos/ealanos/src/lib/mx/io/network/server.h \
/home/mml/genode-igb/repos/ealanos/src/lib/mx/io/network/config.h \
@@ -211,7 +212,6 @@
/home/mml/genode-igb/repos/ealanos/src/lib/mx/resource/builder.h \
/home/mml/genode-igb/repos/ealanos/src/lib/mx/system/thread.h \
/home/mml/genode-igb/contrib/libc-ec685e91ee80735b4a067fea4582aa7f5d06c192/include/libc/pthread.h \
/home/mml/genode-igb/repos/ealanos/src/lib/mx/util/logger.h \
/home/mml/genode-igb/repos/libports/include/libc/component.h
/home/mml/genode-igb/repos/ealanos/src/lib/mx/tasking/scheduler.h:
@@ -620,6 +620,8 @@
/home/mml/genode-igb/repos/ealanos/src/lib/mx/tasking/profiling/idle_profiler.h:
/home/mml/genode-igb/repos/ealanos/src/lib/mx/util/logger.h:
/home/mml/genode-igb/repos/ealanos/src/lib/mx/tasking/runtime.h:
/home/mml/genode-igb/repos/ealanos/src/lib/mx/io/network/server.h:
@@ -636,6 +638,4 @@
/home/mml/genode-igb/contrib/libc-ec685e91ee80735b4a067fea4582aa7f5d06c192/include/libc/pthread.h:
/home/mml/genode-igb/repos/ealanos/src/lib/mx/util/logger.h:
/home/mml/genode-igb/repos/libports/include/libc/component.h:

View File

@@ -60,7 +60,7 @@ public:
* @param local_worker_id Channel, the request came from.
* @return Worker ID where the task was dispatched to.
*/
std::uint16_t dispatch(mx::resource::ptr squad, enum annotation::resource_boundness boundness,
std::uint16_t dispatch(mx::resource::ptr squad, enum Annotation::resource_boundness boundness,
std::uint16_t local_worker_id) noexcept;
/**
@@ -213,12 +213,12 @@ private:
PhysicalCoreResourceWorkerIds &operator=(const PhysicalCoreResourceWorkerIds &) noexcept = default;
PhysicalCoreResourceWorkerIds &operator=(PhysicalCoreResourceWorkerIds &&) noexcept = default;
[[nodiscard]] std::uint16_t operator[](const enum annotation::resource_boundness boundness) const noexcept
[[nodiscard]] std::uint16_t operator[](const enum Annotation::resource_boundness boundness) const noexcept
{
return _worker_ids[boundness];
}
[[nodiscard]] std::uint16_t &operator[](const enum annotation::resource_boundness boundness) noexcept
[[nodiscard]] std::uint16_t &operator[](const enum Annotation::resource_boundness boundness) noexcept
{
return _worker_ids[boundness];
}

View File

@@ -147,12 +147,12 @@ public:
/**
* @return The annotation of the task.
*/
[[nodiscard]] const annotation &annotation() const noexcept { return _annotation; }
[[nodiscard]] const Annotation &annotation() const noexcept { return _annotation; }
/**
* @return The annotation of the task.
*/
[[nodiscard]] class annotation &annotation() noexcept { return _annotation; }
[[nodiscard]] class Annotation &annotation() noexcept { return _annotation; }
/**
* Annotate the task with a resource the task will work on.
@@ -234,7 +234,7 @@ public:
*
* @param execution_destination Destination to execute on.
*/
void annotate(const annotation::execution_destination execution_destination) noexcept
void annotate(const Annotation::execution_destination execution_destination) noexcept
{
_annotation.set(execution_destination);
}
@@ -244,7 +244,7 @@ public:
*
* @param is_readonly True, when the task is read only (false by default).
*/
void annotate(const annotation::access_intention access_intention) noexcept { _annotation.set(access_intention); }
void annotate(const Annotation::access_intention access_intention) noexcept { _annotation.set(access_intention); }
/**
* @return Pointer to the next task in spawn queue.
@@ -262,7 +262,7 @@ private:
TaskInterface *_next{nullptr};
/// Tasks annotations.
class annotation _annotation
class Annotation _annotation
{
};
};

View File

@@ -33,7 +33,7 @@ TaskResult TaskSquadSpawnTask::execute(std::uint16_t worker_id)
}
else
{
first->annotate(annotation::execution_destination::local);
first->annotate(Annotation::execution_destination::local);
runtime::spawn(*first, worker_id);
}
}

View File

@@ -34,7 +34,7 @@ void Worker::execute()
system::builtin::pause();
}
assert(this->_target_core_id == system::cpu::core_id() && "Worker not pinned to correct core.");
//assert(this->_target_core_id == system::cpu::core_id() && "Worker not pinned to correct core.");
const auto worker_id = this->_id;
/// Period the task sampler for monitoring task cycles becomes active.