Changes in benchmark/readyQ/transfer.go [65c9208:6dc2db9]
- File:
-
- 1 edited
-
benchmark/readyQ/transfer.go (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
benchmark/readyQ/transfer.go
r65c9208 r6dc2db9 6 6 "math/rand" 7 7 "os" 8 "regexp"9 8 "runtime" 10 9 "sync/atomic" … … 17 16 id uint64 18 17 idx uint64 19 estop uint6420 18 seed uint64 21 19 } … … 36 34 37 35 func NewLeader(size uint64) (*LeaderInfo) { 38 this := &LeaderInfo{0, 0, 0,uint64(os.Getpid())}36 this := &LeaderInfo{0, 0, uint64(os.Getpid())} 39 37 40 38 r := rand.Intn(10) … … 53 51 } 54 52 55 func waitgroup( leader * LeaderInfo, idx uint64, threads [] MyThread, main_sem chan struct {}) {53 func waitgroup(idx uint64, threads [] MyThread) { 56 54 start := time.Now() 57 Outer:58 55 for i := 0; i < len(threads); i++ { 59 56 // fmt.Fprintf(os.Stderr, "Waiting for :%d (%d)\n", threads[i].id, atomic.LoadUint64(&threads[i].idx) ); … … 64 61 if delta.Seconds() > 5 { 65 62 fmt.Fprintf(os.Stderr, "Programs has been blocked for more than 5 secs") 66 atomic.StoreUint64(&leader.estop, 1); 67 main_sem <- (struct {}{}) 68 break Outer 63 os.Exit(1) 69 64 } 70 65 } … … 79 74 if i != me { 80 75 // debug!( "Leader waking {}", i); 81 defer func() {82 if err := recover(); err != nil {83 fmt.Fprintf(os.Stderr, "Panic occurred: %s\n", err)84 }85 }()86 76 threads[i].sem <- (struct {}{}) 87 77 } … … 94 84 atomic.StoreUint64(&leader.idx, nidx); 95 85 96 if nidx > stop_count || atomic.LoadUint64(&leader.estop) != 0{86 if nidx > stop_count { 97 87 // debug!( "Leader {} done", this.id); 98 88 main_sem <- (struct {}{}) … … 102 92 // debug!( "====================\nLeader no {} : {}", nidx, this.id); 103 93 104 waitgroup( leader, nidx, threads, main_sem);94 waitgroup(nidx, threads); 105 95 106 96 leader.next( uint64(len(threads)) ); … … 156 146 waitleader( exhaust, leader, &threads[me], &r ) 157 147 } 158 if atomic.LoadUint64(&leader.idx) > stop_count || atomic.LoadUint64(&leader.estop) != 0{ break; }148 if atomic.LoadUint64(&leader.idx) > stop_count { break; } 159 149 } 160 150 … … 165 155 func main() { 166 156 // Benchmark specific command line arguments 167 exhaustOpt := flag. String("e", "no", "Whether or not threads that have seen the new epoch should park instead of yielding.")157 exhaustOpt := flag.Bool("e", false, "Whether or not threads that have seen the new epoch should park instead of yielding.") 168 158 169 159 // General benchmark initialization and deinitialization 170 bench_init() 171 172 exhaustVal := *exhaustOpt; 173 174 var exhaust bool 175 re_yes := regexp.MustCompile("[Yy]|[Yy][Ee][Ss]") 176 re_no := regexp.MustCompile("[Nn]|[Nn][Oo]") 177 if re_yes.Match([]byte(exhaustVal)) { 178 exhaust = true 179 } else if re_no.Match([]byte(exhaustVal)) { 180 exhaust = false 181 } else { 182 fmt.Fprintf(os.Stderr, "Unrecognized exhaust(-e) option '%s'\n", exhaustVal) 183 os.Exit(1) 184 } 185 160 defer bench_init()() 161 162 exhaust := *exhaustOpt; 186 163 if clock_mode { 187 fmt.Fprintf(os.Stderr, "Programs does not support fixed duration mode \n")164 fmt.Fprintf(os.Stderr, "Programs does not support fixed duration mode") 188 165 os.Exit(1) 189 166 } … … 238 215 ws = "no" 239 216 } 240 p.Printf("Duration (ms) : % d\n", delta.Milliseconds() )217 p.Printf("Duration (ms) : %f\n", delta.Milliseconds() ) 241 218 p.Printf("Number of processors : %d\n", nprocs ) 242 219 p.Printf("Number of threads : %d\n", nthreads ) 243 p.Printf("Total Operations(ops) : %15d\n", (leader.idx - 1))220 p.Printf("Total Operations(ops) : %15d\n", stop_count ) 244 221 p.Printf("Threads parking on wait : %s\n", ws) 245 222 p.Printf("Rechecking : %d\n", rechecks ) 246 p.Printf("ns per transfer : %f\n", float64(delta.Nanoseconds()) / float64(leader.idx) ) 247 } 223 }
Note:
See TracChangeset
for help on using the changeset viewer.