Measurement infrastructure and tests
authorBarret Rhoden <brho@cs.berkeley.edu>
Fri, 5 Jun 2009 20:42:07 +0000 (13:42 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Sat, 6 Jun 2009 00:22:17 +0000 (17:22 -0700)
test_run_measurements and measurements.c are closely coupled.  Make sure
the case statements match up.

include/env.h
include/testing.h
kern/src/Makefrag
kern/src/console.c
kern/src/env.c
kern/src/manager.c
kern/src/testing.c
kern/src/workqueue.c
user/apps/parlib/readline.c
user/apps/roslib/measurements.c
user/roslib/inc/measure.h

index 21bad4b..4ac2bb0 100644 (file)
@@ -26,6 +26,9 @@ int   envid2env(envid_t envid, env_t **env_store, bool checkperm);
 void   (IN_HANDLER env_run)(env_t *e) __attribute__((noreturn));
 void   env_pop_tf(trapframe_t *tf) __attribute__((noreturn));
 
+/* Helper handler for smp_call to dispatch jobs to other cores */
+void run_env_handler(trapframe_t *tf, void* data);
+
 #define ENV_CREATE(x)                  ({                                             \
        extern uint8_t _binary_obj_user_apps_##x##_start[],                        \
                _binary_obj_user_apps_##x##_size[];                                    \
index e49369b..33be6a5 100644 (file)
@@ -19,6 +19,7 @@ void test_checklists(void);
 void test_pit(void);
 void test_smp_call_functions(void);
 void test_lapic_status_bit(void);
+void test_run_measurements(uint32_t job_num);
 
 void test_hello_world_handler(trapframe_t *tf, void* data);
 void test_print_info_handler(trapframe_t *tf, void* data);
index 3c29fec..1189365 100644 (file)
@@ -39,26 +39,13 @@ KERN_SRCFILES := $(KERN_SRC_DIR)/entry.S \
 # Only build files if they exist.
 KERN_SRCFILES := $(wildcard $(KERN_SRCFILES))
 
-KERN_APPFILES :=       $(USER_APPS_PARLIB_DIR)/matrix 
+KERN_APPFILES :=    $(USER_APPS_PARLIB_DIR)/matrix \
+                    $(USER_APPS_ROSLIB_DIR)/null \
+                    $(USER_APPS_ROSLIB_DIR)/hello \
+                    $(USER_APPS_ROSLIB_DIR)/measurements
 #                    $(USER_APPS_PARLIB_DIR)/draw_nanwan
 #                    $(USER_APPS_PARLIB_DIR)/open_read \
-#                    $(USER_APPS_ROSLIB_DIR)/null
-#                                      $(USER_APPS_ROSLIB_DIR)/hello \
-#                                      apps/hello \
-#                                      apps_newlib/null \
-#                              apps/hello \
-#                              apps/buggyhello \
-#                              apps/evilhello \
-#                              apps/testbss \
-#                              apps/divzero \
-#                              apps/breakpoint \
-#                              apps/softint \
-#                              apps/badsegment \
-#                              apps/faultread \
-#                              apps/faultreadkernel \
-#                              apps/faultwrite \
-#                              apps/faultwritekernel \
-#                              apps_newlib/null \
+#                    $(USER_APPS_PARLIB_DIR)/hello \
 
 KERN_LDFLAGS   := $(KERN_LDFLAGS) -L$(OBJDIR)/$(KERN_DIR) \
                   -T $(KERN_DIR)/kernel.ld
index 95ef7af..eb83b1a 100644 (file)
@@ -70,7 +70,7 @@ serial_init(void)
        // 8 data bits, 1 stop bit, parity off; turn off DLAB latch
        outb(COM1+COM_LCR, COM_LCR_WLEN8 & ~COM_LCR_DLAB);
 
-       // No modem controls
+       // This should turn on hardware flow control
        outb(COM1+COM_MCR, COM_MCR_RTS | COM_MCR_DTR);
        // Enable rcv interrupts
        outb(COM1+COM_IER, COM_IER_RDI);
index 9fbe3a2..5b206eb 100644 (file)
@@ -611,3 +611,16 @@ env_run(env_t *e)
     env_pop_tf(&e->env_tf);
 }
 
