Skip to content
Open

misc #23

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1d35956
synchronize bop_msg
benohalloran Apr 12, 2016
9e32f2d
Revert "synchronize bop_msg"
benohalloran Apr 12, 2016
f9375cb
format for abort spec
benohalloran Apr 12, 2016
1901383
Merge pull request #20 from bop-langs/abort_printf
benohalloran Apr 12, 2016
870dce5
remove old semaphore
benohalloran Apr 12, 2016
f4a63b9
Add BOP_ordered ports
benohalloran Apr 19, 2016
589a94c
Merge pull request #22 from bop-langs/ordered_port
benohalloran Apr 19, 2016
ae61a0b
Allow for external error reporter
benohalloran Apr 30, 2016
94c9e87
Cleanup makefile, lower ending bop_report msg level
benohalloran Apr 30, 2016
98619b2
Increase DM Block size
benohalloran Apr 30, 2016
025139f
Refactor dmmalloc headers
benohalloran May 1, 2016
ec3e05d
Properly support printf-like message in abort spec
benohalloran May 1, 2016
ec88c1d
Fix deadlock issue
benohalloran May 2, 2016
2de76f9
Joel's initial commit
joeljk13 Jun 17, 2016
0287edb
Undo
joeljk13 Jun 17, 2016
64de784
Add test
joeljk13 Jun 17, 2016
09ecaa6
Add test
joeljk13 Jun 17, 2016
8658843
Update tests
joeljk13 Jun 22, 2016
40b26f9
Fix formatting in dmmalloc.[ch]
joeljk13 Jun 22, 2016
21f1936
Add sandbox, with add.c example
joeljk13 Jun 22, 2016
31e5e97
Fix missing prototypes
joeljk13 Jun 22, 2016
391d858
Update makefile to save temp files
joeljk13 Jun 22, 2016
28ead86
Sandbox
joeljk13 Jun 22, 2016
b2b27b1
Fix spacing; ignore cscope.out
joeljk13 Jun 22, 2016
6dc45d4
Fix pointer formats
joeljk13 Jun 22, 2016
ceedc2b
Reformat all *.[ch] files
joeljk13 Jul 1, 2016
0d72192
Rewrite Makefile to be cleaner and more extendable
joeljk13 Jul 1, 2016
d9aea5e
Sandbox: change CFLAGS
joeljk13 Jul 10, 2016
581db07
Fix `make clean` to remove more
joeljk13 Jul 10, 2016
c2e60af
Update sandbox
joeljk13 Jul 11, 2016
1dd5b71
Fix hanging bug
joeljk13 Jul 11, 2016
44c7bce
Don't just busy-wait - sleep(1) between wait()s
joeljk13 Jul 11, 2016
c641aa2
Rename environment variables to be uppercase
joeljk13 Jul 11, 2016
94ec6ba
Minor improvements
joeljk13 Jul 11, 2016
73d2f25
Updates for tests
joeljk13 Jul 11, 2016
d2d4840
Revert "Don't just busy-wait - sleep(1) between wait()s"
joeljk13 Jul 13, 2016
06a42cb
Add level to bop_msg output
joeljk13 Jul 13, 2016
fb7f4d3
Fix bugs in CBOP
joeljk13 Jul 25, 2016
d954492
Hack wait fix with usleep; add unit_tests to tests
joeljk13 Jul 27, 2016
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ wrapper_test
malloc_test
*.o
inst.a
libinst.a
*.d
*.d.tmp
cscope.out
89 changes: 23 additions & 66 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,82 +1,39 @@
CC ?= gcc
ifeq ($(CC), cc)
CC = gcc
endif

CI ?= false
ifeq ($(CI), true)
CI_FLAGS = -D CI_BUILD
else
CI_FLAGS = -U CI_BUILD
endif


BUILD_DIR ?= .
_OBJS = malloc_wrapper.o dmmalloc.o ary_bitmap.o postwait.o bop_merge.o \
range_tree/dtree.o bop_ppr.o utils.o external/malloc.o \
bop_ppr_sync.o bop_io.o bop_ports.o bop_ordered.o libc_overrides.o key_value_checks.o

