Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 -
2 changes: 1 addition & 1 deletion 3rdparty/musl
1 change: 1 addition & 0 deletions 3rdparty/tbb
Submodule tbb added at dda6d3
1 change: 1 addition & 0 deletions Makefile.user
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CPPFLAGS+= -DMLOG_PORTAL=FilterError
CPPFLAGS+= -DMLOG_SCHED=FilterError
CPPFLAGS+= -DMLOG_SYSCALL=FilterError
CPPFLAGS+= -DMLOG_TASKLET=FilterError
CPPFLAGS+= -DMLOG_PROCESSORMGMT=FilterWarning
#CPPFLAGS+= -DTRACE
#CPPFLAGS+= -DNDEBUG

Expand Down
3 changes: 3 additions & 0 deletions kernel-amd64.config
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
"plugin-rapl-driver-intel",
"app-init-example",
"test-synchronous-task",
"plugin-processor-allocator"
]

[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"
82 changes: 67 additions & 15 deletions kernel/app/init-example/app/init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@
#include "mythos/invocation.hh"
#include "mythos/protocol/CpuDriverKNC.hh"
#include "mythos/PciMsgQueueMPSC.hh"
#include "mythos/InfoFrame.hh"
#include "runtime/Portal.hh"
#include "runtime/ExecutionContext.hh"
#include "runtime/CapMap.hh"
#include "runtime/RaplDriverIntel.hh"
#include "runtime/Example.hh"
#include "runtime/PageMap.hh"
#include "runtime/KernelMemory.hh"
#include "runtime/SimpleCapAlloc.hh"
#include "runtime/CapAlloc.hh"
#include "runtime/ProcessorAllocator.hh"
#include "runtime/tls.hh"
#include "runtime/mlog.hh"
#include "runtime/InterruptControl.hh"
Expand All @@ -45,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 @@ -56,7 +59,7 @@
#include <sys/time.h>


mythos::InvocationBuf* msg_ptr asm("msg_ptr");
mythos::InfoFrame* info_ptr asm("info_ptr");
int main() asm("main");

extern char process_test_image_start SYMBOL("process_test_image_start");
Expand All @@ -65,14 +68,14 @@ constexpr uint64_t stacksize = 4*4096;
char initstack[stacksize];
char* initstack_top = initstack+stacksize;

mythos::Portal portal(mythos::init::PORTAL, msg_ptr);
mythos::Portal portal(mythos::init::PORTAL, info_ptr->getInvocationBuf());
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);
cap_alloc_t capAlloc(myCS);
mythos::RaplDriverIntel rapl(mythos::init::RAPL_DRIVER_INTEL);
mythos::ProcessorAllocator pa(mythos::init::PROCESSOR_ALLOCATOR);

char threadstack[stacksize];
char* thread1stack_top = threadstack+stacksize/2;
Expand Down Expand Up @@ -103,7 +106,7 @@ void test_Portal()
MLOG_ERROR(mlog::app, "test_Portal begin");
mythos::PortalLock pl(portal); // future access will fail if the portal is in use already
MLOG_INFO(mlog::app, "test_Portal: allocate portal");
uintptr_t vaddr = mythos::round_up(uintptr_t(msg_ptr) + 1, mythos::align2M);
uintptr_t vaddr = mythos::round_up(info_ptr->getInfoEnd(), mythos::align2M);
// allocate a portal
mythos::Portal p2(capAlloc(), (void*)vaddr);
auto res1 = p2.create(pl, kmem).wait();
Expand Down Expand Up @@ -185,23 +188,26 @@ void test_tls()
auto tls = mythos::setupNewTLS();
MLOG_INFO(mlog::app, "test_EC: create ec1 TLS", DVARhex(tls));
ASSERT(tls != nullptr);
auto res1 = ec1.create(kmem).as(myAS).cs(myCS).sched(mythos::init::SCHEDULERS_START + 1)
auto sc = pa.alloc(pl).wait();
TEST(sc);
auto res1 = ec1.create(kmem).as(myAS).cs(myCS).sched(sc->cap)
.prepareStack(thread1stack_top).startFun(threadFun, nullptr)
.suspended(false).fs(tls)
.invokeVia(pl).wait();
TEST(res1);
TEST(ec1.setFSGS(pl,(uint64_t) tls, 0).wait());
mythos::syscall_signal(ec1.cap());
MLOG_INFO(mlog::app, "End test tls");
capAlloc.free(ec1.cap(), pl);
}


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(uintptr_t(msg_ptr) + 1, align);
uintptr_t vaddr = mythos::round_up(info_ptr->getInfoEnd() + align2M, align2M);
// allocate a 2MiB frame
mythos::Frame f(capAlloc());
auto res2 = f.create(pl, kmem, size, align).wait();
Expand Down Expand Up @@ -322,7 +328,9 @@ void test_ExecutionContext()