+/* This is the top-half of an interrupt handler, where the bottom half is
+ * env_run (which never returns).  Just add it to the delayed work queue,
+ * which isn't really a queue yet.
+ */
+void run_env_handler(trapframe_t *tf, void* data)
+{
+       assert(data);
+       per_cpu_info_t *cpuinfo = &per_cpu_info[lapic_get_id()];
+       spin_lock_irqsave(&cpuinfo->lock);
+       cpuinfo->delayed_work.func = (func_t)env_run;
+       cpuinfo->delayed_work.data = data;
+       spin_unlock_irqsave(&cpuinfo->lock);
+}
index fb0ebd1..f065d5d 100644 (file)
 #include <env.h>
 #include <workqueue.h>
 #include <syscall.h>
-
-/* Helper handlers for smp_call to dispatch jobs to other cores */
-static void work_env_run(void* data)
-{
-       env_run((env_t*)data);
-}
-
-static void run_env_handler(trapframe_t *tf, void* data)
-{
-       assert(data);
-       per_cpu_info[lapic_get_id()].delayed_work.func = work_env_run;
-       per_cpu_info[lapic_get_id()].delayed_work.data = data;
-}
+#include <testing.h>
 
 /*
  * Currently, if you leave this function by way of env_run (process_workqueue
@@ -38,13 +26,40 @@ static void run_env_handler(trapframe_t *tf, void* data)
 void manager(void)
 {
        static uint8_t progress = 0;
-       env_t* env_batch[64]; // Fairly arbitrary, just the max I plan to use.
        
-       if(progress == 0) {
-               progress++;
-               env_batch[0] = ENV_CREATE(parlib_matrix);
-               env_run(env_batch[0]);
+       switch (progress++) {
+               case 0:
+                       printk("Beginning Tests\n");
+                       test_run_measurements(progress);  // should never return
+                       break;
+               case 1:
+               case 2:
+               case 3:
+               case 4:
+               case 5:
+               case 6:
+               case 7:
+               case 8:
+               case 9:
+               case 10:
+               case 11:
+               case 12:
+               case 13:
+               case 14:
+                       test_run_measurements(progress);
+                       break;
+               default:
+                       panic("Don't Panic");
+       }
+       panic("If you see me, then you probably screwed up");
+
+       /*
+       printk("Servicing syscalls from Core 0:\n\n");
+       while (1) {
+               process_generic_syscalls(&envs[0], 1);
+               cpu_relax();
        }
+       */
        return;
 }
 
index 5771de8..56fe16b 100644 (file)
@@ -3,6 +3,7 @@
 #endif
 
 #include <arch/mmu.h>
+#include <ros/memlayout.h>
 #include <arch/x86.h>
 #include <arch/smp.h>
 #include <arch/apic.h>
@@ -12,6 +13,8 @@
 #include <string.h>
 #include <testing.h>
 #include <trap.h>
+#include <env.h>
+#include <syscall.h>
 
 #define test_vector 0xeb
 
@@ -19,7 +22,7 @@ void test_ipi_sending(void)
 {
        extern handler_t interrupt_handlers[];
        int8_t state = 0;
-       
+
        register_interrupt_handler(interrupt_handlers, test_vector,
                                   test_hello_world_handler, 0);
        enable_irqsave(&state);
@@ -74,7 +77,7 @@ void test_print_info(void)
        smp_call_function_all(test_print_info_handler, 0, 0);
        cprintf("\nDone!\n");
 }
-       
+
 
 extern uint8_t num_cpus;
 barrier_t test_cpu_array;
@@ -110,7 +113,7 @@ void test_interrupts_irqsave(void)
        disable_irqsave(&state);
        printd("Interrupts are: %x\n", read_eflags() & FL_IF);
        assert((read_eflags() & FL_IF) == 0);
-       printd("Done.  Should have been 0, 200, 200, 200, 0\n");        
+       printd("Done.  Should have been 0, 200, 200, 200, 0\n");
 
        printd("Testing Nesting Disabling first, turning ints on:\n");
        state = 0;
@@ -133,7 +136,7 @@ void test_interrupts_irqsave(void)
        enable_irqsave(&state);
        printd("Interrupts are: %x\n", read_eflags() & FL_IF);
        assert((read_eflags() & FL_IF) == 0x200);
-       printd("Done.  Should have been 200, 0, 0, 0, 200 \n"); 
+       printd("Done.  Should have been 200, 0, 0, 0, 200 \n");
 
        state = 0;
        disable_irq();
