Skip to content

Commit

Permalink
Merge branch 'elementary-computer-science'
Browse files Browse the repository at this point in the history
  • Loading branch information
ckirsch committed Jul 24, 2023
2 parents 193fd19 + 84d1a66 commit fd002b6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ selfie-gc-nomain.h: selfie-gc.h
# Consider these targets as targets, not files
.PHONY: self self-self self-self-check 64-to-32-bit \
whitespace quine escape debug replay \
emu emu-emu emu-emu-emu emu-vmm-emu os-emu os-vmm-emu \
emu emu-emu emu-emu-emu emu-vmm-emu os-emu os-vmm-emu overhead \
self-emu self-os-emu self-os-vmm-emu min mob \
gib gclib giblib gclibtest boehmgc cache \
sat brr bzz mon smt beat btor2 all
Expand Down Expand Up @@ -133,6 +133,10 @@ os-emu: selfie selfie.m
os-vmm-emu: selfie selfie.m
./selfie -l selfie.m -m 3 -l selfie.m -y 2 -l selfie.m -y 1

# Determine overhead of timer interrupts and context switching
overhead: selfie selfie.m
./selfie -l selfie.m -m 2 -l selfie.m -c examples/overhead.c -y 1

# Self-compile on emulator
self-emu: selfie selfie.m selfie.s
./selfie -l selfie.m -m 3 -c selfie.c -o selfie-emu.m -s selfie-emu.s
Expand Down
10 changes: 10 additions & 0 deletions examples/overhead.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// looping for measuring overhead of timer interrupts
// as upper bound on overhead of context switching
uint64_t main() {
uint64_t i;

i = 0;

while (i < 1000000000)
i = i + 1;
}
16 changes: 8 additions & 8 deletions selfie.c
Original file line number Diff line number Diff line change
Expand Up @@ -10721,10 +10721,12 @@ void print_instruction_versus_exception_profile(uint64_t* parent_context) {
uint64_t ec_count;
uint64_t* context;

printf("%s: %lu(%lu.%.2lu%%) executed instructions", selfie_name,
printf("%s: %lu executed instructions [%lu.%.2lu%% share, factor %lu.%.2lu]\n", selfie_name,
get_ic_all(parent_context),
percentage_format_integral_2(get_total_number_of_instructions(), get_ic_all(parent_context)),
percentage_format_fractional_2(get_total_number_of_instructions(), get_ic_all(parent_context)));
percentage_format_fractional_2(get_total_number_of_instructions(), get_ic_all(parent_context)),
ratio_format_integral_2(get_total_number_of_instructions(), get_ic_all(parent_context)),
ratio_format_fractional_2(get_total_number_of_instructions(), get_ic_all(parent_context)));

ic_count = 0;
ec_count = 0;
Expand All @@ -10741,17 +10743,15 @@ void print_instruction_versus_exception_profile(uint64_t* parent_context) {
context = get_next_context(context);
}

if (ec_count > 0) {
if (ec_count > 0)
// assert: get_ic_all(parent_context) > 0
printf(" [%lu.%.2lu%% overhead, factor %lu.%.2lu]\n",
printf("%s: %lu exceptions handled by %lu instructions each [%lu.%.2lu%% overhead, factor %lu.%.2lu]\n", selfie_name,
ec_count,
ratio_format_integral_2(get_ic_all(parent_context), ec_count),
percentage_format_integral_2(ic_count, get_ic_all(parent_context)),
percentage_format_fractional_2(ic_count, get_ic_all(parent_context)),
ratio_format_integral_2(get_ic_all(parent_context), ic_count) + 1,
ratio_format_fractional_2(get_ic_all(parent_context), ic_count));
printf("%s: %lu instructions per exception, handling %lu exceptions in total", selfie_name,
ec_count, ratio_format_integral_2(get_ic_all(parent_context), ec_count));
}
println();
}

void print_profile() {
Expand Down

0 comments on commit fd002b6

Please sign in to comment.