1
0
Fork 0
mirror of https://github.com/hermitcore/libhermit.git synced 2025-03-09 00:00:03 +01:00

enable iRCCE support

This commit is contained in:
Stefan Lankes 2016-01-26 14:30:00 +01:00
parent 3ad5981511
commit 871ce8cc0d
10 changed files with 92 additions and 124 deletions

View file

@ -84,6 +84,9 @@ int sys_sem_cancelablewait(sem_t* sem, unsigned int ms);
int sys_clone(tid_t* id, void* ep, void* argv);
off_t sys_lseek(int fd, off_t offset, int whence);
size_t sys_get_ticks(void);
int sys_rcce_init(int session_id);
size_t sys_rcce_malloc(int session_id, int ue);
int sys_rcce_fini(int session_id);
#define __NR_exit 0
#define __NR_write 1

View file

@ -226,7 +226,6 @@ int smp_main(void)
}
#endif
#if 0
static int init_rcce(void)
{
size_t addr;
@ -242,9 +241,10 @@ static int init_rcce(void)
rcce_lock = (islelock_t*) addr;
rcce_mpb = (rcce_mpb_t*) (addr + CACHE_LINE*(RCCE_MAXNP+1));
kprintf("Map rcce_lock at %p and rcce_mpb at %p\n", rcce_lock, rcce_mpb);
return 0;
}
#endif
int libc_start(int argc, char** argv, char** env);
@ -284,7 +284,7 @@ static int initd(void* arg)
init_netifs();
// initialize iRCCE
//init_rcce();
init_rcce();
s = lwip_socket(PF_INET , SOCK_STREAM , 0);
if (s < 0) {

View file

@ -434,7 +434,7 @@ off_t sys_lseek(int fd, off_t offset, int whence)
return off;
}
static int sys_rcce_init(int session_id)
int sys_rcce_init(int session_id)
{
int i, err = 0;
size_t paddr = 0;
@ -485,7 +485,7 @@ out:
return err;
}
static size_t sys_rcce_malloc(int session_id, int ue)
size_t sys_rcce_malloc(int session_id, int ue)
{
size_t vaddr = 0;
int i, counter = 0;
@ -532,7 +532,7 @@ out:
return 0;
}
static int sys_rcce_fini(int session_id)
int sys_rcce_fini(int session_id)
{
int i, j;
int ret = 0;
@ -582,6 +582,7 @@ int sys_stat(const char* file, /*struct stat *st*/ void* st)
return -ENOSYS;
}
#if 0
int fork(void)
{
return -ENOSYS;
@ -628,6 +629,7 @@ int gethostname(char *name, size_t len)
return 0;
}
#endif
static int default_handler(void)
{

View file

@ -27,6 +27,7 @@
#include <sys/shm.h>
#if 0
int shmget(key_t key, size_t size, int shmflg)
{
return 0;
@ -46,3 +47,4 @@ int shmctl(int shmid, int cmd, struct shmid_ds *buf)
{
return 0;
}
#endif

View file

@ -45,7 +45,7 @@ $(TMP)/bootstrap:
$Q$(MKDIR) $(TMP)/bootstrap
$Q$(CD) $(TMP)/bootstrap; $(TOPDIR)/gcc/configure --target=$(TARGET) --prefix=$(TOPDIR)/$(ARCH) --without-headers --enable-languages=c --disable-nls --disable-shared --disable-libssp --disable-libgomp --enable-threads=posix --enable-tls && $(MAKE) $(NJOBS) all-gcc && $(MAKE) install-gcc
toolchain: $(TMP)/newlib libs $(TMP)/gcc headers $(TMP)/mpich_hermit $(TMP)/mpich demo
toolchain: $(TMP)/newlib libs $(TMP)/gcc headers demo
$(TMP)/newlib:
@echo Build newlib, libpthread and libgomp

View file

@ -48,7 +48,7 @@ endif
default: all
all: stream.bin hg.bin netio.bin #RCCE_pingping RCCE_pingpong
all: stream.bin hg.bin netio.bin RCCE_pingping.bin RCCE_pingpong.bin
stream.o: stream.c
@echo [CC] $@

View file

@ -256,7 +256,7 @@ int RC_COMM_BUFFER_SIZE() {
t_vcharp RC_COMM_BUFFER_START(int ue){
#ifdef __hermit__
t_vcharp retval;
retval = (t_vcharp) SYSCALL2(__NR_rcce_malloc, RCCE_SESSION_ID, ue);
retval = (t_vcharp) sys_rcce_malloc(RCCE_SESSION_ID, ue);
if (!retval) {
fprintf(stderr, "rcce_malloc failed\n");
RCCE_finalize();
@ -869,7 +869,7 @@ int RCCE_init(
int verbose_level = 0;
#ifdef __hermit__
SYSCALL1(__NR_rcce_init, RCCE_SESSION_ID /* id of the session */);
sys_rcce_init(RCCE_SESSION_ID /* id of the session */);
#elif defined(SCC)
// Copperridge specific initialization...
InitAPI(0);fflush(0);
@ -1206,7 +1206,7 @@ int RCCE_finalize(void){
FreeConfigReg((int *)(virtual_lockaddress[ue]));
}
#else
SYSCALL1(__NR_rcce_fini, RCCE_SESSION_ID /* id of the session */);
sys_rcce_fini(RCCE_SESSION_ID /* id of the session */);
#endif
fflush(NULL);
#endif

View file

@ -25,13 +25,69 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @author Stefan Lankes
* @file include/hermit/syscall.h
* @brief System call number definitions
*
* This file contains define constants for every syscall's number.
*/
#ifndef __SYSCALL_H__
#define __SYSCALL_H__
#ifdef __KERNEL__
#include <hermit/stddef.h>
#else
#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>
#ifndef NORETURN
#define NORETURN __attribute__((noreturn))
#endif
typedef unsigned int tid_t;
#endif
#ifdef __cplusplus
extern "C" {
#endif
struct sem;
typedef struct sem sem_t;
/*
* HermitCore is a libOS.
* => classical system calls are realized as normal function
* => forward declaration of system calls as function
*/
tid_t sys_getpid(void);
int sys_fork(void);
int sys_wait(int* status);
int sys_execve(const char* name, char * const * argv, char * const * env);
int sys_getprio(tid_t* id);
int sys_setprio(tid_t* id, int prio);
void NORETURN sys_exit(int arg);
ssize_t sys_read(int fd, char* buf, size_t len);
ssize_t sys_write(int fd, const char* buf, size_t len);
ssize_t sys_sbrk(int incr);
int sys_open(const char* name, int flags, int mode);
int sys_close(int fd);
void sys_msleep(unsigned int ms);
int sys_sem_init(sem_t** sem, unsigned int value);
int sys_sem_destroy(sem_t* sem);
int sys_sem_wait(sem_t* sem);
int sys_sem_post(sem_t* sem);
int sys_sem_timedwait(sem_t *sem, unsigned int ms);
int sys_sem_cancelablewait(sem_t* sem, unsigned int ms);
int sys_clone(tid_t* id, void* ep, void* argv);
off_t sys_lseek(int fd, off_t offset, int whence);
size_t sys_get_ticks(void);
int sys_rcce_init(int session_id);
size_t sys_rcce_malloc(int session_id, int ue);
int sys_rcce_fini(int session_id);
#define __NR_exit 0
#define __NR_write 1
#define __NR_open 2
@ -47,39 +103,23 @@ extern "C" {
#define __NR_wait 12
#define __NR_execve 13
#define __NR_times 14
#define __NR_accept 15
#define __NR_bind 16
#define __NR_closesocket 17
#define __NR_connect 18
#define __NR_listen 19
#define __NR_recv 20
#define __NR_send 21
#define __NR_socket 22
#define __NR_getsockopt 23
#define __NR_setsockopt 24
#define __NR_gethostbyname 25
#define __NR_sendto 26
#define __NR_recvfrom 27
#define __NR_select 28
#define __NR_stat 29
#define __NR_dup 30
#define __NR_dup2 31
#define __NR_msleep 32
#define __NR_yield 33
#define __NR_sem_init 34
#define __NR_sem_destroy 35
#define __NR_sem_wait 36
#define __NR_sem_post 37
#define __NR_sem_timedwait 38
#define __NR_getprio 39
#define __NR_setprio 40
#define __NR_clone 41
#define __NR_sem_cancelablewait 42
#define __NR_get_ticks 43
#define __NR_rcce_init 44
#define __NR_rcce_fini 45
#define __NR_rcce_malloc 46
#define __NR_stat 15
#define __NR_dup 16
#define __NR_dup2 17
#define __NR_msleep 18
#define __NR_yield 19
#define __NR_sem_init 20
#define __NR_sem_destroy 21
#define __NR_sem_wait 22
#define __NR_sem_post 23
#define __NR_sem_timedwait 24
#define __NR_getprio 25
#define __NR_setprio 26
#define __NR_clone 27
#define __NR_sem_cancelablewait 28
#define __NR_get_ticks 29
#ifndef __KERNEL__
inline static long
syscall(int nr, unsigned long arg0, unsigned long arg1, unsigned long arg2)
{
@ -102,6 +142,7 @@ syscall(int nr, unsigned long arg0, unsigned long arg1, unsigned long arg2)
syscall(NR, (unsigned long)ARG0, (unsigned long)ARG1, 0)
#define SYSCALL3(NR, ARG0, ARG1, ARG2) \
syscall(NR, (unsigned long)ARG0, (unsigned long)ARG1, (unsigned long)ARG2)
#endif // __KERNEL__
#ifdef __cplusplus
}

View file

@ -48,7 +48,7 @@ endif
default: all
all: hello.bin hello++.bin thr_hello.bin jacobi.bin hellof.bin cpi.bin #RCCE_minimum
all: hello.bin hello++.bin thr_hello.bin jacobi.bin hellof.bin RCCE_minimum.bin
hello++: hello++.o
@echo [LD] $@
@ -89,17 +89,6 @@ thr_hello: thr_hello.o
$Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@
$Qchmod a-x $@.sym
cpi.o: cpi.c
@echo [CC] $@
$Q$(CC_FOR_TARGET) -c $(CFLAGS_FOR_TARGET) -pthread -o $@ $<
cpi: cpi.o
@echo [LD] $@
$Q$(CC_FOR_TARGET) $(LDFLAGS_FOR_TARGET) $(CFLAGS_FOR_TARGET) -o $@ $< -pthread -lmpi
$Q$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym
$Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@
$Qchmod a-x $@.sym
RCCE_minimum: RCCE_minimum.o
@echo [LD] $@
$Q$(CC_FOR_TARGET) $(LDFLAGS_FOR_TARGET) $(CFLAGS_FOR_TARGET) -o $@ $< -lircce

View file

@ -1,69 +0,0 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/*
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
/*
* We take this example form the orginoal MPICH distributions
* => see COPYRIGHT statement in hermit/usr/mpich-3.2
*/
#include "mpi.h"
#include <stdio.h>
#include <math.h>
double f(double);
double f(double a)
{
return (4.0 / (1.0 + a*a));
}
int main(int argc,char *argv[])
{
int n, myid, numprocs, i;
double PI25DT = 3.141592653589793238462643;
double mypi, pi, h, sum, x;
double startwtime = 0.0, endwtime;
int namelen;
char processor_name[MPI_MAX_PROCESSOR_NAME];
MPI_Init(&argc,&argv);
MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
MPI_Comm_rank(MPI_COMM_WORLD,&myid);
MPI_Get_processor_name(processor_name,&namelen);
fprintf(stdout,"Process %d of %d is on %s\n",
myid, numprocs, processor_name);
fflush(stdout);
n = 10000; /* default # of rectangles */
if (myid == 0)
startwtime = MPI_Wtime();
MPI_Bcast(&n, 1, MPI_INT, 0, MPI_COMM_WORLD);
h = 1.0 / (double) n;
sum = 0.0;
/* A slightly better approach starts from large i and works back */
for (i = myid + 1; i <= n; i += numprocs)
{
x = h * ((double)i - 0.5);
sum += f(x);
}
mypi = h * sum;
MPI_Reduce(&mypi, &pi, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);
if (myid == 0) {
endwtime = MPI_Wtime();
printf("pi is approximately %.16f, Error is %.16f\n",
pi, fabs(pi - PI25DT));
printf("wall clock time = %f\n", endwtime-startwtime);
fflush(stdout);
}
MPI_Finalize();
return 0;
}