From fd99c4d73e01b0e80993411bac97158a909ee571 Mon Sep 17 00:00:00 2001 From: Liu Changxi Date: Wed, 18 Oct 2023 16:28:17 +0800 Subject: [PATCH 1/8] [Bug fixed]: fixed a bug in timing/cu/issuearbiter.go; this bug causes dead lock when (1,2,3) are satisfied. 1) wavefonts in wfpools[next] are complted but not scheduled out; 2)wfpools[next+1].wfs has activate wfs; 3)other wavefronts are completed --- timing/cu/issuearbiter.go | 42 +++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/timing/cu/issuearbiter.go b/timing/cu/issuearbiter.go index ac594acd..46c9bf98 100644 --- a/timing/cu/issuearbiter.go +++ b/timing/cu/issuearbiter.go @@ -23,24 +23,36 @@ func (a *IssueArbiter) Arbitrate( return []*wavefront.Wavefront{} } - a.moveToNextSIMD(wfPools) - for len(wfPools[a.lastSIMDID].wfs) == 0 { - a.moveToNextSIMD(wfPools) - } + originalSIMDID := a.lastSIMDID - typeMask := make([]bool, 7) - wfPool := wfPools[a.lastSIMDID] list := make([]*wavefront.Wavefront, 0) - for _, wf := range wfPool.wfs { - if wf.State != wavefront.WfReady || wf.InstToIssue == nil { - continue - } + for len(list) == 0 { + a.moveToNextSIMD(wfPools) + for len(wfPools[a.lastSIMDID].wfs) == 0 { + a.moveToNextSIMD(wfPools) + if a.lastSIMDID == originalSIMDID { + break + } + } + if len(wfPools[a.lastSIMDID].wfs) != 0 { - if typeMask[wf.InstToIssue.ExeUnit] == false { - list = append(list, wf) - typeMask[wf.InstToIssue.ExeUnit] = true - } - } + typeMask := make([]bool, 7) + wfPool := wfPools[a.lastSIMDID] + for _, wf := range wfPool.wfs { + if wf.State != wavefront.WfReady || wf.InstToIssue == nil { + continue + } + + if typeMask[wf.InstToIssue.ExeUnit] == false { + list = append(list, wf) + typeMask[wf.InstToIssue.ExeUnit] = true + } + } + } + if a.lastSIMDID == originalSIMDID { + break + } + } return list } From d4b0438182c51a1933d45a92a341522eb95f51a4 Mon Sep 17 00:00:00 2001 From: Liu Changxi Date: Wed, 18 Oct 2023 20:18:29 +0800 Subject: [PATCH 2/8] [Format]: how to replace 4 space with a tab --- timing/cu/issuearbiter.go | 52 +++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/timing/cu/issuearbiter.go b/timing/cu/issuearbiter.go index 46c9bf98..f3cb4e28 100644 --- a/timing/cu/issuearbiter.go +++ b/timing/cu/issuearbiter.go @@ -23,36 +23,36 @@ func (a *IssueArbiter) Arbitrate( return []*wavefront.Wavefront{} } - originalSIMDID := a.lastSIMDID + originalSIMDID := a.lastSIMDID list := make([]*wavefront.Wavefront, 0) - for len(list) == 0 { - a.moveToNextSIMD(wfPools) - for len(wfPools[a.lastSIMDID].wfs) == 0 { - a.moveToNextSIMD(wfPools) - if a.lastSIMDID == originalSIMDID { - break - } - } - if len(wfPools[a.lastSIMDID].wfs) != 0 { + for len(list) == 0 { + a.moveToNextSIMD(wfPools) + for len(wfPools[a.lastSIMDID].wfs) == 0 { + a.moveToNextSIMD(wfPools) + if a.lastSIMDID == originalSIMDID { + break + } + } + if len(wfPools[a.lastSIMDID].wfs) != 0 { - typeMask := make([]bool, 7) - wfPool := wfPools[a.lastSIMDID] - for _, wf := range wfPool.wfs { - if wf.State != wavefront.WfReady || wf.InstToIssue == nil { - continue - } + typeMask := make([]bool, 7) + wfPool := wfPools[a.lastSIMDID] + for _, wf := range wfPool.wfs { + if wf.State != wavefront.WfReady || wf.InstToIssue == nil { + continue + } - if typeMask[wf.InstToIssue.ExeUnit] == false { - list = append(list, wf) - typeMask[wf.InstToIssue.ExeUnit] = true - } - } - } - if a.lastSIMDID == originalSIMDID { - break - } - } + if typeMask[wf.InstToIssue.ExeUnit] == false { + list = append(list, wf) + typeMask[wf.InstToIssue.ExeUnit] = true + } + } + } + if a.lastSIMDID == originalSIMDID { + break + } + } return list } From 18782ca0061d1ae74244386582bc42151b966992 Mon Sep 17 00:00:00 2001 From: Liu Changxi Date: Fri, 20 Oct 2023 13:01:51 +0800 Subject: [PATCH 3/8] [Issue Arbiter]: fixed a minimal bug; could cause dead loop issue --- timing/cu/issuearbiter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/timing/cu/issuearbiter.go b/timing/cu/issuearbiter.go index f3cb4e28..76cb734b 100644 --- a/timing/cu/issuearbiter.go +++ b/timing/cu/issuearbiter.go @@ -29,10 +29,10 @@ func (a *IssueArbiter) Arbitrate( for len(list) == 0 { a.moveToNextSIMD(wfPools) for len(wfPools[a.lastSIMDID].wfs) == 0 { - a.moveToNextSIMD(wfPools) if a.lastSIMDID == originalSIMDID { break } + a.moveToNextSIMD(wfPools) } if len(wfPools[a.lastSIMDID].wfs) != 0 { From ae39027d53e0af7ac5e9cc327f4d11802bcd8d9c Mon Sep 17 00:00:00 2001 From: Liu Changxi Date: Mon, 27 Nov 2023 21:56:35 +0800 Subject: [PATCH 4/8] [Bug Fixed]: fixed a bug in vector memory unit --- timing/cu/vectormemoryunit.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/timing/cu/vectormemoryunit.go b/timing/cu/vectormemoryunit.go index c0b98528..ba93b0ea 100644 --- a/timing/cu/vectormemoryunit.go +++ b/timing/cu/vectormemoryunit.go @@ -109,8 +109,9 @@ func (u *VectorMemoryUnit) insertTransactionToPipeline( } func (u *VectorMemoryUnit) execute(now sim.VTimeInSec) (madeProgress bool) { - item := u.postInstructionPipelineBuffer.Pop() + item := u.postInstructionPipelineBuffer.Peek() if item == nil { + u.postInstructionPipelineBuffer.Pop() return false } @@ -126,6 +127,7 @@ func (u *VectorMemoryUnit) execute(now sim.VTimeInSec) (madeProgress bool) { log.Panicf("running inst %s in vector memory unit is not supported", inst.String(nil)) } + u.postInstructionPipelineBuffer.Pop() u.cu.UpdatePCAndSetReady(wave) u.numInstInFlight-- From f3b0b8cc5cf6253eecc6e00c09a8213555062023 Mon Sep 17 00:00:00 2001 From: Yifan Sun Date: Mon, 27 Nov 2023 07:43:21 -0700 Subject: [PATCH 5/8] Apply suggestions from code review Minor changes in formats --- timing/cu/issuearbiter.go | 3 ++- timing/cu/vectormemoryunit.go | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/timing/cu/issuearbiter.go b/timing/cu/issuearbiter.go index 76cb734b..7171bb96 100644 --- a/timing/cu/issuearbiter.go +++ b/timing/cu/issuearbiter.go @@ -34,8 +34,8 @@ func (a *IssueArbiter) Arbitrate( } a.moveToNextSIMD(wfPools) } - if len(wfPools[a.lastSIMDID].wfs) != 0 { + if len(wfPools[a.lastSIMDID].wfs) != 0 { typeMask := make([]bool, 7) wfPool := wfPools[a.lastSIMDID] for _, wf := range wfPool.wfs { @@ -49,6 +49,7 @@ func (a *IssueArbiter) Arbitrate( } } } + if a.lastSIMDID == originalSIMDID { break } diff --git a/timing/cu/vectormemoryunit.go b/timing/cu/vectormemoryunit.go index ba93b0ea..8b571336 100644 --- a/timing/cu/vectormemoryunit.go +++ b/timing/cu/vectormemoryunit.go @@ -111,7 +111,6 @@ func (u *VectorMemoryUnit) insertTransactionToPipeline( func (u *VectorMemoryUnit) execute(now sim.VTimeInSec) (madeProgress bool) { item := u.postInstructionPipelineBuffer.Peek() if item == nil { - u.postInstructionPipelineBuffer.Pop() return false } From ea939c3e35a21a115950fa4689acb6f74ae50876 Mon Sep 17 00:00:00 2001 From: Yifan Sun Date: Wed, 13 Dec 2023 10:19:07 -0500 Subject: [PATCH 6/8] update logic --- timing/cu/issuearbiter.go | 67 +++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 24 deletions(-) diff --git a/timing/cu/issuearbiter.go b/timing/cu/issuearbiter.go index 7171bb96..b1e251d9 100644 --- a/timing/cu/issuearbiter.go +++ b/timing/cu/issuearbiter.go @@ -10,7 +10,7 @@ type IssueArbiter struct { // NewIssueArbiter returns a newly created IssueArbiter func NewIssueArbiter() *IssueArbiter { a := new(IssueArbiter) - a.lastSIMDID = -1 + a.lastSIMDID = 0 return a } @@ -23,38 +23,57 @@ func (a *IssueArbiter) Arbitrate( return []*wavefront.Wavefront{} } - originalSIMDID := a.lastSIMDID + wfToIssue := make([]*wavefront.Wavefront, 0) + for i := 0; i < len(wfPools); i++ { + simdID := (a.lastSIMDID + i) % len(wfPools) - list := make([]*wavefront.Wavefront, 0) - for len(list) == 0 { - a.moveToNextSIMD(wfPools) - for len(wfPools[a.lastSIMDID].wfs) == 0 { - if a.lastSIMDID == originalSIMDID { - break + typeMask := make([]bool, 7) + wfPool := wfPools[simdID] + for _, wf := range wfPool.wfs { + if wf.State != wavefront.WfReady || wf.InstToIssue == nil { + continue } - a.moveToNextSIMD(wfPools) - } - - if len(wfPools[a.lastSIMDID].wfs) != 0 { - typeMask := make([]bool, 7) - wfPool := wfPools[a.lastSIMDID] - for _, wf := range wfPool.wfs { - if wf.State != wavefront.WfReady || wf.InstToIssue == nil { - continue - } - if typeMask[wf.InstToIssue.ExeUnit] == false { - list = append(list, wf) - typeMask[wf.InstToIssue.ExeUnit] = true - } + if typeMask[wf.InstToIssue.ExeUnit] == false { + wfToIssue = append(wfToIssue, wf) + typeMask[wf.InstToIssue.ExeUnit] = true } } - if a.lastSIMDID == originalSIMDID { + if len(wfToIssue) != 0 { + a.lastSIMDID = simdID break } } - return list + + // for len(wfToIssue) == 0 { + // a.moveToNextSIMD(wfPools) + // for len(wfPools[a.lastSIMDID].wfs) == 0 { + // if a.lastSIMDID == originalSIMDID { + // break + // } + // a.moveToNextSIMD(wfPools) + // } + + // typeMask := make([]bool, 7) + // wfPool := wfPools[a.lastSIMDID] + // for _, wf := range wfPool.wfs { + // if wf.State != wavefront.WfReady || wf.InstToIssue == nil { + // continue + // } + + // if typeMask[wf.InstToIssue.ExeUnit] == false { + // wfToIssue = append(wfToIssue, wf) + // typeMask[wf.InstToIssue.ExeUnit] = true + // } + // } + + // if a.lastSIMDID == originalSIMDID { + // break + // } + // } + + return wfToIssue } func (a *IssueArbiter) moveToNextSIMD(wfPools []*WavefrontPool) { From e0717d9aab967c5ffefd15575e74a23351ebd226 Mon Sep 17 00:00:00 2001 From: Yifan Sun Date: Mon, 18 Dec 2023 10:25:54 -0500 Subject: [PATCH 7/8] Fix unit test --- timing/cu/issuearbiter.go | 27 --------------------------- timing/cu/vectormemoryunit_test.go | 2 ++ 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/timing/cu/issuearbiter.go b/timing/cu/issuearbiter.go index b1e251d9..2992dbe8 100644 --- a/timing/cu/issuearbiter.go +++ b/timing/cu/issuearbiter.go @@ -46,33 +46,6 @@ func (a *IssueArbiter) Arbitrate( } } - // for len(wfToIssue) == 0 { - // a.moveToNextSIMD(wfPools) - // for len(wfPools[a.lastSIMDID].wfs) == 0 { - // if a.lastSIMDID == originalSIMDID { - // break - // } - // a.moveToNextSIMD(wfPools) - // } - - // typeMask := make([]bool, 7) - // wfPool := wfPools[a.lastSIMDID] - // for _, wf := range wfPool.wfs { - // if wf.State != wavefront.WfReady || wf.InstToIssue == nil { - // continue - // } - - // if typeMask[wf.InstToIssue.ExeUnit] == false { - // wfToIssue = append(wfToIssue, wf) - // typeMask[wf.InstToIssue.ExeUnit] = true - // } - // } - - // if a.lastSIMDID == originalSIMDID { - // break - // } - // } - return wfToIssue } diff --git a/timing/cu/vectormemoryunit_test.go b/timing/cu/vectormemoryunit_test.go index 4c5cc62a..0e067254 100644 --- a/timing/cu/vectormemoryunit_test.go +++ b/timing/cu/vectormemoryunit_test.go @@ -91,6 +91,7 @@ var _ = Describe("Vector Memory Unit", func() { transactions[i].Read = read } coalescer.EXPECT().generateMemTransactions(wave).Return(transactions) + instBuffer.EXPECT().Peek().Return(vectorMemInst{wavefront: wave}) instBuffer.EXPECT().Pop().Return(vectorMemInst{wavefront: wave}) madeProgress := vecMemUnit.instToTransaction(10) @@ -122,6 +123,7 @@ var _ = Describe("Vector Memory Unit", func() { transactions[i].Write = write } coalescer.EXPECT().generateMemTransactions(wave).Return(transactions) + instBuffer.EXPECT().Peek().Return(vectorMemInst{wavefront: wave}) instBuffer.EXPECT().Pop().Return(vectorMemInst{wavefront: wave}) madeProgress := vecMemUnit.instToTransaction(10) From 57df83794285e6206b8db30faf390ba63f976dde Mon Sep 17 00:00:00 2001 From: Yifan Sun Date: Mon, 18 Dec 2023 10:41:19 -0500 Subject: [PATCH 8/8] Remove concurrent kernel in test --- tests/acceptance/cases.go | 56 +++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/tests/acceptance/cases.go b/tests/acceptance/cases.go index 8a7a23e0..c7d37a6f 100644 --- a/tests/acceptance/cases.go +++ b/tests/acceptance/cases.go @@ -801,32 +801,32 @@ var benchmarks = []benchmark{ {gpus: []int{1, 2, 3, 4}, timing: true, parallel: true, unifiedGPU: true, unifiedMemory: true}, }, }, - { - benchmarkPath: "", - executablePath: "../../samples/concurrentkernel", - executable: "concurrentkernel", - sizeArgs: []string{}, - cases: []benchmarkCase{ - {gpus: []int{1}, timing: false, parallel: false, unifiedGPU: false, unifiedMemory: false}, - {gpus: []int{1}, timing: false, parallel: true, unifiedGPU: false, unifiedMemory: false}, - {gpus: []int{1}, timing: true, parallel: false, unifiedGPU: false, unifiedMemory: false}, - {gpus: []int{1}, timing: true, parallel: true, unifiedGPU: false, unifiedMemory: false}, - }, - }, - { - benchmarkPath: "", - executablePath: "../../samples/concurrentworkload", - executable: "concurrentworkload", - sizeArgs: []string{}, - cases: []benchmarkCase{ - {gpus: []int{1, 2, 3, 4}, timing: false, parallel: false, unifiedGPU: false, unifiedMemory: false}, - {gpus: []int{1, 2, 3, 4}, timing: false, parallel: true, unifiedGPU: false, unifiedMemory: false}, - {gpus: []int{1, 2, 3, 4}, timing: true, parallel: false, unifiedGPU: false, unifiedMemory: false}, - {gpus: []int{1, 2, 3, 4}, timing: true, parallel: true, unifiedGPU: false, unifiedMemory: false}, - // {gpus: []int{1, 2, 3, 4}, timing: false, parallel: false, unifiedGPU: false, unifiedMemory: true}, - // {gpus: []int{1, 2, 3, 4}, timing: false, parallel: true, unifiedGPU: false, unifiedMemory: true}, - // {gpus: []int{1, 2, 3, 4}, timing: true, parallel: false, unifiedGPU: false, unifiedMemory: true}, - // {gpus: []int{1, 2, 3, 4}, timing: true, parallel: true, unifiedGPU: false, unifiedMemory: true}, - }, - }, + // { + // benchmarkPath: "", + // executablePath: "../../samples/concurrentkernel", + // executable: "concurrentkernel", + // sizeArgs: []string{}, + // cases: []benchmarkCase{ + // {gpus: []int{1}, timing: false, parallel: false, unifiedGPU: false, unifiedMemory: false}, + // {gpus: []int{1}, timing: false, parallel: true, unifiedGPU: false, unifiedMemory: false}, + // {gpus: []int{1}, timing: true, parallel: false, unifiedGPU: false, unifiedMemory: false}, + // {gpus: []int{1}, timing: true, parallel: true, unifiedGPU: false, unifiedMemory: false}, + // }, + // }, + // { + // benchmarkPath: "", + // executablePath: "../../samples/concurrentworkload", + // executable: "concurrentworkload", + // sizeArgs: []string{}, + // cases: []benchmarkCase{ + // {gpus: []int{1, 2, 3, 4}, timing: false, parallel: false, unifiedGPU: false, unifiedMemory: false}, + // {gpus: []int{1, 2, 3, 4}, timing: false, parallel: true, unifiedGPU: false, unifiedMemory: false}, + // {gpus: []int{1, 2, 3, 4}, timing: true, parallel: false, unifiedGPU: false, unifiedMemory: false}, + // {gpus: []int{1, 2, 3, 4}, timing: true, parallel: true, unifiedGPU: false, unifiedMemory: false}, + // {gpus: []int{1, 2, 3, 4}, timing: false, parallel: false, unifiedGPU: false, unifiedMemory: true}, + // {gpus: []int{1, 2, 3, 4}, timing: false, parallel: true, unifiedGPU: false, unifiedMemory: true}, + // {gpus: []int{1, 2, 3, 4}, timing: true, parallel: false, unifiedGPU: false, unifiedMemory: true}, + // {gpus: []int{1, 2, 3, 4}, timing: true, parallel: true, unifiedGPU: false, unifiedMemory: true}, + // }, + // }, }