auto tls1 = mythos::setupNewTLS();
ASSERT(tls1 != nullptr);
auto res1 = ec1.create(kmem).as(myAS).cs(myCS).sched(mythos::init::SCHEDULERS_START)
auto sc1 = pa.alloc(pl).wait();
TEST(sc1);
auto res1 = ec1.create(kmem).as(myAS).cs(myCS).sched(sc1->cap)
.prepareStack(thread1stack_top).startFun(&thread_main, nullptr)
.suspended(false).fs(tls1)
.invokeVia(pl).wait();
Expand All @@ -331,7 +339,9 @@ void test_ExecutionContext()
MLOG_INFO(mlog::app, "test_EC: create ec2");
auto tls2 = mythos::setupNewTLS();
ASSERT(tls2 != nullptr);
auto res2 = ec2.create(kmem).as(myAS).cs(myCS).sched(mythos::init::SCHEDULERS_START+1)
auto sc2 = pa.alloc(pl).wait();
TEST(sc2);
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();
Expand All @@ -345,6 +355,11 @@ void test_ExecutionContext()
MLOG_INFO(mlog::app, "sending notifications");
mythos::syscall_signal(ec1.cap());
mythos::syscall_signal(ec2.cap());
{
mythos::PortalLock pl(portal);
TEST(capAlloc.free(ec1, pl));
TEST(capAlloc.free(ec2, pl));
}
MLOG_INFO(mlog::app, "End Test ExecutionContext");
}

Expand All @@ -357,7 +372,9 @@ void test_InterruptControl() {
mythos::ExecutionContext ec(capAlloc());
auto tls = mythos::setupNewTLS();
ASSERT(tls != nullptr);
auto res1 = ec.create(kmem).as(myAS).cs(myCS).sched(mythos::init::SCHEDULERS_START + 2)
auto sc = pa.alloc(pl).wait();
TEST(sc);
auto res1 = ec.create(kmem).as(myAS).cs(myCS).sched(sc->cap)
.prepareStack(thread3stack_top).startFun(&thread_main, nullptr)
.suspended(false).fs(tls)
.invokeVia(pl).wait();
Expand All @@ -368,6 +385,28 @@ void test_InterruptControl() {
MLOG_INFO(mlog::app, "test_InterruptControl end");
}

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

class say_hello
{
int id;
public:
say_hello(int i) : id(i) { }
void operator( ) ( ) const
{
printf("hello from task %d\n",id);
}
};

tbb::task_group tg;
for(int i=0; i<10; i++){
tg.run(say_hello(i)); // spawn 1st task and return
}
tg.wait( ); // wait for tasks to complete
MLOG_INFO(mlog::app, "Test finished");
}

bool primeTest(uint64_t n){

if(n == 0 | n == 1){
Expand Down Expand Up @@ -480,10 +519,21 @@ 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);

Expand All @@ -494,9 +544,9 @@ int main()
{
char const str[] = "Hello world!";
mythos::syscall_debug(str, sizeof(str)-1);
MLOG_ERROR(mlog::app, "application is starting :)", DVARhex(msg_ptr), DVARhex(initstack_top));
MLOG_ERROR(mlog::app, "application is starting :)", DVARhex(info_ptr), DVARhex(initstack_top));

test_float();
//test_float();
test_Example();
test_Portal();
test_heap(); // heap must be initialized for tls test
Expand All @@ -506,7 +556,9 @@ int main()
//test_HostChannel(portal, 24*1024*1024, 2*1024*1024);
test_ExecutionContext();
test_pthreads();
//test_Rapl();
test_Rapl();
test_processor_allocator();
test_TBB();
test_process();
//test_CgaScreen();

Expand Down
8 changes: 6 additions & 2 deletions kernel/app/process_test/process_test/process_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "mythos/init.hh"
#include "mythos/invocation.hh"
#include "mythos/InfoFrame.hh"
#include "runtime/Portal.hh"
#include "runtime/ExecutionContext.hh"
#include "runtime/CapMap.hh"
Expand All @@ -34,6 +35,7 @@
#include "runtime/PageMap.hh"
#include "runtime/KernelMemory.hh"
#include "runtime/SimpleCapAlloc.hh"
#include "runtime/ProcessorAllocator.hh"
#include "runtime/tls.hh"
#include "runtime/mlog.hh"
#include "runtime/InterruptControl.hh"
Expand All @@ -43,26 +45,28 @@
#include "runtime/Mutex.hh"


mythos::InvocationBuf* msg_ptr asm("msg_ptr");
mythos::InfoFrame* info_ptr asm("info_ptr");
int main() asm("main");

constexpr uint64_t stacksize = 4*4096;
char initstack[stacksize];
char* initstack_top = initstack+stacksize;

mythos::Portal portal(mythos::init::PORTAL, msg_ptr);
mythos::Portal portal(mythos::init::PORTAL, info_ptr->getInvocationBuf());
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);


int main()
{
MLOG_ERROR(mlog::app, "New process started :)");
MLOG_INFO(mlog::app, "info frame", DVARhex(info_ptr), DVAR(info_ptr->getNumThreads()), DVAR(info_ptr->getPsPerTSC()));

return 0;
}
2 changes: 2 additions & 0 deletions kernel/async/monitor-common/async/Place.hh
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ public:
/** true if the hardware thread is currently in kernel mode and processing tasks. */
bool isActive() const { return nestingMonitor.load(std::memory_order_relaxed); }

cpu::ThreadID getThreadID(){ return threadID; }

protected:
void pushPrivate(TaskletBase* msg) {
ASSERT(isLocal());
Expand Down
Loading