CFLAGS_DEF = -Wall -g -fPIC -pthread -I. -Wno-unused-function $(PLATFORM) $(CUSTOMDEF) $(CI_FLAGS)
CUSTOMDEF = -D USE_DL_PREFIX -D BOP -D USE_LOCKS -D UNSUPPORTED_MALLOC
LDFLAGS = -Wl,--no-as-needed -ldl
OPITIMIZEFLAGS = -O3
DEBUG_FLAGS = -ggdb3 -g3 -pg -D CHECK_COUNTS -U NDEBUG
FLAGS = -Wall -Wno-unused-function -pthread -g3 -fPIC -I. -save-temps \
-D USE_DL_PREFIX -D BOP -D USE_LOCKS -D UNSUPPORTED_MALLOC \
-D DM_DEBUG -D CHECK_COUNTS
LIB = inst.a

LIB_SO = $(BUILD_DIR)/inst.a

OBJS = $(patsubst %,$(BUILD_DIR)/%,$(_OBJS))
_HEADERS = $(wildcard *.h) $(wildcard external/*.h) $(wildcard range_tree/*.h)
HEADERS = $(patsubst %,$(BUILD_DIR)/%,$(_HEADERS))

DEBUG ?= 1
ifeq ($(DEBUG), 1)
CFLAGS = $(CFLAGS_DEF) $(DEBUG_FLAGS)
else
CFLAGS = $(CFLAGS_DEF) $(OPITIMIZEFLAGS)
endif
CFLAGS_ALL = $(FLAGS) $(CFLAGS)
LDFLAGS_ALL = -Wl,--no-as-needed $(LDFLAGS)
LDLIBS_ALL = -ldl $(LDLIBS)

TEST_DIRS = add sleep str/BOP_string str/strsub str/strsub2
SRC := $(wildcard *.c) $(wildcard range_tree/*.c) $(wildcard external/*.c)
OBJS = $(SRC:.c=.o)

library: print_info $(LIB_SO) # $(HEADERS)
TEST_DIRS = add sleep str/BOP_string str/strsub str/strsub2 parallel_alloc unit_tests

print_info:
@echo Build info debug build = $(DEBUG)
@echo cc = $(CC)
@echo CFLAGS = $(CFLAGS)
@echo LDFLAGS = $(LDFLAGS)
@echo OBJS = $(OBJS)
.PHONY: all
all: $(LIB)

test: library
for dir in $(TEST_DIRS) ; do \
.PHONY: test
test: $(LIB)
@for dir in $(TEST_DIRS) ; do \
echo $$dir ; \
cd tests/$$dir ; \
rake ; \
rake run ; \
cd -; \
done

$(LIB_SO): $(OBJS)
@echo building archive "$(LIB_SO)"
@ar r $(LIB_SO) $(OBJS)
@ranlib $(LIB_SO)
$(LIB): $(OBJS)
ar r $(LIB) $(OBJS)
ranlib $(LIB)

all: $(OBJS)

$(BUILD_DIR)/%.o: %.c
@mkdir -p $(@D)
@echo compiling $^
@$(CC) -c -o $@ $^ $(CFLAGS)

$(BUILD_DIR)/%.h: %.h
@mkdir -p $(@D)
@cp $^ $@
%.o: %.c
$(CC) $(CPPFLAGS) $(CFLAGS_ALL) -c -o $@ $<

.PHONY: clean
clean:
rm -f $(OBJS) $(LIB_SO)
for dir in $(TEST_DIRS) ; do \
echo $$dir ; \
cd tests/$$dir ; \
rake clean ; \
cd -; \
done
find -type f -name '*.[ios]' -delete
rm -f $(LIB) tags cscope.out
find -type f -iname rakefile -execdir rake clean \; 2>/dev/null || true
135 changes: 88 additions & 47 deletions ary_bitmap.c
Original file line number Diff line number Diff line change
@@ -1,74 +1,115 @@
#include "ary_bitmap.h"
#include "bop_api.h"
#include "external/malloc.h"
#include <stdlib.h>
#include <string.h>
#include "external/malloc.h"
#include "bop_api.h"
#include "ary_bitmap.h"

/* each entry an unsigned number, 32 bits */
uint32_t ary_map_entries( uint32_t ary_size ) {
return (ary_size >> 5) + ((ary_size & 0x1f)? 1: 0);
uint32_t
ary_map_entries(uint32_t ary_size)
{
return (ary_size >> 5) + ((ary_size & 0x1f) ? 1 : 0);
}

void *ary_malloc_with_map( uint32_t length, uint32_t elem_size ) {
void *ary = malloc( length*(elem_size) + ary_map_entries(length) * sizeof(uint32_t) * 2 );
ary_maps_reset( ary, length, elem_size );
return ary;
void *
ary_malloc_with_map(uint32_t length, uint32_t elem_size)
{
void *ary = malloc(length * (elem_size) +
ary_map_entries(length) * sizeof(uint32_t) * 2);

ary_maps_reset(ary, length, elem_size);
return ary;
}

void *ary_realloc_with_map( void *mem, uint32_t new_len, uint32_t elem_size ) {
void *ary = realloc( mem, new_len*elem_size + ary_map_entries(new_len) * sizeof(uint32_t) * 2 );
ary_maps_reset( ary, new_len, elem_size );
return ary;
void *
ary_realloc_with_map(void *mem, uint32_t new_len, uint32_t elem_size)
{
void *ary = realloc(mem,
new_len * elem_size +
ary_map_entries(new_len) * sizeof(uint32_t) * 2);

ary_maps_reset(ary, new_len, elem_size);
return ary;
}

uint32_t *get_ary_use_map( void *base, uint32_t length, uint32_t elem_size ) {
return (uint32_t *) (((char*)base) + elem_size * length);
uint32_t *
get_ary_use_map(void *base, uint32_t length, uint32_t elem_size)
{
return (uint32_t *)(((char *)base) + elem_size * length);
}

uint32_t *get_ary_mod_map( void *base, uint32_t length, uint32_t elem_size ) {
return (uint32_t *) (((char*)base) + elem_size * length + ary_map_entries(length) * sizeof(uint32_t));
uint32_t *
get_ary_mod_map(void *base, uint32_t length, uint32_t elem_size)
{
return (uint32_t *)(((char *)base) + elem_size * length +
ary_map_entries(length) * sizeof(uint32_t));
}

void ary_maps_reset( void *base, uint32_t length, uint32_t elem_size ) {
char * maps_base = (char*) get_ary_use_map( base, length, elem_size );
memset( maps_base, 0, ary_map_entries( length ) * 2 * sizeof( uint32_t ) );
BOP_promise( maps_base, ary_map_entries( length ) * 2 * sizeof( uint32_t ) );
void
ary_maps_reset(void *base, uint32_t length, uint32_t elem_size)
{
char *maps_base = (char *)get_ary_use_map(base, length, elem_size);

memset(maps_base, 0, ary_map_entries(length) * 2 * sizeof(uint32_t));
BOP_promise(maps_base, ary_map_entries(length) * 2 * sizeof(uint32_t));
}

static void mark_bit( uint32_t *map, uint32_t idx ) {
uint32_t word_idx = idx >> 5;
uint32_t offset = idx & 0x1f;
map[ word_idx ] |= 0x1 << offset;
static void
mark_bit(uint32_t *map, uint32_t idx)
{
uint32_t word_idx = idx >> 5;
uint32_t offset = idx & 0x1f;

map[word_idx] |= 0x1 << offset;
}

void ary_use_elem( void *base, uint32_t length,
uint32_t elem_size, uint32_t idx ) {
uint32_t *use_map = get_ary_use_map( base, length, elem_size );
mark_bit( use_map, idx );
void
ary_use_elem(void *base, uint32_t length, uint32_t elem_size, uint32_t idx)
{
uint32_t *use_map = get_ary_use_map(base, length, elem_size);

mark_bit(use_map, idx);
}

void ary_promise_elem( void *base, uint32_t length,
uint32_t elem_size, uint32_t idx ) {
uint32_t *mod_map = get_ary_mod_map( base, length, elem_size );
mark_bit( mod_map, idx );
void
ary_promise_elem(void *base, uint32_t length, uint32_t elem_size, uint32_t idx)
{
uint32_t *mod_map = get_ary_mod_map(base, length, elem_size);

mark_bit(mod_map, idx);
}

static void scan_one_map( void *base, uint32_t length, uint32_t elem_size,
uint32_t *map, monitor_t *bop_mon ) {
uint32_t num = ary_map_entries( length );
static void
scan_one_map(void *base,
uint32_t length,
uint32_t elem_size,
uint32_t *map,
monitor_t *bop_mon)
{
uint32_t num = ary_map_entries(length);
int i, j;
for ( i = 0; i < num; i++ ) {
uint32_t word = map[ i ];
uint32_t idx = i << 5;
for ( j = 0; j < 32; j++ )
if ( (word >> j) & 0x1 )
(*bop_mon)( ((char*) base) + (idx + j) * elem_size, elem_size );

for (i = 0; i < num; i++) {
uint32_t word = map[i];
uint32_t idx = i << 5;

for (j = 0; j < 32; j++)
if ((word >> j) & 0x1)
(*bop_mon)(((char *)base) + (idx + j) * elem_size, elem_size);
}
}

void scan_ary_maps( void *base, uint32_t length, uint32_t elem_size ) {
scan_one_map( base, length, elem_size,
get_ary_use_map(base, length, elem_size), & BOP_record_read );
scan_one_map( base, length, elem_size,
get_ary_mod_map(base, length, elem_size), & BOP_record_write );
void
scan_ary_maps(void *base, uint32_t length, uint32_t elem_size)
{
scan_one_map(base,
length,
elem_size,
get_ary_use_map(base, length, elem_size),
&BOP_record_read);
scan_one_map(base,
length,
elem_size,
get_ary_mod_map(base, length, elem_size),
&BOP_record_write);
}
29 changes: 18 additions & 11 deletions ary_bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,31 @@
#define _ARY_BITMAP_H_
#include <stdint.h>

void *ary_malloc_with_map( uint32_t length, uint32_t elem_size );
void *ary_realloc_with_map( void *var, uint32_t length, uint32_t elem_size );
void *
ary_malloc_with_map(uint32_t length, uint32_t elem_size);
void *
ary_realloc_with_map(void *var, uint32_t length, uint32_t elem_size);

/* each entry an unsigned number, 32 bits */
uint32_t ary_map_entries( uint32_t ary_size );
uint32_t
ary_map_entries(uint32_t ary_size);

uint32_t *get_ary_use_map( void *base, uint32_t lenth, uint32_t elem_size );
uint32_t *
get_ary_use_map(void *base, uint32_t lenth, uint32_t elem_size);

uint32_t *get_ary_mod_map( void *base, uint32_t lenth, uint32_t elem_size );
uint32_t *
get_ary_mod_map(void *base, uint32_t lenth, uint32_t elem_size);

void ary_maps_reset( void *base, uint32_t lenth, uint32_t elem_size );
void
ary_maps_reset(void *base, uint32_t lenth, uint32_t elem_size);

void ary_use_elem( void *base, uint32_t lenth,
uint32_t elem_size, uint32_t idx );
void
ary_use_elem(void *base, uint32_t lenth, uint32_t elem_size, uint32_t idx);

void ary_promise_elem( void *base, uint32_t lenth,
uint32_t elem_size, uint32_t idx );
void
ary_promise_elem(void *base, uint32_t lenth, uint32_t elem_size, uint32_t idx);

void scan_ary_maps( void *base, uint32_t length, uint32_t elem_size );
void
scan_ary_maps(void *base, uint32_t length, uint32_t elem_size);

#endif
Loading