Changeset eb47a80 for doc/theses/colby_parsons_MMAth/benchmarks
- Timestamp:
- Mar 30, 2023, 9:48:06 PM (3 years ago)
- Branches:
- ADT, ast-experimental, master, stuck-waitfor-destruct
- Children:
- 0b66ef9
- Parents:
- 70056ed (diff), 6e83384 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- doc/theses/colby_parsons_MMAth/benchmarks/channels
- Files:
-
- 19 added
- 3 edited
- 1 moved
-
cfa/barrier.cfa (added)
-
cfa/churn.cfa (added)
-
cfa/contend.cfa (modified) (9 diffs)
-
cfa/daisy_chain.cfa (added)
-
cfa/hot_potato.cfa (added)
-
cfa/ping_pong.cfa (added)
-
cfa/pub_sub.cfa (added)
-
go/barrier/barrier.go (added)
-
go/barrier/go.mod (added)
-
go/churn/churn.go (added)
-
go/churn/go.mod (added)
-
go/contend/contend.go (moved) (moved from doc/theses/colby_parsons_MMAth/benchmarks/channels/go/contend.go ) (3 diffs)
-
go/contend/go.mod (added)
-
go/daisy_chain/daisy_chain.go (added)
-
go/daisy_chain/go.mod (added)
-
go/hot_potato/go.mod (added)
-
go/hot_potato/hot_potato.go (added)
-
go/ping_pong/go.mod (added)
-
go/ping_pong/ping_pong.go (added)
-
go/pub_sub/go.mod (added)
-
go/pub_sub/pub_sub.go (added)
-
plotData.py (modified) (4 diffs)
-
run (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/colby_parsons_MMAth/benchmarks/channels/cfa/contend.cfa
r70056ed reb47a80 8 8 9 9 // user defines this 10 #define BIG 110 // #define BIG 1 11 11 12 12 owner_lock o; 13 13 14 unsigned long longtotal_operations = 0;14 size_t total_operations = 0; 15 15 16 16 struct bigObject { … … 36 36 Channel * channels; 37 37 38 volatilebool cons_done = false, prod_done = false;38 bool cons_done = false, prod_done = false; 39 39 volatile int cons_done_count = 0; 40 40 size_t cons_check = 0, prod_check = 0; … … 48 48 } 49 49 void main(Consumer & this) { 50 unsigned long longruns = 0;50 size_t runs = 0; 51 51 size_t my_check = 0; 52 52 for ( ;; ) { … … 78 78 } 79 79 void main(Producer & this) { 80 unsigned long longruns = 0;80 size_t runs = 0; 81 81 size_t my_check = 0; 82 size_t my_id = this.i; 82 83 for ( ;; ) { 83 84 if ( prod_done ) break; 84 85 #ifdef BIG 85 86 bigObject j{(size_t)runs}; 86 insert( channels[ this.i], j );87 insert( channels[ my_id ], j ); 87 88 my_check = my_check ^ (j.a + j.b + j.c + j.d + j.d + j.e + j.f + j.g + j.h); 88 89 #else 89 insert( channels[ this.i], (size_t)runs );90 insert( channels[ my_id ], (size_t)runs ); 90 91 my_check = my_check ^ ((size_t)runs); 91 92 #endif … … 99 100 } 100 101 101 int test( size_t Processors, size_t Channels, size_t Producers, size_t Consumers, size_t ChannelSize ) {102 size_t Clusters = Processors;102 static inline int test( size_t Processors, size_t Channels, size_t Producers, size_t Consumers, size_t ChannelSize ) { 103 size_t Clusters = 1; 103 104 // create a cluster 104 105 cluster clus[Clusters]; 105 106 processor * proc[Processors]; 106 107 for ( i; Processors ) { 107 (*(proc[i] = alloc())){clus[i % Clusters]};108 (*(proc[i] = malloc())){clus[i % Clusters]}; 108 109 } 109 110 … … 120 121 Producer * p[Producers * Channels]; 121 122 122 for ( i; Consumers * Channels ) { 123 (*(c[i] = alloc())){ i % Channels, clus[i % Clusters] }; 124 } 125 126 for ( i; Producers * Channels ) { 127 (*(p[i] = alloc())){ i % Channels, clus[i % Clusters] }; 123 for ( j; Channels ) { 124 for ( i; Producers ) { 125 (*(p[i] = malloc())){ j, clus[j % Clusters] }; 126 } 127 128 for ( i; Consumers ) { 129 (*(c[i] = malloc())){ j, clus[j % Clusters] }; 130 } 128 131 } 129 132 … … 148 151 } 149 152 } 150 151 153 } 152 154 … … 185 187 186 188 int main( int argc, char * argv[] ) { 187 size_t Processors = 1 0, Channels = 1, Producers = 10, Consumers = 10, ChannelSize = 128;189 size_t Processors = 1, Channels = 1, Producers = 1, Consumers = 1, ChannelSize = 128; 188 190 switch ( argc ) { 189 191 case 3: … … 206 208 exit( EXIT_FAILURE ); 207 209 } // switch 208 Producers = Processors ;209 Consumers = Processors ;210 Producers = Processors / 2; 211 Consumers = Processors / 2; 210 212 test(Processors, Channels, Producers, Consumers, ChannelSize); 211 213 } -
doc/theses/colby_parsons_MMAth/benchmarks/channels/go/contend/contend.go
r70056ed reb47a80 64 64 case 3: 65 65 if os.Args[2] != "d" { // default ? 66 ChannelSize, _ = strconv.Atoi( os.Args[ 1] )66 ChannelSize, _ = strconv.Atoi( os.Args[2] ) 67 67 if ChannelSize < 0 { usage(); } 68 68 } // if … … 78 78 } // switch 79 79 runtime.GOMAXPROCS( Processors ); 80 ProdsPerChan = Processors 81 ConsPerChan = Processors 80 ProdsPerChan = Processors /2 81 ConsPerChan = Processors / 2 82 82 83 83 // fmt.Println("Processors: ",Processors," Channels: ",Channels," ProdsPerChan: ",ProdsPerChan," ConsPerChan: ",ConsPerChan," Channel Size: ",ChannelSize) … … 108 108 cons_done = true 109 109 for i := range chans { 110 J: for j := 0; j < ConsPerChan; j++{110 L: for { 111 111 select { 112 case chans[i] <- 0:113 112 case k := <-chans[i]: 113 cons_check = cons_check ^ k 114 114 default: 115 break J115 break L 116 116 } 117 117 } 118 118 } 119 for i := range chans { 120 close(chans[i]) 121 } 122 119 123 for j := 0; j < ConsPerChan * Channels; j++{ 120 124 <-consJoin 121 125 } 122 126 123 // for i := range chans { 124 // L: for { 125 // select { 126 // case k := <-chans[i]: 127 // cons_check = cons_check ^ k 128 // default: 129 // break L 130 // } 131 // } 132 // } 127 133 128 if cons_check != prod_check { 134 129 fmt.Println("\nChecksum mismatch: Cons: %d, Prods: %d", cons_check, prod_check) 135 130 } 136 for i := range chans {137 close(chans[i])138 }139 131 fmt.Println(total_operations) 140 132 } -
doc/theses/colby_parsons_MMAth/benchmarks/channels/plotData.py
r70056ed reb47a80 36 36 procs.append(int(val)) 37 37 38 # 3rd line has num locks args 39 line = readfile.readline() 40 locks = [] 41 for val in line.split(): 42 locks.append(int(val)) 43 44 # 4th line has number of variants 38 # 3rd line has number of variants 45 39 line = readfile.readline() 46 40 names = line.split() … … 50 44 lines = (line for line in lines if line) # Non-blank lines 51 45 46 class Bench(Enum): 47 Unset = 0 48 Contend = 1 49 Zero = 2 50 Barrier = 3 51 Churn = 4 52 Daisy_Chain = 5 53 Hot_Potato = 6 54 Pub_Sub = 7 55 52 56 nameSet = False 53 curr Locks = -1# default val57 currBench = Bench.Unset # default val 54 58 count = 0 55 59 procCount = 0 56 60 currVariant = 0 57 name = " Aggregate Lock"61 name = "" 58 62 var_name = "" 59 63 sendData = [0.0 for j in range(numVariants)] … … 64 68 # print(line) 65 69 66 if currLocks == -1: 67 lineArr = line.split() 68 currLocks = lineArr[-1] 70 if currBench == Bench.Unset: 71 if line == "contend:": 72 name = "Contend" 73 currBench = Bench.Contend 74 elif line == "zero:": 75 name = "Zero" 76 currBench = Bench.Zero 77 elif line == "barrier:": 78 name = "Barrier" 79 currBench = Bench.Barrier 80 elif line == "churn:": 81 name = "Churn" 82 currBench = Bench.Churn 83 elif line == "daisy_chain:": 84 name = "Daisy_Chain" 85 currBench = Bench.Daisy_Chain 86 elif line == "hot_potato:": 87 name = "Hot_Potato" 88 currBench = Bench.Hot_Potato 89 elif line == "pub_sub:": 90 name = "Pub_Sub" 91 currBench = Bench.Pub_Sub 92 else: 93 print("Expected benchmark name") 94 print("Line: " + line) 95 sys.exit() 69 96 continue 70 97 … … 95 122 if currVariant == numVariants: 96 123 fig, ax = plt.subplots() 97 plt.title(name + " Benchmark : " + str(currLocks) + " Locks")98 plt.ylabel("Throughput ( entries)")124 plt.title(name + " Benchmark") 125 plt.ylabel("Throughput (channel operations)") 99 126 plt.xlabel("Cores") 100 127 for idx, arr in enumerate(data): 101 128 plt.errorbar( procs, arr, [bars[idx][0], bars[idx][1]], capsize=2, marker='o' ) 129 102 130 plt.yscale("log") 131 # plt.ylim(1, None) 132 # ax.get_yaxis().set_major_formatter(ticks.ScalarFormatter()) 133 # else: 134 # plt.ylim(0, None) 103 135 plt.xticks(procs) 104 136 ax.legend(names) 105 # fig.savefig("plots/" + machineName + "Aggregate_Lock_" + str(currLocks)+ ".png")106 plt.savefig("plots/" + machineName + "Aggregate_Lock_" + str(currLocks)+ ".pgf")137 # fig.savefig("plots/" + machineName + name + ".png") 138 plt.savefig("plots/" + machineName + name + ".pgf") 107 139 fig.clf() 108 140 109 141 # reset 110 curr Locks = -1142 currBench = Bench.Unset 111 143 currVariant = 0 -
doc/theses/colby_parsons_MMAth/benchmarks/channels/run
r70056ed reb47a80 85 85 } 86 86 87 numtimes=11 88 89 # locks=('-DLOCKS=L1' '-DLOCKS=L2' '-DLOCKS=L3' '-DLOCKS=L4' '-DLOCKS=L5' '-DLOCKS=L6' '-DLOCKS=L7' '-DLOCKS=L8') 90 # locks='1 2 3 4 5 6 7 8' 91 lock_flags=('-DLOCKS=L2' '-DLOCKS=L4' '-DLOCKS=L8') 92 locks=('2' '4' '8') 87 numtimes=5 93 88 94 89 num_threads='2 4 8 16 24 32' 95 # num_threads='2 4 8'90 # num_threads='2' 96 91 97 92 # toggle benchmarks 98 order=${true} 99 rand=${true} 100 baseline=${true} 93 zero=${false} 94 contend=${true} 95 barrier=${false} 96 churn=${false} 97 daisy_chain=${false} 98 hot_potato=${false} 99 pub_sub=${false} 101 100 102 101 runCFA=${true} 103 run CPP=${true}102 runGO=${true} 104 103 # runCFA=${false} 105 # run CPP=${false}104 # runGO=${false} 106 105 107 106 cfa=~/cfa-cc/driver/cfa 108 cpp=g++109 107 110 108 # Helpers to minimize code duplication … … 152 150 echo $num_threads 153 151 154 for i in ${!locks[@]}; do 155 echo -n ${locks[$i]}' ' 156 done 157 echo "" 158 159 if [ ${runCFA} -eq ${true} ] && [ ${order} -eq ${true} ]; then 160 echo -n 'CFA-order ' 161 fi 162 if [ ${runCPP} -eq ${true} ] && [ ${order} -eq ${true} ]; then 163 echo -n 'CPP-order ' 164 fi 165 if [ ${runCFA} -eq ${true} ] && [ ${baseline} -eq ${true} ]; then 166 echo -n 'CFA-baseline ' 167 fi 168 if [ ${runCPP} -eq ${true} ] && [ ${baseline} -eq ${true} ]; then 169 echo -n 'CPP-baseline ' 170 fi 171 if [ ${runCFA} -eq ${true} ] && [ ${rand} -eq ${true} ]; then 172 echo -n 'CFA-rand ' 173 fi 174 if [ ${runCPP} -eq ${true} ] && [ ${rand} -eq ${true} ]; then 175 echo -n 'CPP-rand ' 152 if [ ${runCFA} -eq ${true} ]; then 153 echo -n 'CFA ' 154 fi 155 if [ ${runGO} -eq ${true} ]; then 156 echo -n 'Go ' 176 157 fi 177 158 echo "" … … 182 163 cfa_flags='-quiet -O3 -nodebug -DNDEBUG' 183 164 184 # cpp flagse185 cpp_flags='-O3 -std=c++17 -lpthread -pthread -DNDEBUG'186 187 165 # run the benchmarks 188 166 189 run_ order() {167 run_contend() { 190 168 post_args=${1} 191 169 192 170 if [ ${runCFA} -eq ${true} ] ; then 193 171 cd cfa # CFA RUN 194 print_header 'CFA -'${3}195 ${cfa} ${cfa_flags} ${2} ${3}.cfa -o a.${hostname} > /dev/null 2>&1172 print_header 'CFA' 173 ${cfa} ${cfa_flags} ${2}.cfa -o a.${hostname} > /dev/null 2>&1 196 174 run_bench 197 175 rm a.${hostname} … … 199 177 fi # done CFA 200 178 201 if [ ${run CPP} -eq ${true} ] ; then202 cd cpp # CPPRUN203 print_header ' CPP-'${3}204 ${cpp} ${cpp_flags} ${2} ${3}.cc-o a.${hostname} > /dev/null 2>&1179 if [ ${runGO} -eq ${true} ] ; then 180 cd go/${2} # Go RUN 181 print_header 'Go' 182 go build -o a.${hostname} > /dev/null 2>&1 205 183 run_bench 206 184 rm a.${hostname} 207 185 cd - > /dev/null 208 fi # done CPP186 fi # done Go 209 187 } 210 188 211 189 # /usr/bin/time -f "%Uu %Ss %Er %Mkb" 212 213 for i in ${!locks[@]}; do 214 echo "locks: "${locks[$i]} 215 if [ ${order} -eq ${true} ] ; then 216 run_order ${locks[$i]} ${lock_flags[$i]} 'order' 217 fi 218 if [ ${baseline} -eq ${true} ] ; then 219 run_order ${locks[$i]} ${lock_flags[$i]} 'baseline' 220 fi 221 if [ ${rand} -eq ${true} ] ; then 222 run_order ${locks[$i]} '-DLOCKS=L8' 'rand' 223 fi 224 done 225 226 190 if [ ${contend} -eq ${true} ] ; then 191 echo "contend: " 192 run_contend '128' 'contend' 193 fi 194 195 if [ ${zero} -eq ${true} ] ; then 196 echo "zero: " 197 run_contend '0' 'contend' 198 fi 199 200 if [ ${barrier} -eq ${true} ] ; then 201 echo "barrier: " 202 run_contend '' 'barrier' 203 fi 204 205 if [ ${churn} -eq ${true} ] ; then 206 echo "churn: " 207 run_contend '' 'churn' 208 fi 209 210 if [ ${daisy_chain} -eq ${true} ] ; then 211 echo "daisy_chain: " 212 run_contend '' 'daisy_chain' 213 fi 214 215 if [ ${hot_potato} -eq ${true} ] ; then 216 echo "hot_potato: " 217 run_contend '' 'hot_potato' 218 fi 219 220 if [ ${pub_sub} -eq ${true} ] ; then 221 echo "pub_sub: " 222 run_contend '' 'pub_sub' 223 fi
Note:
See TracChangeset
for help on using the changeset viewer.