Skip to content

Commit cc372a9

Browse files
committed
adding raycast benchmark
1 parent 734c25e commit cc372a9

42 files changed

Lines changed: 17790 additions & 12 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎sim/simx/core.cpp‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,64 @@ void Core::issue() {
358358
}
359359
}
360360

361+
if (ready_set.any()) {
362+
// apply user-driven scheduling
363+
auto count = ready_set.count();
364+
if (count > 1) {
365+
uint32_t priority_warps = 0;
366+
uint32_t yielding_warps = 0;
367+
for (uint32_t j = 0; j < PER_ISSUE_WARPS; ++j) {
368+
if (ready_set.test(j)) {
369+
uint32_t wid = j * ISSUE_WIDTH + iw;
370+
auto& warp = emulator_.warps_.at(wid);
371+
if (warp.priority > 0) {
372+
++priority_warps;
373+
}
374+
if (warp.yield > 0) {
375+
++yielding_warps;
376+
}
377+
if (warp.priority > 0 && warp.yield > 0) {
378+
std::cout << "Warp cannot be both priority and yielding! wid=" << wid << std::endl << std::flush;
379+
std::abort();
380+
}
381+
}
382+
}
383+
if (yielding_warps != 0) {
384+
// remove yielding warps from ready set
385+
for (uint32_t j = 0; j < PER_ISSUE_WARPS; ++j) {
386+
if (ready_set.test(j)) {
387+
uint32_t wid = j * ISSUE_WIDTH + iw;
388+
auto& warp = emulator_.warps_.at(wid);
389+
if (warp.yield > 0) {
390+
ready_set.reset(j);
391+
--warp.yield; // update yield counter
392+
--count;
393+
auto& ibuffer = ibuffers_.at(wid);
394+
auto trace = ibuffer.top();
395+
DT(3, "*** pipeline-counter-yield: " << *trace);
396+
}
397+
}
398+
}
399+
}
400+
if (priority_warps != 0 && priority_warps < count) {
401+
// remove non-priority warps from ready set
402+
for (uint32_t j = 0; j < PER_ISSUE_WARPS; ++j) {
403+
if (ready_set.test(j)) {
404+
uint32_t wid = j * ISSUE_WIDTH + iw;
405+
auto& warp = emulator_.warps_.at(wid);
406+
if (warp.priority == 0) {
407+
ready_set.reset(j);
408+
--count;
409+
auto& ibuffer = ibuffers_.at(wid);
410+
auto trace = ibuffer.top();
411+
DT(3, "*** pipeline-priority-yield: " << *trace);
412+
}
413+
}
414+
}
415+
}
416+
}
417+
}
418+
361419
if (ready_set.any()) {
362420
// select one instruction from ready set
363421
auto w = ibuffer_arbs_.at(iw).grant(ready_set);

‎sim/simx/decode.cpp‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ static op_string_t op_string(const Instr &instr) {
368368
case WctlType::JOIN: return {"JOIN", ""};
369369
case WctlType::BAR: return {"BAR", ""};
370370
case WctlType::PRED: return {wctlArgs.is_neg ? "PRED.N":"PRED", ""};
371+
case WctlType::WSCHED: return {"WSCHED", "priority=" + std::to_string(wctlArgs.priority) + ", yield=" + std::to_string(wctlArgs.yield)};
371372
default:
372373
std::abort();
373374
}
@@ -1032,16 +1033,22 @@ void Emulator::decode(uint32_t code, uint32_t wid, uint64_t uuid) {
10321033
instr->setSrcReg(1, rs2, RegType::Integer);
10331034
wctlArgs.is_neg = (rd != 0);
10341035
break;
1036+
case 6: // WSCHED
1037+
instr->setOpType(WctlType::WSCHED);
1038+
wctlArgs.priority = rs1;
1039+
wctlArgs.yield = rs2;
1040+
break;
10351041
default:
10361042
std::abort();
10371043
}
10381044
instr->setArgs(wctlArgs);
10391045
ibuffer.push_back(instr);
10401046
} break;
1041-
case 1: { // VOTE
1047+
case 1: { // VOTE & SHUFFLE
10421048
auto instr = std::allocate_shared<Instr>(instr_pool_, uuid, FUType::ALU);
10431049
instr->setDestReg(rd, RegType::Integer);
10441050
instr->setSrcReg(0, rs1, RegType::Integer);
1051+
instr->setSrcReg(1, rs2, RegType::Integer);
10451052
switch (funct3) {
10461053
case 0:
10471054
instr->setOpType(VoteType::ALL);
@@ -1057,19 +1064,19 @@ void Emulator::decode(uint32_t code, uint32_t wid, uint64_t uuid) {
10571064
break;
10581065
case 4:
10591066
instr->setOpType(ShflType::UP);
1060-
instr->setSrcReg(1, rs2, RegType::Integer);
1067+
instr->setSrcReg(2, rs3, RegType::Integer);
10611068
break;
10621069
case 5:
10631070
instr->setOpType(ShflType::DOWN);
1064-
instr->setSrcReg(1, rs2, RegType::Integer);
1071+
instr->setSrcReg(2, rs3, RegType::Integer);
10651072
break;
10661073
case 6:
10671074
instr->setOpType(ShflType::BFLY);
1068-
instr->setSrcReg(1, rs2, RegType::Integer);
1075+
instr->setSrcReg(2, rs3, RegType::Integer);
10691076
break;
10701077
case 7:
10711078
instr->setOpType(ShflType::IDX);
1072-
instr->setSrcReg(1, rs2, RegType::Integer);
1079+
instr->setSrcReg(2, rs3, RegType::Integer);
10731080
break;
10741081
default:
10751082
std::abort();

‎sim/simx/emulator.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,17 @@ warp_t::warp_t(uint32_t num_threads)
3636
, tmask(num_threads)
3737
, PC(0)
3838
, uuid(0)
39+
, priority(0)
40+
, yield(0)
3941
{}
4042

4143
void warp_t::reset(uint64_t startup_addr) {
4244
this->tmask.reset();
4345
this->PC = startup_addr;
4446
this->uuid = 0;
4547
this->fcsr = 0;
48+
this->priority = 0;
49+
this->yield = 0;
4650

4751
for (auto& reg_file : this->ireg_file) {
4852
for (auto& reg : reg_file) {

‎sim/simx/emulator.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ struct warp_t {
6060
Word PC;
6161
Byte fcsr;
6262
uint32_t uuid;
63+
uint32_t priority;
64+
uint32_t yield;
6365

6466
warp_t(uint32_t num_threads);
6567

@@ -164,6 +166,8 @@ class Emulator {
164166
#endif
165167

166168
PoolAllocator<Instr, 64> instr_pool_;
169+
170+
friend class Core;
167171
};
168172

169173
}

‎sim/simx/execute.cpp‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ instr_trace_t* Emulator::execute(const Instr &instr, uint32_t wid) {
145145
DP(1, "Instr: " << instr << ", cid=" << core_->id() << ", wid=" << wid << ", tmask=" << warp.tmask
146146
<< ", PC=0x" << std::hex << warp.PC << std::dec << " (#" << instr.getUUID() << ")");
147147

148+
assert(warp.tmask.any());
149+
148150
// fetch register values
149151
if (rsrc0.type != RegType::None) fetch_registers(rs1_data, wid, 0, rsrc0);
150152
if (rsrc1.type != RegType::None) fetch_registers(rs2_data, wid, 1, rsrc1);
@@ -313,15 +315,16 @@ instr_trace_t* Emulator::execute(const Instr &instr, uint32_t wid) {
313315
for (uint32_t t = thread_start; t < num_threads; ++t) {
314316
if (!warp.tmask.test(t))
315317
continue;
316-
auto is_pred = rs1_data[t].i & 0x1;
318+
bool is_pred = (rs1_data[t].i & 1) != 0;
319+
has_vote_true |= is_pred;
320+
has_vote_false |= !is_pred;
317321
if (is_pred) {
318-
has_vote_true = true;
319322
ballot |= (Word(1) << t);
320-
} else {
321-
has_vote_false = true;
322323
}
323324
}
324325
for (uint32_t t = thread_start; t < num_threads; ++t) {
326+
if (!warp.tmask.test(t))
327+
continue;
325328
switch (vote_type) {
326329
case VoteType::ALL:
327330
rd_data[t].i = !has_vote_false;
@@ -373,8 +376,9 @@ instr_trace_t* Emulator::execute(const Instr &instr, uint32_t wid) {
373376
default:
374377
std::abort();
375378
}
376-
if (!pval)
379+
if (!pval) {
377380
lane = t;
381+
}
378382
if (lane < num_threads) {
379383
rd_data[t].i = rs1_data[lane].i;
380384
} else {
@@ -1396,6 +1400,11 @@ instr_trace_t* Emulator::execute(const Instr &instr, uint32_t wid) {
13961400
next_tmask = ThreadMask(num_threads, rs2_data.at(thread_last).u);
13971401
}
13981402
} break;
1403+
case WctlType::WSCHED: {
1404+
trace->fetch_stall = true;
1405+
warp.priority = wctlArgs.priority;
1406+
warp.yield = wctlArgs.yield;
1407+
} break;
13991408
default:
14001409
std::abort();
14011410
}

‎sim/simx/func_unit.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ void SfuUnit::tick() {
368368
case WctlType::SPLIT:
369369
case WctlType::JOIN:
370370
case WctlType::PRED:
371+
case WctlType::WSCHED:
371372
output.push(trace, 2+delay);
372373
break;
373374
case WctlType::BAR: {

‎sim/simx/types.h‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,11 +429,14 @@ enum class WctlType {
429429
SPLIT,
430430
JOIN,
431431
BAR,
432-
PRED
432+
PRED,
433+
WSCHED
433434
};
434435

435436
struct IntrWctlArgs {
436-
uint32_t is_neg : 1;
437+
uint32_t is_neg : 1;
438+
uint32_t priority : 1;
439+
uint32_t yield : 5;
437440
};
438441

439442
inline std::ostream &operator<<(std::ostream &os, const WctlType& type) {
@@ -444,6 +447,7 @@ inline std::ostream &operator<<(std::ostream &os, const WctlType& type) {
444447
case WctlType::JOIN: os << "JOIN"; break;
445448
case WctlType::BAR: os << "BAR"; break;
446449
case WctlType::PRED: os << "PRED"; break;
450+
case WctlType::WSCHED: os << "WSCHED"; break;
447451
default:
448452
assert(false);
449453
}

‎tests/regression/Makefile‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ all:
2222
$(MAKE) -C sgemm2
2323
$(MAKE) -C madmax
2424
$(MAKE) -C stencil3d
25+
$(MAKE) -C raycast
2526

2627
run-simx:
2728
$(MAKE) -C basic run-simx
@@ -44,6 +45,7 @@ run-simx:
4445
$(MAKE) -C sgemm2 run-simx
4546
$(MAKE) -C madmax run-simx
4647
$(MAKE) -C stencil3d run-simx
48+
$(MAKE) -C raycast run-simx
4749

4850
run-rtlsim:
4951
$(MAKE) -C basic run-rtlsim
@@ -66,6 +68,7 @@ run-rtlsim:
6668
$(MAKE) -C sgemm2 run-rtlsim
6769
$(MAKE) -C madmax run-rtlsim
6870
$(MAKE) -C stencil3d run-rtlsim
71+
$(MAKE) -C raycast run-rtlsim
6972

7073
clean:
7174
$(MAKE) -C basic clean
@@ -88,3 +91,4 @@ clean:
8891
$(MAKE) -C sgemm2 clean
8992
$(MAKE) -C madmax clean
9093
$(MAKE) -C stencil3d clean
94+
$(MAKE) -C raycast clean

‎tests/regression/priority/Makefile‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
ROOT_DIR := $(realpath ../../..)
2+
include $(ROOT_DIR)/config.mk
3+
4+
PROJECT := priority
5+
6+
SRC_DIR := $(VORTEX_HOME)/tests/regression/$(PROJECT)
7+
8+
SRCS := $(SRC_DIR)/main.cpp
9+
10+
VX_SRCS := $(SRC_DIR)/kernel.cpp
11+
12+
OPTS ?= -n32
13+
14+
include ../common.mk

‎tests/regression/priority/common.h‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef _COMMON_H_
2+
#define _COMMON_H_
3+
4+
#ifndef TYPE
5+
#define TYPE float
6+
#endif
7+
8+
typedef struct {
9+
uint32_t grid_dim[2];
10+
uint32_t size;
11+
uint64_t A_addr;
12+
uint64_t B_addr;
13+
uint64_t C_addr;
14+
} kernel_arg_t;
15+
16+
#endif

0 commit comments

Comments
 (0)