Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
37edd9d
tbb library
Feb 21, 2020
6a04dd9
tbb test
Feb 21, 2020
e939a1d
Merge branch 'master' into i139_intel_tbb_support
Jan 8, 2021
534b8ce
Merge branch 'i164_processor_allocator' into i139_intel_tbb_support
Jan 8, 2021
1f28333
fixes for TBB
Jan 9, 2021
1f6f90a
Merge branch 'i176_process_info_frame' into i139_intel_tbb_support
Jan 9, 2021
a46cacb
worked on ThreadTeam
Jan 28, 2021
f1a8648
remove ThreadTeam dependency in Schedulingcontext
Jan 29, 2021
4a4cd48
fixed warnings
Jan 29, 2021
45a786e
Merge branch 'master' into i193_TBB_resource_management
Jan 29, 2021
0d910eb
Merge branch 'i139_intel_tbb_support' into i193_TBB_resource_management
Jan 29, 2021
9282699
local Portal
Feb 4, 2021
25e5030
worked on ThreadTeam
Feb 7, 2021
ac226d7
worked on ThreadTeam
Feb 9, 2021
b4353b6
Merge branch 'i192_process_thread_group' into i193_TBB_resource_manag…
Feb 9, 2021
2b2f831
threadteam synchronization
Feb 18, 2021
6d9f1e5
ThreadTeam
Feb 18, 2021
dd416b6
trigger pagemap bug
Feb 25, 2021
13611a5
debug output
Feb 25, 2021
9d43fb7
debug output
Feb 26, 2021
418ba45
debug output
Feb 26, 2021
9d9c9d7
rename CapEntry::unlink
Feb 26, 2021
9be6916
capentry unlock debug output
Feb 26, 2021
7da68f2
renames lock to lock_next.
Feb 26, 2021
74f3bcc
PML4 broadcast page fault test
Feb 27, 2021
7e8d78a
fixed PML4 broadcast page fault
Feb 27, 2021
efc4ade
adds lock_cap.
Mar 1, 2021
9b24ea6
searches for leaf locklessy.
Mar 1, 2021
ae1bfc3
fixed overwritten flags.
Mar 1, 2021
9469d8b
fixes lock order.
Mar 1, 2021
0cb2143
adds a bit more documentation.
Mar 1, 2021
ece2d00
Merge branch 'i194_deadlock_in_pagemap' of github.com:ManyThreads/myt…
Mar 1, 2021
fb20cf9
provide original capmap capability to user
Mar 2, 2021
ce705b7
removed move operation of capmap to avaoid cyclic dependencies (proce…
Mar 2, 2021
e2025a8
worked on many things
Mar 2, 2021
7ded780
Merge branch 'i195_capmap_deletion' into i193_TBB_resource_management
Mar 2, 2021
ba316b2
fixed process
Mar 2, 2021
ee6255a
Merge branch 'i194_deadlock_in_pagemap' into i193_TBB_resource_manage…
Mar 2, 2021
21e6d93
updates try_lock code.
Mar 2, 2021
c7c08d7
updates comment.
Mar 2, 2021
bf3a5e2
fixed race in EC
Mar 2, 2021
1d2d49f
reworked process
Mar 2, 2021
327fe1c
PA register teams && free SCs to PA
Mar 2, 2021
19a0523
cleanup init.cc
Mar 2, 2021
52ffd96
removed debug output from capentry
Mar 3, 2021
eed7ecf
fixed EC exit
Mar 3, 2021
c00a303
revoke demand
Mar 3, 2021
03a3124
moved processor allocator
Mar 3, 2021
1641db0
thread team core limitation invocation
Mar 4, 2021
2d3d6fb
fixed musl revoke demand
Mar 5, 2021
245619e
combined test TBB RAPL ThreadTeam
Mar 5, 2021
51b7089
Merge branch 'i194_deadlock_in_pagemap' into i193_TBB_resource_manage…
Mar 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@
path = 3rdparty/ihk
url = https://github.com/ManyThreads/ihk.git
ignore = dirty
[submodule "3rdparty/tbb"]
path = 3rdparty/tbb
url = git@github.com:ManyThreads/tbb.git
22 changes: 22 additions & 0 deletions 3rdparty/install-tbb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
TBBDIR="${SCRIPTDIR}/tbb"
CXXDIR="${SCRIPTDIR}/cxx-amd64"
TBB_BUILD_PREFIX="my_tbb"

MYFLAGS=" -std=c++11 -march=native -Wfatal-errors -g"
MYFLAGS+=" -fno-stack-protector"
MYFLAGS+=" -nostdlib -nostdinc -nostdinc++"
MYFLAGS+=" -isystem ${CXXDIR}/usr/include/c++/v1"
MYFLAGS+=" -isystem ${CXXDIR}/usr/include"

export CXXFLAGS="${MYFLAGS} ${CPLUS_FLAGS}"
export tbb_build_prefix="${TBB_BUILD_PREFIX}"

echo $CPLUS_FLAGS

cd $TBBDIR
make clean default
make extra_inc=big_iron.inc
cd -
1 change: 1 addition & 0 deletions 3rdparty/tbb
Submodule tbb added at efa988
2 changes: 1 addition & 1 deletion Makefile.user
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CPPFLAGS+= -DMLOG_APP=FilterAny
CPPFLAGS+= -DMLOG_APP=FilterInfo
CPPFLAGS+= -DMLOG_ASYNC=FilterError
CPPFLAGS+= -DMLOG_BOOT=FilterError
CPPFLAGS+= -DMLOG_CPU=FilterError
Expand Down
6 changes: 4 additions & 2 deletions kernel-amd64.config
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
"plugin-dump-multiboot",
"plugin-rapl-driver-intel",
"app-init-example",
"test-synchronous-task",
"plugin-processor-allocator"
#"test-synchronous-task",
"objects-thread-team"
]

