Index: doc/theses/colby_parsons_MMAth/benchmarks/channels/cfa/contend.cfa
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/channels/cfa/contend.cfa	(revision 2f6a9391fb8df95071d5a97f144de723657b7e5d)
+++ doc/theses/colby_parsons_MMAth/benchmarks/channels/cfa/contend.cfa	(revision 2f6a9391fb8df95071d5a97f144de723657b7e5d)
@@ -0,0 +1,211 @@
+#include <locks.hfa>
+#include <fstream.hfa>
+#include <stdio.h>
+#include <channel.hfa>
+#include <thread.hfa>
+#include <time.hfa>
+#include <string.h>
+
+// user defines this
+#define BIG 1
+
+owner_lock o;
+
+unsigned long long total_operations = 0;
+
+struct bigObject {
+    size_t a;
+    size_t b;
+    size_t c;
+    size_t d;
+    size_t e;
+    size_t f;
+    size_t g;
+    size_t h;
+};
+
+void ?{}( bigObject & this, size_t i ) with(this) { a = i; b = i; c = i; d = i; e = i; f = i; g = i; h = i; }
+void ?{}( bigObject & this ) { this{0}; }
+
+#ifdef BIG
+typedef channel( bigObject ) Channel;
+#else
+typedef channel( size_t ) Channel;
+#endif
+
+Channel * channels;
+
+volatile bool cons_done = false, prod_done = false;
+volatile int cons_done_count = 0;
+size_t cons_check = 0, prod_check = 0;
+
+thread Consumer {
+    size_t i;
+};
+static inline void ?{}( Consumer & c, size_t i, cluster & clu ) {
+    ((thread &)c){ clu };
+    c.i = i; 
+}
+void main(Consumer & this) {
+    unsigned long long runs = 0;
+    size_t my_check = 0;
+    for ( ;; ) {
+        if ( cons_done ) break;
+        #ifdef BIG
+        bigObject j = remove( channels[ this.i ] );
+        my_check = my_check ^ (j.a + j.b + j.c + j.d + j.d + j.e + j.f + j.g + j.h);
+        #else
+        size_t j = remove( channels[ this.i ] );
+        my_check = my_check ^ j;
+        #endif
+        
+        if ( !prod_done ) runs++;
+    }
+    lock(o);
+    total_operations += runs;
+    cons_done_count++;
+    cons_check = cons_check ^ my_check;
+    // sout | "C: " | runs;
+    unlock(o);
+}
+
+thread Producer {
+    size_t i;
+};
+static inline void ?{}( Producer & p, size_t i, cluster & clu ) {
+    ((thread &)p){ clu };
+    p.i = i;
+}
+void main(Producer & this) {
+    unsigned long long runs = 0;
+    size_t my_check = 0;
+    for ( ;; ) {
+        if ( prod_done ) break;
+        #ifdef BIG
+        bigObject j{(size_t)runs};
+        insert( channels[ this.i ], j );
+        my_check = my_check ^ (j.a + j.b + j.c + j.d + j.d + j.e + j.f + j.g + j.h);
+        #else
+        insert( channels[ this.i ], (size_t)runs );
+        my_check = my_check ^ ((size_t)runs);
+        #endif
+        runs++;
+    }
+    lock(o);
+    total_operations += runs;
+    prod_check = prod_check ^ my_check;
+    // sout | "P: " | runs;
+    unlock(o);
+}
+
+int test( size_t Processors, size_t Channels, size_t Producers, size_t Consumers, size_t ChannelSize ) {
+    size_t Clusters = Processors;
+    // create a cluster
+    cluster clus[Clusters];
+    processor * proc[Processors];
+    for ( i; Processors ) {
+        (*(proc[i] = alloc())){clus[i % Clusters]};
+    }
+
+    channels = aalloc( Channels );
+
+    // sout | "Processors: " | Processors | " ProdsPerChan: " | Producers | " ConsPerChan: " | Consumers | "Channels: " | Channels | " Channel Size: " | ChannelSize;
+    
+    for ( i; Channels ) {
+        channels[i]{ ChannelSize };
+    }
+
+    // sout | "start";
+    Consumer * c[Consumers * Channels];
+    Producer * p[Producers * Channels];
+
+    for ( i; Consumers * Channels ) {
+        (*(c[i] = alloc())){ i % Channels, clus[i % Clusters] };
+    }
+
+    for ( i; Producers * Channels ) {
+        (*(p[i] = alloc())){ i % Channels, clus[i % Clusters] };
+    }
+
+    sleep(10`s);
+    prod_done = true;
+
+    for ( i; Producers * Channels ) {
+        delete(p[i]);
+    }
+
+    // sout | "prods";
+    cons_done = true;
+    while( cons_done_count != Consumers * Channels ) {
+        for ( i; Channels ) {
+            if ( has_waiters( channels[i] ) ){
+                #ifdef BIG
+                bigObject b{0};
+                insert( channels[i], b );
+                #else
+                insert( channels[i], 0 );
+                #endif
+            }
+        }
+        
+    }
+
+    // sout | "cons";
+    for ( i; Consumers * Channels ) {
+        delete(c[i]);
+    }
+
+    // sout | "flush";
+    for ( i; Channels ) {
+        for ( ;; ) {
+            if ( get_count( channels[i] ) > 0 ) {
+                #ifdef BIG
+                bigObject j = remove( channels[ i ] );
+                cons_check = cons_check ^ (j.a + j.b + j.c + j.d + j.d + j.e + j.f + j.g + j.h);
+                #else
+                size_t j = remove( channels[ i ] );
+                cons_check = cons_check ^ j;
+                #endif
+            } else break;
+        }
+    }
+
+    adelete( channels );
+    sout | total_operations;
+    if ( cons_check != prod_check )
+        sout | "CHECKSUM MISMATCH !!!";
+    // print_stats_now( *active_cluster(), CFA_STATS_READY_Q);
+
+    for ( i; Processors ) {
+        delete(proc[i]);
+    }
+    // sout | "done";
+    return 0;
+}
+
+int main( int argc, char * argv[] ) {
+    size_t Processors = 10, Channels = 1, Producers = 10, Consumers = 10, ChannelSize = 128;
+    switch ( argc ) {
+	  case 3:
+		if ( strcmp( argv[2], "d" ) != 0 ) {			// default ?
+			ChannelSize = atoi( argv[2] );
+		} // if
+	  case 2:
+		if ( strcmp( argv[1], "d" ) != 0 ) {			// default ?
+			Processors = atoi( argv[1] );
+			if ( Processors < 1 ) goto Usage;
+		} // if
+	  case 1:											// use defaults
+		break;
+	  default:
+	  Usage:
+		sout | "Usage: " | argv[0]
+             | " [ processors (> 0) | 'd' (default " | Processors
+			 | ") ] [ channel size (>= 0) | 'd' (default " | ChannelSize
+			 | ") ]" ;
+		exit( EXIT_FAILURE );
+	} // switch
+    Producers = Processors;
+    Consumers = Processors;
+    test(Processors, Channels, Producers, Consumers, ChannelSize);
+}
Index: doc/theses/colby_parsons_MMAth/benchmarks/channels/go/contend.go
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/channels/go/contend.go	(revision 2f6a9391fb8df95071d5a97f144de723657b7e5d)
+++ doc/theses/colby_parsons_MMAth/benchmarks/channels/go/contend.go	(revision 2f6a9391fb8df95071d5a97f144de723657b7e5d)
@@ -0,0 +1,140 @@
+package main
+
+import (
+	"fmt"
+	"sync"
+	"time"
+	"runtime"
+	"os"
+	"strconv"
+)
+
+var Processors, Channels, ProdsPerChan, ConsPerChan, ChannelSize int = 1, 1, 1, 1, 128
+var cons_done, prod_done bool = false, false;
+var total_operations, cons_check, prod_check uint64 = 0, 0, 0
+var m sync.Mutex
+
+var prodJoin chan int = make(chan int, ProdsPerChan * Channels + 1)
+var consJoin chan int = make(chan int, ConsPerChan * Channels + 1)
+
+func consumer( channel chan uint64 ) {
+	var count uint64 = 0
+	var checksum uint64 = 0
+	for {
+		if cons_done { break }
+		j := <- channel
+		checksum = checksum ^ j
+		if ! prod_done { count++ }
+	}
+	m.Lock()
+	total_operations += count
+	cons_check = cons_check ^ checksum
+	// fmt.Print("C: ",count)
+	m.Unlock()
+	consJoin <- 0
+}
+
+func producer( channel chan uint64 ) {
+	var count uint64 = 0
+	var checksum uint64 = 0
+	for {
+		if prod_done { break }
+		checksum = checksum ^ count
+		channel <- count
+		count++
+	}
+	m.Lock()
+	total_operations += count
+	prod_check = prod_check ^ checksum
+	// fmt.Print("P: ",count, " ")
+	m.Unlock()
+	prodJoin <- 0
+}
+
+func usage() {
+	fmt.Printf( "Usage: %v " +
+		"[ processors (> 0) | 'd' (default %v) ] " +
+		"[ ChannelSize (> 0) | 'd' (default %v) ]\n",
+		os.Args[0], Processors, ChannelSize );
+	os.Exit( 1 );
+}
+
+func main() {
+	switch len( os.Args ) {
+		case 3:
+			if os.Args[2] != "d" {							// default ?
+				ChannelSize, _ = strconv.Atoi( os.Args[1] )
+					if ChannelSize < 0 { usage(); }
+			} // if
+		fallthrough
+		case 2:
+			if os.Args[1] != "d" {							// default ?
+				Processors, _ = strconv.Atoi( os.Args[1] )
+				if Processors < 1 { usage(); }
+			} // if
+		case 1:											// use defaults
+		default:
+		usage();
+	} // switch
+	runtime.GOMAXPROCS( Processors );
+	ProdsPerChan = Processors
+	ConsPerChan = Processors
+
+	// fmt.Println("Processors: ",Processors," Channels: ",Channels," ProdsPerChan: ",ProdsPerChan," ConsPerChan: ",ConsPerChan," Channel Size: ",ChannelSize)
+	
+	chans := make( [] chan uint64, Channels )
+	for i := range chans {
+		chans[i] = make(chan uint64, ChannelSize)
+	}
+	for i := range chans {
+		for j := 0; j < ProdsPerChan; j++ {
+			go producer( chans[i] )
+		}
+
+		for j := 0; j < ConsPerChan; j++ {
+			go consumer( chans[i] )
+		}
+	}
+		
+
+	// wait 10 seconds
+	time.Sleep(time.Second * 10)
+	// fmt.Println("prod done\n")
+	prod_done = true
+	for j := 0; j < ProdsPerChan * Channels ; j++ {
+		<-prodJoin
+	}
+	// fmt.Println("cons done\n")
+	cons_done = true
+	for i := range chans {
+		J: for j := 0; j < ConsPerChan; j++ {
+			select {
+				case chans[i] <- 0:
+					
+				default:
+					break J
+			}
+		}
+	}
+	for j := 0; j < ConsPerChan * Channels; j++{
+		<-consJoin
+	}
+	
+	// for i := range chans {
+	// 	L: for {
+	// 		select {
+	// 			case k := <-chans[i]:
+	// 				cons_check = cons_check ^ k
+	// 			default:
+	// 				break L
+	// 		}
+	// 	}
+	// }
+	if cons_check != prod_check {
+		fmt.Println("\nChecksum mismatch: Cons: %d, Prods: %d", cons_check, prod_check)
+	}
+	for i := range chans {
+		close(chans[i])
+	}
+    fmt.Println(total_operations)
+}
Index: doc/theses/colby_parsons_MMAth/benchmarks/channels/plotData.py
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/channels/plotData.py	(revision 2f6a9391fb8df95071d5a97f144de723657b7e5d)
+++ doc/theses/colby_parsons_MMAth/benchmarks/channels/plotData.py	(revision 2f6a9391fb8df95071d5a97f144de723657b7e5d)
@@ -0,0 +1,111 @@
+import os
+import sys
+import time
+import matplotlib.pyplot as plt
+import matplotlib.ticker as ticks
+import math
+from scipy import stats as st
+import numpy as np
+from enum import Enum
+from statistics import median
+
+import matplotlib
+matplotlib.use("pgf")
+matplotlib.rcParams.update({
+    "pgf.texsystem": "pdflatex",
+    'font.family': 'serif',
+    'text.usetex': True,
+    'pgf.rcfonts': False,
+})
+
+readfile = open(sys.argv[1], "r")
+
+machineName = ""
+
+if len(sys.argv) > 2:
+    machineName = sys.argv[2]
+
+# first line has num times per experiment
+line = readfile.readline()
+numTimes = int(line)
+
+# second line has processor args
+line = readfile.readline()
+procs = []
+for val in line.split():
+    procs.append(int(val))
+
+# 3rd line has num locks args
+line = readfile.readline()
+locks = []
+for val in line.split():
+    locks.append(int(val))
+
+# 4th line has number of variants
+line = readfile.readline()
+names = line.split()
+numVariants = len(names)
+
+lines = (line.rstrip() for line in readfile) # All lines including the blank ones
+lines = (line for line in lines if line) # Non-blank lines
+
+nameSet = False
+currLocks = -1 # default val
+count = 0
+procCount = 0
+currVariant = 0
+name = "Aggregate Lock"
+var_name = ""
+sendData = [0.0 for j in range(numVariants)]
+data = [[0.0 for i in range(len(procs))] for j in range(numVariants)]
+bars = [[[0.0 for i in range(len(procs))],[0.0 for k in range(len(procs))]] for j in range(numVariants)]
+tempData = [0.0 for i in range(numTimes)]
+for idx, line in enumerate(lines):
+    # print(line)
+    
+    if currLocks == -1:
+        lineArr = line.split()
+        currLocks = lineArr[-1]
+        continue
+
+    if line[0:5] == "cores":
+        continue
+
+    if not nameSet:
+        nameSet = True
+        continue
+    
+    lineArr = line.split()
+    tempData[count] = float(lineArr[-1])
+    count += 1
+    if count == numTimes:
+        currMedian = median( tempData )
+        data[currVariant][procCount] = currMedian
+        lower, upper = st.t.interval(0.95, numTimes - 1, loc=np.mean(tempData), scale=st.sem(tempData))
+        bars[currVariant][0][procCount] = currMedian - lower
+        bars[currVariant][1][procCount] = upper - currMedian
+        count = 0
+        procCount += 1
+
+        if procCount == len(procs):
+            procCount = 0
+            nameSet = False
+            currVariant += 1
+
+            if currVariant == numVariants:
+                fig, ax = plt.subplots()
+                plt.title(name + " Benchmark: " + str(currLocks) + " Locks")
+                plt.ylabel("Throughput (entries)")
+                plt.xlabel("Cores")
+                for idx, arr in enumerate(data):
+                    plt.errorbar( procs, arr, [bars[idx][0], bars[idx][1]], capsize=2, marker='o' )
+                plt.yscale("log")
+                plt.xticks(procs)
+                ax.legend(names)
+                # fig.savefig("plots/" + machineName + "Aggregate_Lock_" + str(currLocks) + ".png")
+                plt.savefig("plots/" + machineName + "Aggregate_Lock_" + str(currLocks) + ".pgf")
+                fig.clf()
+
+                # reset
+                currLocks = -1
+                currVariant = 0
Index: doc/theses/colby_parsons_MMAth/benchmarks/channels/run
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/channels/run	(revision 2f6a9391fb8df95071d5a97f144de723657b7e5d)
+++ doc/theses/colby_parsons_MMAth/benchmarks/channels/run	(revision 2f6a9391fb8df95071d5a97f144de723657b7e5d)
@@ -0,0 +1,226 @@
+#!/bin/bash -
+
+false=0; true=1
+
+# Usage: arch [ hostname ] returns hostname, cores, startcore
+#
+#   Define machine architecture based on starting socket, CPUs (cores) per socket, number of
+#   sockets, has hyperthreading.
+
+start=0
+
+arch() {
+	hostname=${1:-`hostname`}			# return value
+	hashyper=${true}					# assume machine has hyperthreads
+	if [ "${hostname}" = "plg2" ] ; then
+		startsocket=${start}
+		cps=16							# coresPerSocket
+		sockets=2
+		hashyper=${false}				# has no hyperthreads
+	elif [ "${hostname}" = "nasus" ] ; then
+		startsocket=${start}
+		cps=64							# coresPerSocket
+		sockets=2
+	elif [ "${hostname}" = "pyke" ] ; then
+		startsocket=${start}
+		cps=24							# coresPerSocket
+		sockets=2
+	elif [ "${hostname}" = "jax" ] ; then
+		startsocket=${start}
+		cps=24							# coresPerSocket
+		sockets=4
+	else
+		echo "unsupported host" ${hostname}
+		exit 1
+	fi
+	cores=$(( ${cps} * ${sockets} ))
+	startcore=$(( ${startsocket} * ${cps} ))
+}
+
+# Usage: affinity (global cps, sockets, startsocket, hashyper, cores, startcore, wrap)
+#   returns taskset argument
+#
+#   This routine assumes hyperthreading has only 2 hyperthreads per core.
+#
+#   If hyperthread scanning is used: processor units are assigned across the low-number hyperthreads
+#   of the socket's cores. When the low-number hyperthreads are filled, the high-number hyperhtreads
+#   are assigned across the socket's cores. Then the next socket is assigned.
+#
+#   If hyperthread wrapping is used: processor units are assigned in low/high-number pairs of
+#   hyperthreads across the socket's cores. Then the next socket is assigned.
+
+wrap=${false}							# set to control hyperthread assignment across socket cores
+
+affinity() {
+	if [ ${wrap} -eq ${true} -a ${hashyper} -eq ${false} ] ; then
+		echo "architecture does not support hyperthreading for wrapping"
+		exit 1
+	fi
+	taskset=""							# return value
+	set -- $(( ${1} - 1 ))				# decrement $1
+	if [ ${1} -eq 0 ] ; then taskset="${startcore}-${startcore}"; return; fi
+	if [ ${1} -ge $(( ${cps} * ( ${sockets} - ${startsocket} ) * ( ${hashyper} + 1 ) )) ] ; then # error
+		echo "not enough cores $(( ${cores} * ${sockets} )) for $(( ${1} + 1 )) starting at ${startcore}"
+		exit 1
+	fi
+	if [ ${hashyper} -eq ${false} ] ; then taskset="${startcore}-$(( ${1} + ${startcore} ))"; return; fi # no hyperthreads
+	start2=$(( ${startcore} + ${cores} ))
+	if [ ${wrap} -eq ${true} ] ; then 	# hyperthread wrapping
+		end1=$(( ${1} / 2 + ${startcore} ))
+		end2=$(( ${end1} + ${cores} ))
+		if [ $(( ${1} % 2 )) -eq 0 ] ; then
+			end2=$(( ${end2} - 1 ))
+		fi
+		taskset="${startcore}-${end1},${start2}-${end2}"
+	else								# hyperthread scanning
+		if [ ${1} -lt ${cps} ] ; then taskset="${startcore}-$(( ${1} + ${startcore} ))"; return; fi
+		filled=$(( ${1} / ( ${cps} * 2 ) * ${cps} ))
+		modulus=$(( ${1} % ( ${cps} * 2 ) ))	# leftover cores added to saturated sockets
+		if [ ${modulus} -gt ${cps} ] ; then
+			taskset="${startcore}-$(( ${startcore} + ${filled} + ${cps} - 1 )),${start2}-$(( ${start2} + ${filled} + ${modulus} % ${cps} ))"
+		else
+			taskset="${startcore}-$(( ${startcore} + ${filled} + ${modulus} )),${start2}-$(( ${start2} + ${filled} - 1 ))"
+		fi
+	fi
+}
+
+numtimes=11
+
+# locks=('-DLOCKS=L1' '-DLOCKS=L2' '-DLOCKS=L3' '-DLOCKS=L4' '-DLOCKS=L5' '-DLOCKS=L6' '-DLOCKS=L7' '-DLOCKS=L8')
+# locks='1 2 3 4 5 6 7 8'
+lock_flags=('-DLOCKS=L2' '-DLOCKS=L4' '-DLOCKS=L8')
+locks=('2' '4' '8')
+
+num_threads='2 4 8 16 24 32'
+# num_threads='2 4 8'
+
+# toggle benchmarks
+order=${true}
+rand=${true}
+baseline=${true}
+
+runCFA=${true}
+runCPP=${true}
+# runCFA=${false}
+# runCPP=${false}
+
+cfa=~/cfa-cc/driver/cfa
+cpp=g++
+
+# Helpers to minimize code duplication
+
+# repeats a command ${numtimes}
+preprint=''
+repeat_command() {
+    t=1
+    while [ ${t} -le ${numtimes} ] ; do
+        echo -n -e ${preprint}
+        "${@}"
+        t=`expr ${t} + 1`
+    done
+}
+
+# prints the leading info for a given run of a variant
+print_header() {
+    echo ${1}':'
+    echo -e "cores\tthroughput (entries)"
+}
+
+# runs the current benchmark with provided args
+# only works for standard-run benchmarks (not Akka)
+# must split into pre and post args to be able to supply val of p
+pre_args=''
+post_args=''
+single_run() {
+    affinity ${1}
+    preprint="${1}\t"
+    repeat_command taskset -c ${taskset} ./a.${hostname} ${pre_args} ${1} ${post_args}
+}
+
+# runs the current bench for all processor vals
+# works for standard benchs that dont need to set a config file (not Akka or CAF)
+run_bench() {
+    for p in ${num_threads} ; do
+        single_run ${p}
+    done
+}
+
+arch # get hostname
+
+# set up leading info for python script
+echo $numtimes
+echo $num_threads
+
+for i in ${!locks[@]}; do
+        echo -n ${locks[$i]}' '
+done
+echo ""
+
+if [ ${runCFA} -eq ${true} ] && [ ${order} -eq ${true} ]; then
+    echo -n 'CFA-order '
+fi
+if [ ${runCPP} -eq ${true} ] && [ ${order} -eq ${true} ]; then
+    echo -n 'CPP-order '
+fi
+if [ ${runCFA} -eq ${true} ] && [ ${baseline} -eq ${true} ]; then
+    echo -n 'CFA-baseline '
+fi
+if [ ${runCPP} -eq ${true} ] && [ ${baseline} -eq ${true} ]; then
+    echo -n 'CPP-baseline '
+fi
+if [ ${runCFA} -eq ${true} ] && [ ${rand} -eq ${true} ]; then
+    echo -n 'CFA-rand '
+fi
+if [ ${runCPP} -eq ${true} ] && [ ${rand} -eq ${true} ]; then
+    echo -n 'CPP-rand '
+fi
+echo ""
+
+# done printing header info for output
+
+# cfa flags
+cfa_flags='-quiet -O3 -nodebug -DNDEBUG'
+
+# cpp flagse
+cpp_flags='-O3 -std=c++17 -lpthread -pthread -DNDEBUG'
+
+# run the benchmarks
+
+run_order() {
+    post_args=${1}
+
+    if [ ${runCFA} -eq ${true} ] ; then
+        cd cfa # CFA RUN
+        print_header 'CFA-'${3}
+        ${cfa} ${cfa_flags} ${2} ${3}.cfa -o a.${hostname} > /dev/null 2>&1
+        run_bench
+        rm a.${hostname}
+        cd - > /dev/null
+    fi # done CFA
+
+    if [ ${runCPP} -eq ${true} ] ; then
+        cd cpp # CPP RUN
+        print_header 'CPP-'${3}
+        ${cpp} ${cpp_flags} ${2} ${3}.cc -o a.${hostname} > /dev/null 2>&1
+        run_bench
+        rm a.${hostname}
+        cd - > /dev/null
+    fi # done CPP
+}
+
+# /usr/bin/time -f "%Uu %Ss %Er %Mkb"
+
+for i in ${!locks[@]}; do
+    echo "locks: "${locks[$i]}
+    if [ ${order} -eq ${true} ] ; then
+        run_order ${locks[$i]} ${lock_flags[$i]} 'order'
+    fi
+    if [ ${baseline} -eq ${true} ] ; then
+        run_order ${locks[$i]} ${lock_flags[$i]} 'baseline'
+    fi
+    if [ ${rand} -eq ${true} ] ; then
+        run_order ${locks[$i]} '-DLOCKS=L8' 'rand'
+    fi
+done
+
+
