Skip to content

Commit

Permalink
Merge release-7.2.0 (#171)
Browse files Browse the repository at this point in the history
Merge release-7.2.0:

* New default clock: get-time-of-day (#170)
* STime API (#159)
* Add ARMv7l arch support to ROSS (#155)
* Fix to generate covage stats (#150)
* changing damaris submodule/directory to risa
* Updated README
* Update to the way the build process grabs version number (#148)
* simplifying the build of static or shared libraries (#147)
* ROSS cleanup: -Wall, -Wextra, and more (#135)
  • Loading branch information
gonsie authored Dec 2, 2019
2 parents adfaf05 + dc562c5 commit 5eb95cf
Show file tree
Hide file tree
Showing 33 changed files with 416 additions and 221 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ script:
- make
- CTEST_OUTPUT_ON_FAILURE=1 make test
- cd ..
- mkdir build-gtod && cd build-gtod
- MPICH_CC=clag cmake -DCOVERALLS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS="-Wall -Wextra" -DROSS_BUILD_MODELS=ON -DROSS_CLOCK_OVERRIDE=ON ..
- make
- CTEST_OUTPUT_ON_FAILURE=1 ctest -R SCHED
- make coveralls
- cd ..
- mkdir build && cd build
- MPICH_CC=clang cmake -DCOVERALLS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS="-Wall -Wextra" -DROSS_BUILD_MODELS=ON ..
- make
Expand Down
19 changes: 14 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ SET(GVT mpi_allreduce)

# Architecture setting and management
SET(VALID_ARCH NO)
OPTION(ROSS_CLOCK_OVERRIDE "override platform detection to use gtod clock" NO)

IF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL i386)
SET(VALID_ARCH YES)
Expand Down Expand Up @@ -132,16 +133,24 @@ IF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL aarch64)
SET(CLOCK aarch64)
ENDIF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL aarch64)

IF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL armv7l)
SET(VALID_ARCH YES)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
ADD_DEFINITIONS(-D_GNU_SOURCE)
SET(CLOCK armv7l)
ENDIF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL armv7l)

IF(VALID_ARCH)
IF(VALID_ARCH AND NOT ${ROSS_CLOCK_OVERRIDE})
MESSAGE(STATUS "System architecture detected: ${CMAKE_SYSTEM_PROCESSOR}")
MESSAGE(STATUS "Using C_FLAGS: ${CMAKE_C_FLAGS}")
MESSAGE(STATUS "Using CLOCK: ${CLOCK}")
ELSE(VALID_ARCH)
MESSAGE(FATAL_ERROR "System architecture not recognized!\n"
ELSE(VALID_ARCH AND NOT ${ROSS_CLOCK_OVERRIDE})
MESSAGE(WARNING "System architecture not recognized!\n"
"Found: ${CMAKE_SYSTEM_PROCESSOR}\n"
"Expected: i386 | x86_64 | ppc64 | ppc64le | aarch64")
ENDIF(VALID_ARCH)
"Falling back to get-time-of-day clock implementation.")
SET(CLOCK gtod)
ENDIF(VALID_ARCH AND NOT ${ROSS_CLOCK_OVERRIDE})


## MPI
INCLUDE(SetupMPI)
Expand Down
62 changes: 31 additions & 31 deletions core/avl_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ avlSearch(AvlTree t, tw_event *key)
if (t == AVL_EMPTY) {
return 0;
}
if (key->recv_ts == t->key->recv_ts) {

if (TW_STIME_CMP(key->recv_ts, t->key->recv_ts) == 0) {
// Timestamp is the same
if (key->event_id == t->key->event_id) {
// Event ID is the same
Expand All @@ -63,7 +63,7 @@ avlSearch(AvlTree t, tw_event *key)
}
else {
// Timestamp is different
return avlSearch(t->child[key->recv_ts > t->key->recv_ts], key);
return avlSearch(t->child[TW_STIME_CMP(key->recv_ts, t->key->recv_ts) > 0], key);
}
}

Expand All @@ -72,12 +72,12 @@ void
avlSanityCheck(AvlTree root)
{
int i;

if (root != AVL_EMPTY) {
for (i = 0; i < 2; i++) {
avlSanityCheck(root->child[i]);
}

assert(root->height == 1 + ROSS_MAX(avlGetHeight(root->child[0]), avlGetHeight(root->child[1])));
}
}
Expand All @@ -87,7 +87,7 @@ static void
avlFixHeight(AvlTree t)
{
assert(t != AVL_EMPTY);

t->height = 1 + ROSS_MAX(avlGetHeight(t->child[0]), avlGetHeight(t->child[1]));
}

Expand All @@ -108,15 +108,15 @@ avlRotate(AvlTree *root, int d)
AvlTree oldRoot;
AvlTree newRoot;
AvlTree oldMiddle;

oldRoot = *root;
newRoot = oldRoot->child[d];
oldMiddle = newRoot->child[!d];

oldRoot->child[d] = oldMiddle;
newRoot->child[!d] = oldRoot;
*root = newRoot;

/* update heights */
avlFixHeight((*root)->child[!d]); /* old root */
avlFixHeight(*root); /* new root */
Expand All @@ -129,7 +129,7 @@ static void
avlRebalance(AvlTree *t)
{
int d;

if (*t != AVL_EMPTY) {
for (d = 0; d < 2; d++) {
/* maybe child[d] is now too tall */
Expand All @@ -146,11 +146,11 @@ avlRebalance(AvlTree *t)
avlRotate(&(*t)->child[d], !d);
avlRotate(t, d);
}

return; /* avlRotate called avlFixHeight */
}
}

/* update height */
avlFixHeight(*t);
}
Expand All @@ -171,19 +171,19 @@ avlInsert(AvlTree *t, tw_event *key)
"AVL tree out of memory.\nIncrease avl-size beyond %d\n",
(int)log2(g_tw_avl_node_count));
}

(*t)->child[0] = AVL_EMPTY;
(*t)->child[1] = AVL_EMPTY;

(*t)->key = key;

(*t)->height = 1;

/* done */
return;
}
if (key->recv_ts == (*t)->key->recv_ts) {

if (TW_STIME_CMP(key->recv_ts, (*t)->key->recv_ts) == 0) {
// We have a timestamp tie, check the event ID
if (key->event_id == (*t)->key->event_id) {
// We have a event ID tie, check the send_pe
Expand All @@ -203,7 +203,7 @@ avlInsert(AvlTree *t, tw_event *key)
}
else {
// Timestamps are different
avlInsert(&(*t)->child[key->recv_ts > (*t)->key->recv_ts], key);
avlInsert(&(*t)->child[TW_STIME_CMP(key->recv_ts, (*t)->key->recv_ts) > 0], key);
avlRebalance(t);
}
}
Expand All @@ -227,9 +227,9 @@ avlDeleteMin(AvlTree *t)
{
AvlTree oldroot;
tw_event *event_with_lowest_ts = NULL;

assert(t != AVL_EMPTY);

if ((*t)->child[0] == AVL_EMPTY) {
/* root is min value */
oldroot = *t;
Expand All @@ -241,7 +241,7 @@ avlDeleteMin(AvlTree *t)
/* min value is in left subtree */
event_with_lowest_ts = avlDeleteMin(&(*t)->child[0]);
}

avlRebalance(t);
return event_with_lowest_ts;
}
Expand All @@ -252,13 +252,13 @@ avlDelete(AvlTree *t, tw_event *key)
{
tw_event *target = NULL;
AvlTree oldroot;

if (*t == AVL_EMPTY) {
tw_error(TW_LOC, "We never look for non-existent events!");
return target;
}
if (key->recv_ts == (*t)->key->recv_ts) {

if (TW_STIME_CMP(key->recv_ts, (*t)->key->recv_ts) == 0) {
// We have a timestamp tie, check the event ID
if (key->event_id == (*t)->key->event_id) {
// We have a event ID tie, check the send_pe
Expand Down Expand Up @@ -289,27 +289,27 @@ avlDelete(AvlTree *t, tw_event *key)
}
else {
// Timestamps are different
target = avlDelete(&(*t)->child[key->recv_ts > (*t)->key->recv_ts], key);
target = avlDelete(&(*t)->child[TW_STIME_CMP(key->recv_ts, (*t)->key->recv_ts) > 0], key);
}

avlRebalance(t);

return target;
}

AvlTree avl_alloc(void)
{
AvlTree head = g_tw_pe->avl_list_head;
g_tw_pe->avl_list_head = head->next;

if (g_tw_pe->avl_list_head == NULL) {
tw_error(TW_LOC,
"AVL tree out of memory.\nIncrease avl-size beyond %d\n",
(int)log2(g_tw_avl_node_count));
}

head->next = NULL;

return head;
}

Expand Down
48 changes: 48 additions & 0 deletions core/clock/armv7l.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
This implementation of an ARM v7 clock reader utilizes the
Performance Monitoring Unit (PMU) on Cortex-A7 chips.
Unfortunately, access to the cycle counter from userspace
is disabled by default. A kernel module that enables access
from userspace is required or the system will fault.
An example kernel module that does just that can be found:
https://github.com/nmcglohon/armv7l-userspace-counter.git
More information can be found:
http://neocontra.blogspot.com/2013/05/user-mode-performance-counters-for.html
*/

#include <ross.h>

#ifndef __GNUC__
# error gcc asm extensions required
#endif
#if ! (defined(__arm__))
# error only 32 bit arm platform supported
#endif

static const tw_optdef clock_opts [] =
{
TWOPT_GROUP("ROSS Timing"),
TWOPT_STIME("clock-rate", g_tw_clock_rate, "CPU Clock Rate"),
TWOPT_END()
};

const tw_optdef *tw_clock_setup(void)
{
return clock_opts;
}


void tw_clock_init(tw_pe * me)
{
me->clock_time = 0;
me->clock_offset = tw_clock_read();
}


tw_clock tw_clock_now(tw_pe * me)
{
me->clock_time = tw_clock_read() - me->clock_offset;
return me->clock_time;
}
32 changes: 32 additions & 0 deletions core/clock/armv7l.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
This implementation of an ARM v7 clock reader utilizes the
Performance Monitoring Unit (PMU) on Cortex-A7 chips.
Unfortunately, access to the cycle counter from userspace
is disabled by default. A kernel module that enables access
from userspace is required or the system will fault.
An example kernel module that does just that can be found:
https://github.com/nmcglohon/armv7l-userspace-counter.git
More information can be found:
http://neocontra.blogspot.com/2013/05/user-mode-performance-counters-for.html
*/

#ifndef INC_clock_armv7l
#define INC_clock_armv7l

typedef unsigned int tw_clock;

static inline tw_clock tw_clock_read(void)
{
unsigned int result;
#ifdef ROSS_timing
do {
__asm__ __volatile__ ("MRC p15, 0, %0, c9, c13, 0" : "=r"(result));
} while (__builtin_expect ((int) result == -1, 0));
#endif

return result;
}

#endif
53 changes: 53 additions & 0 deletions core/clock/gtod.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include <ross.h>

extern unsigned long long g_tw_clock_rate;

static const tw_optdef clock_opts [] =
{
TWOPT_GROUP("ROSS Timing"),
TWOPT_ULONGLONG("clock-rate", g_tw_clock_rate, "CPU Clock Rate"),
TWOPT_END()
};

const tw_optdef *tw_clock_setup(void)
{
return clock_opts;
}

tw_clock tw_clock_read(void)
{
#ifdef ZERO_BASED
static volatile int inited = 0;
static volatile tw_clock base = 0;
#else
const tw_clock base = 0;
#endif

const tw_clock scale = 1000000;
struct timeval tv;
gettimeofday(&tv,NULL);

#ifdef ZERO_BASED
if(inited == 0) {
base = ((tw_clock) tv.tv_sec)*scale + (tw_clock) tv.tv_usec;
inited = 1;
}
#endif

return
(((tw_clock) tv.tv_sec)*scale + (tw_clock) tv.tv_usec) - base;
}

void
tw_clock_init(tw_pe * me)
{
me->clock_time = 0;
me->clock_offset = tw_clock_read();
}

tw_clock
tw_clock_now(tw_pe * me)
{
me->clock_time = tw_clock_read() - me->clock_offset;
return me->clock_time;
}
6 changes: 6 additions & 0 deletions core/clock/gtod.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef INC_clock_gtod
#define INC_clock_gtod

typedef uint64_t tw_clock;

#endif
Loading

0 comments on commit 5eb95cf

Please sign in to comment.