[config.vars]
mythos_root = ".."
cxx_path = "../3rdparty/cxx-amd64/usr"
tbb_build_path = "../3rdparty/tbb/build/my_tbb_release"
tbb_inc_path = "../3rdparty/tbb/include"
2 changes: 2 additions & 0 deletions kernel-ihk.config
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@
[config.vars]
mythos_root = ".."
cxx_path = "../3rdparty/cxx-amd64/usr"
tbb_build_path = "../3rdparty/tbb/build/my_tbb_release"
tbb_inc_path = "../3rdparty/tbb/include"
2 changes: 2 additions & 0 deletions kernel-knc.config
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@
[config.vars]
mythos_root = ".."
cxx_path = "../3rdparty/cxx-knc/usr"
tbb_build_path = "../3rdparty/tbb/build/my_tbb_release"
tbb_inc_path = "../3rdparty/tbb/include"
151 changes: 123 additions & 28 deletions kernel/app/init-example/app/init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "runtime/Example.hh"
#include "runtime/PageMap.hh"
#include "runtime/KernelMemory.hh"
#include "runtime/ProcessorAllocator.hh"
#include "runtime/ThreadTeam.hh"
#include "runtime/CapAlloc.hh"
#include "runtime/tls.hh"
#include "runtime/mlog.hh"
Expand All @@ -47,6 +47,7 @@
#include "runtime/Mutex.hh"
#include "runtime/cgaScreen.hh"
#include "runtime/process.hh"
#include "tbb/tbb.h"

#include <vector>
#include <array>
Expand All @@ -68,13 +69,14 @@ char initstack[stacksize];
char* initstack_top = initstack+stacksize;

mythos::Portal portal(mythos::init::PORTAL, info_ptr->getInvocationBuf());
mythos::Frame infoFrame(mythos::init::INFO_FRAME);
mythos::CapMap myCS(mythos::init::CSPACE);
mythos::PageMap myAS(mythos::init::PML4);
mythos::KernelMemory kmem(mythos::init::KM);
mythos::KObject device_memory(mythos::init::DEVICE_MEM);
cap_alloc_t capAlloc(myCS);
mythos::RaplDriverIntel rapl(mythos::init::RAPL_DRIVER_INTEL);
mythos::ProcessorAllocator pa(mythos::init::PROCESSOR_ALLOCATOR);
mythos::ThreadTeam team(mythos::init::THREAD_TEAM);