@@ -144,7 +147,7 @@ void test_interrupts_irqsave(void)
        disable_irqsave(&state);
        printd("Interrupts are: %x\n", read_eflags() & FL_IF);
        assert((read_eflags() & FL_IF) == 0);
-       printd("Done.  Should have been 200, 0\n");     
+       printd("Done.  Should have been 200, 0\n");
 
        state = 0;
        enable_irq();
@@ -155,7 +158,7 @@ void test_interrupts_irqsave(void)
        disable_irqsave(&state);
        printd("Interrupts are: %x\n", read_eflags() & FL_IF);
        assert((read_eflags() & FL_IF) == 0x200);
-       printd("Done.  Should have been 200, 200\n");   
+       printd("Done.  Should have been 200, 200\n");
 
        state = 0;
        disable_irq();
@@ -166,7 +169,7 @@ void test_interrupts_irqsave(void)
        enable_irqsave(&state);
        printd("Interrupts are: %x\n", read_eflags() & FL_IF);
        assert((read_eflags() & FL_IF) == 0);
-       printd("Done.  Should have been 0, 0\n");       
+       printd("Done.  Should have been 0, 0\n");
 
        state = 0;
        enable_irq();
@@ -177,7 +180,7 @@ void test_interrupts_irqsave(void)
        enable_irqsave(&state);
        printd("Interrupts are: %x\n", read_eflags() & FL_IF);
        assert((read_eflags() & FL_IF) == 0x200);
-       printd("Done.  Should have been 0, 200\n");     
+       printd("Done.  Should have been 0, 200\n");
 
        disable_irq();
        cprintf("Passed enable_irqsave tests\n");
@@ -250,11 +253,11 @@ void test_checklists(void)
        commit_checklist_wait(&a_list, &a_mask);
        printk("Old mask (copied onto):\n");
        PRINT_BITMASK(a_list.mask.bits, a_list.mask.size);
-       //smp_call_function_single(1, test_checklist_handler, 0, 0);    
-       smp_call_function_all(test_checklist_handler, 0, 0);    
+       //smp_call_function_single(1, test_checklist_handler, 0, 0);
+       smp_call_function_all(test_checklist_handler, 0, 0);
 
        printk("Waiting on checklist\n");
-       waiton_checklist(&a_list);      
+       waiton_checklist(&a_list);
        printk("Done Waiting!\n");
 
 }
@@ -401,11 +404,142 @@ void test_lapic_status_bit(void)
        // hopefully that handler never fires again.  leaving it registered for now.
 }
 
