summaryrefslogtreecommitdiff
path: root/src/stream_manager.cc
diff options
context:
space:
mode:
authorTor Aamodt <[email protected]>2025-02-10 17:35:31 -0800
committerGitHub <[email protected]>2025-02-10 17:35:31 -0800
commit0e39753a623978eb37bf044b21fde1a5909bff03 (patch)
tree13416ab3a165dde580fe847b06bde7c966482088 /src/stream_manager.cc
parent6b244a5d3be7811f16c312905c1c7fee137ac7a4 (diff)
parent48af0c94ca6d7b05f800f535b3de4cefafcfa655 (diff)
Merge pull request #313 from accel-sim/dev
Purdue Updates Merging
Diffstat (limited to 'src/stream_manager.cc')
-rw-r--r--src/stream_manager.cc30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/stream_manager.cc b/src/stream_manager.cc
index e99bf87..58c2ec4 100644
--- a/src/stream_manager.cc
+++ b/src/stream_manager.cc
@@ -34,6 +34,16 @@
unsigned CUstream_st::sm_next_stream_uid = 0;
+// SST memcpy callbacks
+extern void SST_callback_memcpy_H2D_done();
+extern void SST_callback_memcpy_D2H_done();
+extern void SST_callback_memcpy_to_symbol_done();
+extern void SST_callback_memcpy_from_symbol_done();
+__attribute__((weak)) void SST_callback_memcpy_H2D_done() {}
+__attribute__((weak)) void SST_callback_memcpy_D2H_done() {}
+__attribute__((weak)) void SST_callback_memcpy_to_symbol_done() {}
+__attribute__((weak)) void SST_callback_memcpy_from_symbol_done() {}
+
CUstream_st::CUstream_st() {
m_pending = false;
m_uid = sm_next_stream_uid++;
@@ -122,11 +132,13 @@ bool stream_operation::do_operation(gpgpu_sim *gpu) {
if (g_debug_execution >= 3) printf("memcpy host-to-device\n");
gpu->memcpy_to_gpu(m_device_address_dst, m_host_address_src, m_cnt);
m_stream->record_next_done();
+ if (gpu->is_SST_mode()) SST_callback_memcpy_H2D_done();
break;
case stream_memcpy_device_to_host:
if (g_debug_execution >= 3) printf("memcpy device-to-host\n");
gpu->memcpy_from_gpu(m_host_address_dst, m_device_address_src, m_cnt);
m_stream->record_next_done();
+ if (gpu->is_SST_mode()) SST_callback_memcpy_D2H_done();
break;
case stream_memcpy_device_to_device:
if (g_debug_execution >= 3) printf("memcpy device-to-device\n");
@@ -138,12 +150,14 @@ bool stream_operation::do_operation(gpgpu_sim *gpu) {
gpu->gpgpu_ctx->func_sim->gpgpu_ptx_sim_memcpy_symbol(
m_symbol, m_host_address_src, m_cnt, m_offset, 1, gpu);
m_stream->record_next_done();
+ if (gpu->is_SST_mode()) SST_callback_memcpy_to_symbol_done();
break;
case stream_memcpy_from_symbol:
if (g_debug_execution >= 3) printf("memcpy from symbol\n");
gpu->gpgpu_ctx->func_sim->gpgpu_ptx_sim_memcpy_symbol(
m_symbol, m_host_address_dst, m_cnt, m_offset, 0, gpu);
m_stream->record_next_done();
+ if (gpu->is_SST_mode()) SST_callback_memcpy_from_symbol_done();
break;
case stream_kernel_launch:
if (m_sim_mode) { // Functional Sim
@@ -227,6 +241,8 @@ void stream_operation::print(FILE *fp) const {
case stream_no_op:
fprintf(fp, "no-op");
break;
+ default:
+ break;
}
}
@@ -300,6 +316,14 @@ bool stream_manager::register_finished_kernel(unsigned grid_uid) {
void stream_manager::stop_all_running_kernels() {
pthread_mutex_lock(&m_lock);
+ std::vector<unsigned long long> finished_streams;
+ std::vector<kernel_info_t *> running_kernels = m_gpu->get_running_kernels();
+ for (kernel_info_t *k : running_kernels) {
+ if (k != NULL) {
+ finished_streams.push_back(k->get_streamID());
+ }
+ }
+
// Signal m_gpu to stop all running kernels
m_gpu->stop_all_running_kernels();
@@ -310,7 +334,9 @@ void stream_manager::stop_all_running_kernels() {
}
// If any kernels completed, print out the current stats
- if (count > 0) m_gpu->print_stats();
+ for (unsigned long long streamID : finished_streams) {
+ m_gpu->print_stats(streamID);
+ }
pthread_mutex_unlock(&m_lock);
}
@@ -460,7 +486,7 @@ void stream_manager::push(stream_operation op) {
}
if (g_debug_execution >= 3) print_impl(stdout);
pthread_mutex_unlock(&m_lock);
- if (m_cuda_launch_blocking || stream == NULL) {
+ if (!m_gpu->is_SST_mode() && (m_cuda_launch_blocking || stream == NULL)) {
unsigned int wait_amount = 100;
unsigned int wait_cap = 100000; // 100ms
while (!empty()) {