char threadstack[stacksize];
char* thread1stack_top = threadstack+stacksize/2;
Expand Down Expand Up @@ -187,13 +189,13 @@ void test_tls()
auto tls = mythos::setupNewTLS();
MLOG_INFO(mlog::app, "test_EC: create ec1 TLS", DVARhex(tls));
ASSERT(tls != nullptr);
auto sc = pa.alloc(pl).wait();
TEST(sc);
auto res1 = ec1.create(kmem).as(myAS).cs(myCS).sched(sc->cap)
auto res1 = ec1.create(kmem).as(myAS).cs(myCS)
.prepareStack(thread1stack_top).startFun(threadFun, nullptr)
.suspended(false).fs(tls)
.invokeVia(pl).wait();
TEST(res1);
auto res2 = team.tryRunEC(pl, ec1).wait();
TEST(res2);
TEST(ec1.setFSGS(pl,(uint64_t) tls, 0).wait());
mythos::syscall_signal(ec1.cap());
MLOG_INFO(mlog::app, "End test tls");
Expand All @@ -204,7 +206,7 @@ void test_tls()
void test_heap() {
MLOG_INFO(mlog::app, "Test heap");
mythos::PortalLock pl(portal);
auto size = 4*1024*1024; // 2 MB
auto size = 64*1024*1024; // 2 MB
auto align = 2*1024*1024; // 2 MB
uintptr_t vaddr = mythos::round_up(info_ptr->getInfoEnd() + align2M, align2M);
// allocate a 2MiB frame
Expand Down Expand Up @@ -327,24 +329,24 @@ void test_ExecutionContext()

auto tls1 = mythos::setupNewTLS();
ASSERT(tls1 != nullptr);
auto sc1 = pa.alloc(pl).wait();
TEST(sc1);
auto res1 = ec1.create(kmem).as(myAS).cs(myCS).sched(sc1->cap)
auto res1 = ec1.create(kmem).as(myAS).cs(myCS)
.prepareStack(thread1stack_top).startFun(&thread_main, nullptr)
.suspended(false).fs(tls1)
.invokeVia(pl).wait();
TEST(res1);
auto tres1 = team.tryRunEC(pl, ec1).wait();
TEST(tres1);

MLOG_INFO(mlog::app, "test_EC: create ec2");
auto tls2 = mythos::setupNewTLS();
ASSERT(tls2 != nullptr);
auto sc2 = pa.alloc(pl).wait();
TEST(sc2);
auto res2 = ec2.create(kmem).as(myAS).cs(myCS).sched(sc2->cap)
auto res2 = ec2.create(kmem).as(myAS).cs(myCS)/*.sched(sc2->cap)*/
.prepareStack(thread2stack_top).startFun(&thread_main, nullptr)
.suspended(false).fs(tls2)
.invokeVia(pl).wait();
TEST(res2);
auto tres2 = team.tryRunEC(pl, ec2).wait();
TEST(tres2);
}

