Skip to content

Commit

Permalink
Merge pull request #110 from FJShen/dev
Browse files Browse the repository at this point in the history
Fix for issue #107
  • Loading branch information
barnes88 authored Apr 14, 2022
2 parents 431754a + d824618 commit 786503a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 28 deletions.
58 changes: 31 additions & 27 deletions gpu-simulator/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,41 +81,45 @@ int main(int argc, const char **argv) {

unsigned i = 0;
while (i < commandlist.size() || !kernels_info.empty()) {
trace_kernel_info_t *kernel_info = NULL;
if (commandlist[i].m_type == command_type::cpu_gpu_mem_copy) {
size_t addre, Bcount;
tracer.parse_memcpy_info(commandlist[i].command_string, addre, Bcount);
std::cout << "launching memcpy command : " << commandlist[i].command_string << std::endl;
m_gpgpu_sim->perf_memcpy_to_gpu(addre, Bcount);
i++;
continue;
} else if (commandlist[i].m_type == command_type::kernel_launch) {
// Read trace header info for window_size number of kernels
while (kernels_info.size() < window_size && i < commandlist.size()) {
//gulp up as many commands as possible - either cpu_gpu_mem_copy
//or kernel_launch - until the vector "kernels_info" has reached
//the window_size or we have read every command from commandlist
while (kernels_info.size() < window_size && i < commandlist.size()) {
trace_kernel_info_t *kernel_info = NULL;
if (commandlist[i].m_type == command_type::cpu_gpu_mem_copy) {
size_t addre, Bcount;
tracer.parse_memcpy_info(commandlist[i].command_string, addre, Bcount);
std::cout << "launching memcpy command : " << commandlist[i].command_string << std::endl;
m_gpgpu_sim->perf_memcpy_to_gpu(addre, Bcount);
i++;
} else if (commandlist[i].m_type == command_type::kernel_launch) {
// Read trace header info for window_size number of kernels
kernel_trace_t* kernel_trace_info = tracer.parse_kernel_info(commandlist[i].command_string);
kernel_info = create_kernel_info(kernel_trace_info, m_gpgpu_context, &tconfig, &tracer);
kernels_info.push_back(kernel_info);
std::cout << "Header info loaded for kernel command : " << commandlist[i].command_string << std::endl;
i++;
}

// Launch all kernels within window that are on a stream that isn't already running
for (auto k : kernels_info) {
bool stream_busy = false;
for (auto s: busy_streams) {
if (s == k->get_cuda_stream_id())
stream_busy = true;
}
if (!stream_busy && m_gpgpu_sim->can_start_kernel() && !k->was_launched()) {
std::cout << "launching kernel name: " << k->get_name() << " uid: " << k->get_uid() << std::endl;
m_gpgpu_sim->launch(k);
k->set_launched();
busy_streams.push_back(k->get_cuda_stream_id());
}
else{
//unsupported commands will fail the simulation
assert(0 && "Undefined Command");
}
}

// Launch all kernels within window that are on a stream that isn't already running
for (auto k : kernels_info) {
bool stream_busy = false;
for (auto s: busy_streams) {
if (s == k->get_cuda_stream_id())
stream_busy = true;
}
if (!stream_busy && m_gpgpu_sim->can_start_kernel() && !k->was_launched()) {
std::cout << "launching kernel name: " << k->get_name() << " uid: " << k->get_uid() << std::endl;
m_gpgpu_sim->launch(k);
k->set_launched();
busy_streams.push_back(k->get_cuda_stream_id());
}
}
else if (kernels_info.empty())
assert(0 && "Undefined Command");

bool active = false;
bool sim_cycles = false;
Expand Down
4 changes: 3 additions & 1 deletion util/job_launching/slurm.sim
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ copy_output() {

trap copy_output ERR

set -e
#citing https://stackoverflow.com/questions/35800082/how-to-trap-err-when-using-set-e-in-bash
#Setting -E alongside -e makes any trap on ERR inherited by shell funcs, command substitutions and commands executed in a subshell environment
set -eE

if [ "$GPGPUSIM_SETUP_ENVIRONMENT_WAS_RUN" != "1" ]; then
export GPGPUSIM_ROOT=REPLACE_GPGPUSIM_ROOT
Expand Down

0 comments on commit 786503a

Please sign in to comment.