-/* Helper Functions */
+/******************************************************************************/
+/*            Test Measurements: Couples with measurement.c                   */
+// All user processes can R/W the UGDATA page
+barrier_t* bar = (barrier_t*)UGDATA;
+uint32_t* job_to_run = (uint32_t*)(UGDATA + sizeof(barrier_t));
+env_t* env_batch[64]; // Fairly arbitrary, just the max I plan to use.
+
+/* Helpers for test_run_measurements */
+static void wait_for_all_envs_to_die(void)
+{
+       while (num_envs)
+               cpu_relax();
+}
+
+// this never returns.
+static void sync_tests(int start_core, int num_threads, int job_num)
+{
+       assert(start_core + num_threads <= num_cpus);
+       wait_for_all_envs_to_die();
+       for (int i = start_core; i < start_core + num_threads; i++)
+               env_batch[i] = ENV_CREATE(roslib_measurements);
+       init_barrier(bar, num_threads);
+       *job_to_run = job_num;
+       for (int i = start_core; i < start_core + num_threads; i++)
+               smp_call_function_single(i, run_env_handler, env_batch[i], 0);
+       process_workqueue();
+       // we want to fake a run, to reenter manager for the next case
+       env_t *env = ENV_CREATE(roslib_null);
+       smp_call_function_single(0, run_env_handler, env, 0);
+       process_workqueue();
+       panic("whoops!\n");
+}
+
+static void async_tests(int start_core, int num_threads, int job_num)
+{
+       int count;
+
+       assert(start_core + num_threads <= num_cpus);
+       wait_for_all_envs_to_die();
+       for (int i = start_core; i < start_core + num_threads; i++)
+               env_batch[i] = ENV_CREATE(roslib_measurements);
+       init_barrier(bar, num_threads);
+       *job_to_run = job_num;
+       for (int i = start_core; i < start_core + num_threads; i++)
+               smp_call_function_single(i, run_env_handler, env_batch[i], 0);
+       count = 0;
+       while (count > -num_threads) {
+               count = 0;
+               for (int i = start_core; i < start_core + num_threads; i++) {
+                       count += process_generic_syscalls(env_batch[i], 1);
+               }
+               cpu_relax();
+       }
+       // we want to fake a run, to reenter manager for the next case
+       env_t *env = ENV_CREATE(roslib_null);
+       smp_call_function_single(0, run_env_handler, env, 0);
+       process_workqueue();
+       // this all never returns
+       panic("whoops!\n");
+}
+
+void test_run_measurements(uint32_t job_num)
+{
+       switch (job_num) {
+               case 0: // Nulls
+                       printk("Case 0:\n");
+                       async_tests(2, 1, job_num);  // start core 2, 1 core total
+                       break;
+               case 1: // Sync
+                       printk("Case 1:\n");
+                       sync_tests(2, 1, job_num);
+                       break;
+               case 2:
+                       printk("Case 2:\n");
+                       sync_tests(2, 2, job_num);
+                       break;
+               case 3:
+                       printk("Case 3:\n");
+                       sync_tests(0, 3, job_num);
+                       break;
+               case 4:
+                       printk("Case 4:\n");
+                       sync_tests(0, 4, job_num);
+                       break;
+               case 5:
+                       printk("Case 5:\n");
+                       sync_tests(0, 5, job_num);
+                       break;
+               case 6:
+                       printk("Case 6:\n");
+                       sync_tests(0, 6, job_num);
+                       break;
+               case 7:
+                       printk("Case 7:\n");
+                       sync_tests(0, 7, job_num);
+                       break;
+               case 8:
+                       printk("Case 8:\n");
+                       sync_tests(0, 8, job_num);
+                       break;
+               case 9:
+                       printk("Case 9:\n");
+                       async_tests(2, 1, job_num);
+                       break;
+               case 10:
+                       printk("Case 10:\n");
+                       async_tests(2, 2, job_num);
+                       break;
+               case 11:
+                       printk("Case 11:\n");
+                       async_tests(2, 3, job_num);
+                       break;
+               case 12:
+                       printk("Case 12:\n");
+                       async_tests(2, 4, job_num);
+                       break;
+               case 13:
+                       printk("Case 13:\n");
+                       async_tests(2, 5, job_num);
+                       break;
+               case 14:
+                       printk("Case 14:\n");
+                       async_tests(2, 6, job_num);
+                       break;
+               default:
+                       warn("Invalid test number!!");
+       }
+       panic("Error in test setup!!");
+}
+
+/************************************************************/
+/* ISR Handler Functions */
 
 void test_hello_world_handler(trapframe_t *tf, void* data)
 {
-       cprintf("Incoming IRQ, ISR: %d on core %d with tf at 0x%08x\n", 
+       cprintf("Incoming IRQ, ISR: %d on core %d with tf at 0x%08x\n",
                tf->tf_trapno, lapic_get_id(), tf);
 }
 
@@ -466,11 +600,11 @@ void test_pit(void)
        cprintf("Starting test for TSC (if stable) now (10s)\n");
        udelay(10000000);
        cprintf("End now\n");
-       
+
        cprintf("Starting test for LAPIC (if stable) now (10s)\n");
        enable_irq();
        lapic_set_timer(10000000, FALSE);
-       
+
        uint32_t waiting = 1;
        register_interrupt_handler(interrupt_handlers, test_vector,
                                   test_waiting_handler, &waiting);
index edd185c..c934b2f 100644 (file)
@@ -6,8 +6,9 @@
 #include <arch/x86.h>
 #include <arch/apic.h>
 #include <arch/smp.h>
+#include <arch/atomic.h>
+
 #include <workqueue.h>
-#include <atomic.h>
 
 /*
  * TODO: actually use a queue, which will change some things all over.
index 133273c..7c53082 100644 (file)
@@ -1,5 +1,5 @@
 #include <unistd.h>
-#include <printf.h>
+#include <stdio.h>
 #include <fcntl.h>
 #include <arch/kbdreg.h>
 
index 311ac2f..074991a 100644 (file)
-// null app
-#include <inc/lib.h>
-#include <inc/types.h>
-#include <inc/syscall.h>
-#include <inc/x86.h>
-#include <inc/measure.h>
-#include <inc/null.h>
-#include <inc/timer.h>
+#include <arch/types.h>
+#include <arch/x86.h>
+#include <arch/timer.h>
+#include <arch/atomic.h>
+
+#include <ros/syscall.h>
+
+#include <lib.h>
+#include <measure.h>
+#include <syswrapper.h>
 
 #ifdef __DEPUTY__
 #pragma nodeputy
 #endif
 
+/* System-Global shared page */
+#define shared_page UGDATA
+
+/* Actual Things in the shared memory space:
+ * - First is the barrier
+ * - Second is some job info in here too.
+ */
+
+barrier_t* bar = (barrier_t*)shared_page;
+volatile uint32_t* job_to_run = (uint32_t*)(shared_page + sizeof(barrier_t));
+
+// Experiment constants
+uint32_t corecount = 0;
+#define MAX_CACHELINE_WRITES 129
+
+/* Syscall Methods:
+ * Pulling these in directly so we can measure them without other overheads. 
+ */
+static uint32_t
+syscall_sysenter(int num, uint32_t a1, uint32_t a2, uint32_t a3, uint32_t a4, uint32_t a5)
+{
+       uint32_t ret;
+    asm volatile(
+            "pushl %%ebp\n\t"
+                       "pushl %%esi\n\t"
+            "movl %%esp, %%ebp\n\t"
+            "leal after_sysenter, %%esi\n\t"
+            "sysenter\n\t"
+            "after_sysenter:\n\t"
+                       "popl %%esi\n\t"
+            "popl %%ebp\n\t"
+            :"=a" (ret)
+            : "a" (num),
+                "d" (a1),
+                "c" (a2),
+                "b" (a3),
+                "D" (a4)
+        : "cc", "memory", "%esp");
+       return ret;
+}
+
+static uint32_t
+syscall_trap(int num, uint32_t a1, uint32_t a2, uint32_t a3, uint32_t a4, uint32_t a5)
+{
+       uint32_t ret;
+       asm volatile("int %1\n"
+               : "=a" (ret)
+               : "i" (T_SYSCALL),
+                 "a" (num),
+                 "d" (a1),
+                 "c" (a2),
+                 "b" (a3),
+                 "D" (a4),
+                 "S" (a5)
+               : "cc", "memory");
+
+       return ret;
+}
+
+/* Experiment Rappers.  Like Snoop Dogg. */
+void null_wrapper(uint32_t iters)
+{
+       for (int i = 0; i < iters; i++)
+               null();
+}
+
+void null_async_wrapper(uint32_t iters)
+{
+       async_desc_t *desc;
+       async_rsp_t rsp;
+
+       for (int i = 0; i < iters; i++)
+               null_async(&desc);
+       for (int i = 0; i < iters; i++)
+               waiton_async_call(desc, &rsp);
+}
+
+void sysenter_wrapper(uint32_t iters)
+{
+       for (int i = 0; i < iters; i++)
+               syscall_sysenter(666, 0, 0, 0, 0, 0);
+}
+
+void systrap_wrapper(uint32_t iters)
+{
+       for (int i = 0; i < iters; i++)
+               syscall_trap(666, 0, 0, 0, 0, 0);
+}
+
+void buster_sync_wrapper(uint32_t iters, uint32_t num_writes, uint32_t flags)
+{
+       for (int i = 0; i < iters; i++)
+               cache_buster(num_writes, 0, flags);
+}
+
+void buster_async_wrapper(uint32_t iters, uint32_t num_writes, uint32_t flags)
+{
+       async_desc_t *desc1;
+       async_rsp_t rsp1;
+       for (int i = 0; i < iters; i++){
+               cache_buster_async(&desc1, num_writes, 0, flags);
+       }
+       waiton_async_call(desc1, &rsp1);
+}
+
+void buster_thruput_sync(uint32_t flags, char* text)
+{
+       uint64_t thruput_ticks = 0;;    
+       for (int i = 1; i < MAX_CACHELINE_WRITES; i= i*2) {
+               // BEGIN barrier
+               waiton_barrier(bar);
+               thruput_ticks = start_timing(); 
+               // Sync Buster throughput
+               buster_sync_wrapper(100, i, flags);
+               waiton_barrier(bar);
+               thruput_ticks = stop_timing(thruput_ticks);     
+               printk("XME:BUSTER:%d:S:%s:%d:W:%llu\n", corecount, text, i, thruput_ticks);
+       }
+}
+
+void buster_thruput_async(uint32_t flags, char* text)
+{
+       uint64_t thruput_ticks = 0;;    
+       for (int i = 1; i < MAX_CACHELINE_WRITES; i= i*2) {
+               // BEGIN barrier
+               waiton_barrier(bar);
+               thruput_ticks = start_timing(); 
+               buster_async_wrapper(100, i, flags);
+               waiton_barrier(bar);
+               thruput_ticks = stop_timing(thruput_ticks);     
+               printk("XME:BUSTER:%d:A:%s:%d:W:%llu\n", corecount, text, i, thruput_ticks);
+       }
+}
+
+void buster_latency_sync(uint32_t flags, char* text) 
+{
+       uint64_t tick;
+       for (int i = 1; i < MAX_CACHELINE_WRITES; i=i*2) { // 1 - 128
+               measure_func_runtime(buster_sync_wrapper, 100,  i , flags);
+               tick = measure_func_runtime(buster_sync_wrapper, 1,  i , flags);
+               printk("XME:BUSTER:%d:S:%s:LATENCY:%d:W:%llu\n", corecount, text,i, tick);
+       }
+}
+
+void buster_latency_async(uint32_t flags, char* text) 
+{
+       uint64_t tick;
+       for (int i = 1; i < MAX_CACHELINE_WRITES; i=i*2) { // 1 - 128
+               measure_func_runtime(buster_async_wrapper, 100,  i , flags);
+               tick = measure_func_runtime(buster_async_wrapper, 1,  i , flags);
+               printk("XME:BUSTER:%d:A:%s:LATENCY:%d:W:%llu\n", corecount, text,i, tick);
+       }
+}
+
+/* Finally, begin the test */
 int main(int argc, char** argv)
 {
+       uint32_t coreid = getcpuid();
+       uint64_t ticks;
+       
+       #define MAX_ITERS 10
+
+       disable_irq();
+       switch(*job_to_run) {
+               case 0:
+                       /* NULL SYSCALLS */
+                       if (coreid == 2)
+                               cprintf("Null Syscall Tests\n");
+                       // Sync Null Syscalls
+                       sys_cache_invalidate();
+                       ticks = measure_func_runtime(null_wrapper, 1);
+                       printk("XME:Null:S:1:1:C:%llu\n", ticks);
+                       for (int i = 1; i <= MAX_ITERS; i++) {
+                               ticks = measure_func_runtime(null_wrapper, i);
+                               printk("XME:Null:S:1:%d:W:%llu\n", i, ticks);
+                       }
+
+                       // Async Null Syscalls
+                       sys_cache_invalidate();
+                       ticks = measure_func_runtime(null_async_wrapper, 1);
+                       printk("XME:Null:A:1:1:C:%llu\n", ticks);
+                       for (int i = 1; i <= MAX_ITERS; i++) {
+                               ticks = measure_func_runtime(null_async_wrapper, i);
+                               printk("XME:Null:A:1:%d:W:%llu\n", i, ticks);
+                       }
+
+                       // raw sysenter
+                       sys_cache_invalidate();
+                       ticks = measure_func_runtime(sysenter_wrapper, 1);
+                       printk("XME:SYSE:S:1:1:C:%llu\n", ticks);
+                       for (int i = 1; i <= MAX_ITERS; i++) {
+                               ticks = measure_func_runtime(sysenter_wrapper, i);
+                               printk("XME:SYSE:S:1:%d:W:%llu\n", i, ticks);
+                       }
+
+                       // raw trap
+                       sys_cache_invalidate();
+                       ticks = measure_func_runtime(systrap_wrapper, 1);
+                       printk("XME:TRAP:S:1:1:C:%llu\n", ticks);
+                       for (int i = 1; i <= MAX_ITERS; i++) {
+                               ticks = measure_func_runtime(systrap_wrapper, i);
+                               printk("XME:TRAP:S:1:%d:W:%llu\n", i, ticks);
+                       }
+
+                       break;
+               case 1:
+               case 2:
+               case 3:
+               case 4:
+               case 5:
+               case 6:
+               case 7:
+               case 8:
+                       corecount = (*job_to_run);
+                       if (coreid == 2)
+                               cprintf("Sync Buster Tests for job: %d\n", *job_to_run);
+                       waiton_barrier(bar);
+                       sys_cache_invalidate();
+                       // Sync Buster latency
+                       buster_latency_sync(BUSTER_SHARED, "NOLOCK:NOSTRIDE");
+                       buster_latency_sync(BUSTER_SHARED|BUSTER_LOCKED, "LOCKED:NOSTRIDE");
+                       buster_latency_sync(BUSTER_SHARED|BUSTER_LOCKED|BUSTER_STRIDED, "LOCKED:STRIDE");
+                       buster_latency_sync(BUSTER_SHARED|BUSTER_STRIDED, "NOLOCK:STRIDE");
+                       // Sync Buster thruput
+                       buster_thruput_sync(BUSTER_SHARED|BUSTER_LOCKED, "LOCKED:NOSTRIDE");
+                       buster_thruput_sync(BUSTER_SHARED|BUSTER_LOCKED|BUSTER_STRIDED, "LOCKED:STRIDE");
+                       buster_thruput_sync(BUSTER_SHARED, "UNLOCKED:NOSTRIDE");
+                       buster_thruput_sync(BUSTER_SHARED|BUSTER_STRIDED, "UNLOCKED:STRIDE");
+                       break;
+               case 9:
+               case 10:
+               case 11:
+               case 12:
+               case 13:
+               case 14:
+                       corecount = (*job_to_run) - 8;
+                       if (coreid == 2)
+                               cprintf("Async Buster Tests for job: %d\n", *job_to_run);
+                       
+                       buster_latency_async(BUSTER_SHARED, "NOLOCK:NOSTRIDE");
+                       buster_latency_async(BUSTER_SHARED|BUSTER_LOCKED, "LOCKED:NOSTRIDE");
+                       buster_latency_async(BUSTER_SHARED|BUSTER_LOCKED|BUSTER_STRIDED, "LOCKED:STRIDE");
+                       buster_latency_async(BUSTER_SHARED|BUSTER_STRIDED, "NOLOCK:STRIDE");
+                       if (coreid == 2)
+                               cprintf("Async Buster Thruput Tests\n");
+                       buster_thruput_async(BUSTER_SHARED|BUSTER_LOCKED, "LOCKED:NOSTRIDE");
+                       buster_thruput_async(BUSTER_SHARED|BUSTER_LOCKED|BUSTER_STRIDED, "LOCKED:STRIDE");
+                       buster_thruput_async(BUSTER_SHARED, "UNLOCKED:NOSTRIDE");
+                       buster_thruput_async(BUSTER_SHARED|BUSTER_STRIDED, "UNLOCKED:STRIDE");
+                       break;
+               default:
+                       if (coreid == 2)
+                               cprintf("Bug in Job Selection!!!\n");
+       }
+       waiton_barrier(bar);
+       //cprintf("Env %x, on core %d, finishes\n", env->env_id, coreid);
+       return 0;
+       /* Options for Cache Buster:
+        * BUSTER_SHARED
+        * BUSTER_STRIDED
+        * BUSTER_LOCKED
+        * BUSTER_PRINT_TICKS
+        */
+
        /*
-       TAGGED_TIMING_BEGIN(tst);
        async_desc_t *desc1, *desc2;
        async_rsp_t rsp1, rsp2;
-       cprintf ("training result %llu\n", timing_overhead);
-       cache_buster_async(&desc1, 20, 0xdeadbeef);
-       cache_buster_async(&desc2, 10, 0xcafebabe);
+       cache_buster_async(&desc1, 20, 5, BUSTER_LOCKED | BUSTER_SHARED);
+       cache_buster_async(&desc2, 10, 0, BUSTER_STRIDED);
        waiton_async_call(desc1, &rsp1);
        waiton_async_call(desc2, &rsp2);
+       cache_buster(10, 0, BUSTER_STRIDED | BUSTER_LOCKED);
+       TAGGED_TIMING_BEGIN(tst);
        //measure_function(sys_null(), NUM_ITERATIONS, "sys_null");
        //measure_function(asm volatile("nop;"), NUM_ITERATIONS, "nop");
        //measure_function(cprintf("Reg Sync call  \n"), 10, "printf");
@@ -38,5 +302,4 @@ int main(int argc, char** argv)
        // Spin to make sure we don't have any resources deallocated before done
        while(1);
        */
-       cprintf("Env %x says hi and quits\n", env->env_id);
 }
index 9457c52..623a53d 100644 (file)
@@ -34,7 +34,6 @@
        __measure_runtime(func(__VA_ARGS__));                                      \
 })
 
-
 #define measure_function(func, iters, name)                                    \
 ({                                                                             \
        uint64_t ticks;                                                            \