Skip to content

Commit a23f581

Browse files
committed
remove is_graphics
1 parent a5c3e49 commit a23f581

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

gpu-simulator/accel-sim.cc

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,28 +84,29 @@ void accel_sim_framework::simulation_loop() {
8484
// Launch all kernels within window that are on a stream that isn't already
8585
// running
8686
for (auto k : kernels_info) {
87+
bool is_graphics = m_gpgpu_sim->is_graphics(k->get_streamID());
8788
bool stream_busy = false;
8889
for (auto s : busy_streams) {
8990
if (s == k->get_cuda_stream_id()) stream_busy = true;
9091
}
9192
if (!stream_busy && m_gpgpu_sim->can_start_kernel() &&
9293
!k->was_launched()) {
93-
if ((launched_mesa ==
94-
m_gpgpu_sim->get_config().get_max_concurrent_kernel() * 3 /
95-
4 &&
96-
k->is_graphic_kernel)) {
94+
if (launched_mesa ==
95+
(m_gpgpu_sim->get_config().get_max_concurrent_kernel() * 3 /
96+
4) &&
97+
is_graphics) {
9798
continue;
9899
}
99100
std::cout << "launching kernel name: " << k->get_name()
100101
<< " uid: " << k->get_uid()
101102
<< " cuda_stream_id: " << k->get_cuda_stream_id()
102103
<< std::endl;
103-
if (!k->is_graphic_kernel) {
104-
m_gpgpu_sim->gipc = 0;
105-
} else {
104+
if (is_graphics) {
106105
// graphics
107106
m_gpgpu_sim->cipc = 0;
108107
launched_mesa++;
108+
} else {
109+
m_gpgpu_sim->gipc = 0;
109110
}
110111
m_gpgpu_sim->launch(k);
111112
k->set_launched();
@@ -193,9 +194,11 @@ void accel_sim_framework::parse_commandlist() {
193194
addre, Bcount, per_CTA);
194195
if (commandlist[commandlist_index].command_string.find("MemcpyVulkan") ==
195196
std::string::npos) {
197+
// normal memcpy
196198
std::cout << "launching memcpy command : "
197199
<< commandlist[commandlist_index].command_string << std::endl;
198-
m_gpgpu_sim->perf_memcpy_to_gpu(addre, Bcount, false);
200+
m_gpgpu_sim->perf_memcpy_to_gpu(addre, Bcount, (uint64_t)-1);
201+
// -1: does not belong to any stream
199202
} else {
200203
assert(per_CTA != (unsigned)-1);
201204
kernel_vb_addr.push_back(addre);
@@ -210,6 +213,7 @@ void accel_sim_framework::parse_commandlist() {
210213
kernel_trace_t *kernel_trace_info = tracer.parse_kernel_info(
211214
commandlist[commandlist_index].command_string);
212215
if (kernel_trace_info->kernel_name.find("VERTEX") != std::string::npos) {
216+
m_gpgpu_sim->set_graphics(graphics_stream_id);
213217
kernel_trace_info->cuda_stream_id = graphics_stream_id;
214218
last_grpahics_stream_id = graphics_stream_id;
215219
graphics_stream_id++;
@@ -220,7 +224,7 @@ void accel_sim_framework::parse_commandlist() {
220224
kernel_info = create_kernel_info(kernel_trace_info, m_gpgpu_context,
221225
&tconfig, &tracer);
222226

223-
if (kernel_info->is_graphic_kernel) {
227+
if (m_gpgpu_sim->is_graphics(kernel_info->get_streamID())) {
224228
graphics_commands.push_back(commandlist[commandlist_index]);
225229
unsigned kernel_id = kernel_info->get_uid();
226230

@@ -251,7 +255,7 @@ void accel_sim_framework::parse_commandlist() {
251255

252256
void accel_sim_framework::cleanup(unsigned finished_kernel) {
253257
trace_kernel_info_t *k = NULL;
254-
unsigned long long finished_kernel_cuda_stream_id = -1;
258+
uint64_t finished_kernel_cuda_stream_id = -1;
255259
unsigned finishd_kernel_uid = 0;
256260
for (unsigned j = 0; j < kernels_info.size(); j++) {
257261
k = kernels_info.at(j);
@@ -277,7 +281,7 @@ void accel_sim_framework::cleanup(unsigned finished_kernel) {
277281
m_gpgpu_sim->get_config().mps_sm_count;
278282
}
279283
}
280-
if (k->is_graphic_kernel) {
284+
if (m_gpgpu_sim->is_graphics(k->get_streamID())) {
281285
finished_graphics++;
282286
launched_mesa--;
283287
} else {
@@ -347,10 +351,6 @@ trace_kernel_info_t *accel_sim_framework::create_kernel_info(
347351
function_info->set_name(kernel_trace_info->kernel_name.c_str());
348352
trace_kernel_info_t *kernel_info = new trace_kernel_info_t(
349353
gridDim, blockDim, function_info, parser, config, kernel_trace_info);
350-
if (kernel_trace_info->kernel_name.find("VERTEX") != std::string::npos ||
351-
kernel_trace_info->kernel_name.find("FRAG") != std::string::npos) {
352-
kernel_info->is_graphic_kernel = true;
353-
}
354354

355355
return kernel_info;
356356
}

gpu-simulator/accel-sim.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class accel_sim_framework {
8080
bool computes_done;
8181
bool graphics_done;
8282

83-
std::vector<unsigned long long> busy_streams;
83+
std::vector<uint64_t> busy_streams;
8484
std::vector<trace_kernel_info_t *> kernels_info;
8585
std::vector<trace_command> commandlist;
8686

gpu-simulator/trace-parser/trace_parser.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,15 @@ kernel_trace_t *trace_parser::parse_kernel_info(
342342
} else if (string1 == "cuda" && string2 == "stream") {
343343
sscanf(line.c_str(), "-cuda stream id = %llu",
344344
&kernel_info->cuda_stream_id);
345+
assert(kernel_info->cuda_stream_id != (uint64_t)-1);
346+
if (kernel_info->cuda_stream_id == (uint64_t)-1) {
347+
// in the code -1 is being used as initial value. Assumption is that
348+
// is -1 is not valid. If a stream indeed have id -1, this need to be
349+
// fixed
350+
std::cerr << "Error: cuda stream id is -1, this is not valid"
351+
<< std::endl;
352+
abort();
353+
}
345354
} else if (string1 == "binary" && string2 == "version") {
346355
sscanf(line.c_str(), "-binary version = %d",
347356
&kernel_info->binary_verion);

0 commit comments

Comments
 (0)