for (volatile int i=0; i<100000; i++) {
Expand All @@ -371,19 +373,75 @@ void test_InterruptControl() {
mythos::ExecutionContext ec(capAlloc());
auto tls = mythos::setupNewTLS();
ASSERT(tls != nullptr);
auto sc = pa.alloc(pl).wait();
TEST(sc);
auto res1 = ec.create(kmem).as(myAS).cs(myCS).sched(sc->cap)
auto res1 = ec.create(kmem).as(myAS).cs(myCS)
.prepareStack(thread3stack_top).startFun(&thread_main, nullptr)
.suspended(false).fs(tls)
.invokeVia(pl).wait();
TEST(res1);
auto tres = team.tryRunEC(pl, ec).wait();
TEST(tres);
TEST(ic.registerForInterrupt(pl, ec.cap(), 0x32).wait());
TEST(ic.unregisterInterrupt(pl, 0x32).wait());
TEST(capAlloc.free(ec, pl));
MLOG_INFO(mlog::app, "test_InterruptControl end");
}

long SerialFib( long n ) {
return n<2 ? n :SerialFib(n-1)+SerialFib(n-2);
}

class FibTask: public tbb::task {
public:
const long n;
long* const sum;
FibTask( long n_, long* sum_ ) :
n(n_), sum(sum_)
{}
tbb::task* execute() { // Overrides virtual function task::execute
if( n<10 ) {
*sum = SerialFib(n);
} else {
long x, y;
FibTask& a = *new( allocate_child() ) FibTask(n-1,&x);
FibTask& b = *new( allocate_child() ) FibTask(n-2,&y);
// Set ref_count to 'two children plus one for the wait".
set_ref_count(3);
// Start b running.
spawn( b );
// Start a running and wait for all children (a and b).
spawn_and_wait_for_all(a);
// Do the sum
*sum = x+y;
}
return NULL;
}
};

long ParallelFib( long n ) {
long sum;
tbb::task_scheduler_init tsi; // manually initialize TBB scheduler
FibTask& a = *new(tbb::task::allocate_root()) FibTask(n,&sum);
tbb::task::spawn_root_and_wait(a);
tsi.blocking_terminate(); // wait until TBB is terminated
return sum;
}

void test_TBB(){
MLOG_INFO(mlog::app, "Test TBB");

//test thread team limitation
mythos::PortalLock pl(portal);
auto res = team.setLimit(pl, 2).wait();
TEST(res);

tbb::enableDynamicThreading();

long f = 40;
MLOG_INFO(mlog::app, "fib(", f, ") = ", DVAR(ParallelFib(f)));

MLOG_INFO(mlog::app, "Test finished");
}

bool primeTest(uint64_t n){

if(n == 0 | n == 1){
Expand Down Expand Up @@ -496,27 +554,64 @@ void test_CgaScreen(){
MLOG_INFO(mlog::app, "Test CGA finished");
}

void test_processor_allocator(){
MLOG_INFO(mlog::app, "Test processor allocator");
mythos::PortalLock pl(portal);
auto sc = pa.alloc(pl).wait();
TEST(sc);
auto res = pa.free(pl, sc->cap).wait();
TEST(res);
MLOG_INFO(mlog::app, "Test processor allocator finished");
}

void test_process(){
MLOG_INFO(mlog::app, "Test process");

mythos::PortalLock pl(portal);

Process p(&process_test_image_start);
p.createProcess(pl);
p.join(pl);

MLOG_INFO(mlog::app, "Test process finished");
}

void test_scalability(){
MLOG_INFO(mlog::app, "Test runtime/energy scalability");
mythos::PortalLock pl(portal);
timeval start_run, end_run;

tbb::enableDynamicThreading();
long f = 40;

for(unsigned nThreads = 2; nThreads <= info_ptr->getNumThreads(); nThreads++){
auto res = team.setLimit(pl, nThreads).wait();
ASSERT(res);

asm volatile ("":::"memory");
auto start = rapl.getRaplVal(pl).wait().get();
gettimeofday(&start_run, 0);
asm volatile ("":::"memory");

auto result = ParallelFib(f);

asm volatile ("":::"memory");
auto end = rapl.getRaplVal(pl).wait().get();
gettimeofday(&end_run, 0);
asm volatile ("":::"memory");

double seconds =(end_run.tv_usec - start_run.tv_usec)/1000000.0 + end_run.tv_sec - start_run.tv_sec;
double pp0 = (end.pp0 - start.pp0) * pow(0.5, start.cpu_energy_units);
double pp1 = (end.pp1 - start.pp1) * pow(0.5, start.cpu_energy_units);
double psys = (end.psys - start.psys) * pow(0.5, start.cpu_energy_units);
double pkg = (end.pkg - start.pkg) * pow(0.5, start.cpu_energy_units);
double dram = (end.dram - start.dram) * pow(0.5, start.dram_energy_units);

std::cout << "Prime test: fib(" << f << ") = " << result << ", "<< seconds << " seonds, " << nThreads
<< " threads" << std::endl;

std::cout << "Energy consumption (energy/avg. power):"
<< " PP0:" << pp0 << "J/" << pp0/seconds << "W"
<< " PP1:" << pp1 << "J/" << pp1/seconds << "W"
<< " Platform:" << psys << "J/" << psys/seconds << "W"
<< " Package: " << pkg << "J/ " << pkg/seconds << "W"
<< " DRAM:" << dram << "J/" << dram/seconds << "W"
<< std::endl;
}

MLOG_INFO(mlog::app, "Finished scalability test");
}

int main()
{
char const str[] = "Hello world!";
Expand All @@ -533,13 +628,13 @@ int main()
//test_HostChannel(portal, 24*1024*1024, 2*1024*1024);
test_ExecutionContext();
test_pthreads();
test_Rapl();
test_processor_allocator();
//test_Rapl();
//test_TBB();
test_scalability();
test_process();
//test_CgaScreen();

char const end[] = "bye, cruel world!";
mythos::syscall_debug(end, sizeof(end)-1);

return 0;
}
27 changes: 24 additions & 3 deletions kernel/app/process_test/process_test/process_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,18 @@
#include "runtime/Example.hh"
#include "runtime/PageMap.hh"
#include "runtime/KernelMemory.hh"
#include "runtime/ThreadTeam.hh"
#include "runtime/SimpleCapAlloc.hh"
#include "runtime/ProcessorAllocator.hh"
#include "runtime/tls.hh"
#include "runtime/mlog.hh"
#include "runtime/InterruptControl.hh"
#include <cstdint>
#include "util/optional.hh"
#include "util/align.hh"
#include "runtime/umem.hh"
#include "runtime/Mutex.hh"
#include "runtime/thread-extra.hh"
#include "mythos/caps.hh"


mythos::InfoFrame* info_ptr asm("info_ptr");
Expand All @@ -53,20 +56,38 @@ char initstack[stacksize];
char* initstack_top = initstack+stacksize;

mythos::Portal portal(mythos::init::PORTAL, info_ptr->getInvocationBuf());
mythos::Frame infoFrame(mythos::init::INFO_FRAME);
mythos::CapMap myCS(mythos::init::CSPACE);
mythos::PageMap myAS(mythos::init::PML4);
mythos::KernelMemory kmem(mythos::init::KM);
mythos::KObject device_memory(mythos::init::DEVICE_MEM);
mythos::SimpleCapAlloc< mythos::init::APP_CAP_START
, mythos::init::SIZE-mythos::init::APP_CAP_START> capAlloc(myCS);
mythos::RaplDriverIntel rapl(mythos::init::RAPL_DRIVER_INTEL);
mythos::ProcessorAllocator pa(mythos::init::PROCESSOR_ALLOCATOR);
mythos::ThreadTeam team(mythos::init::THREAD_TEAM);


int main()
{
MLOG_ERROR(mlog::app, "New process started :)");
MLOG_ERROR(mlog::app, "New process started :)", DVAR(sizeof(mythos::InfoFrame)), DVAR(mythos_get_pthread_ec_self()));

MLOG_INFO(mlog::app, "info frame", DVARhex(info_ptr), DVAR(info_ptr->getNumThreads()), DVAR(info_ptr->getPsPerTSC()));

mythos::PortalLock pl(portal);
auto size = 32*1024*1024; // 2 MB
auto align = 2*1024*1024; // 2 MB
uintptr_t vaddr = mythos::round_up(info_ptr->getInfoEnd() + mythos::align2M, mythos::align2M);
// allocate a 2MiB frame
mythos::Frame f(capAlloc());
auto res2 = f.create(pl, kmem, size, align).wait();
TEST(res2);
// map the frame into our address space
auto res3 = myAS.mmap(pl, f, vaddr, size, 0x1).wait();
TEST(res3);
MLOG_INFO(mlog::app, "mmap frame", DVAR(res3.state()),
DVARhex(res3->vaddr), DVAR(res3->level));
mythos::heap.addRange(vaddr, size);

MLOG_ERROR(mlog::app, "process finished :(");
return 0;
}
Loading