summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTayler Hetherington <[email protected]>2015-06-05 14:49:14 -0700
committerTayler Hetherington <[email protected]>2015-06-05 14:49:14 -0700
commit07b1e93f19bef20a9e35fcfc48b091fa36d56d1b (patch)
tree0f8fa652aab482ae0487465f5c0ad34b16b7ae99
parent3ab52d670fbe4fc79eeba1c9a0061dba69fad3b5 (diff)
Fixing bug with max cycle/instruction/cta + bug with C++ name de-mangling with spaces (e.g., using templates)
-rw-r--r--src/cuda-sim/ptx_ir.cc6
-rw-r--r--src/gpgpu-sim/gpu-sim.cc41
-rw-r--r--src/gpgpu-sim/gpu-sim.h16
-rw-r--r--src/gpgpu-sim/shader.cc6
-rw-r--r--src/gpgpusim_entrypoint.cc14
-rw-r--r--src/stream_manager.cc51
-rw-r--r--src/stream_manager.h1
7 files changed, 104 insertions, 31 deletions
diff --git a/src/cuda-sim/ptx_ir.cc b/src/cuda-sim/ptx_ir.cc
index 6943b48..fa37cc4 100644
--- a/src/cuda-sim/ptx_ir.cc
+++ b/src/cuda-sim/ptx_ir.cc
@@ -1256,10 +1256,12 @@ unsigned function_info::print_insn( unsigned pc, FILE * fp ) const
unsigned index = pc - m_start_PC;
char command[1024];
char buffer[1024];
- snprintf(command,1024,"c++filt -p %s",m_name.c_str());
+ memset(command, 0, 1024);
+ memset(buffer, 0, 1024);
+ snprintf(command,1024,"c++filt -p %s\n",m_name.c_str());
FILE *p = popen(command,"r");
buffer[0]=0;
- fscanf(p,"%1023s",buffer);
+ fgets(buffer, 1023, p);
fprintf(fp,"%s",buffer);
if ( index >= m_instr_mem_size ) {
fprintf(fp, "<past last instruction (max pc=%u)>", m_start_PC + m_instr_mem_size - 1 );
diff --git a/src/gpgpu-sim/gpu-sim.cc b/src/gpgpu-sim/gpu-sim.cc
index 8b47c28..32de005 100644
--- a/src/gpgpu-sim/gpu-sim.cc
+++ b/src/gpgpu-sim/gpu-sim.cc
@@ -486,12 +486,29 @@ bool gpgpu_sim::can_start_kernel()
return false;
}
-bool gpgpu_sim::get_more_cta_left() const
-{
+bool gpgpu_sim::hit_max_cta_count() const {
if (m_config.gpu_max_cta_opt != 0) {
- if( m_total_cta_launched >= m_config.gpu_max_cta_opt )
- return false;
+ if( (gpu_tot_issued_cta + m_total_cta_launched) >= m_config.gpu_max_cta_opt )
+ return true;
}
+ return false;
+}
+
+bool gpgpu_sim::kernel_more_cta_left(kernel_info_t *kernel) const {
+ if(hit_max_cta_count())
+ return false;
+
+ if(kernel && !kernel->no_more_ctas_to_run())
+ return true;
+
+ return false;
+}
+
+bool gpgpu_sim::get_more_cta_left() const
+{
+ if(hit_max_cta_count())
+ return false;
+
for(unsigned n=0; n < m_running_kernels.size(); n++ ) {
if( m_running_kernels[n] && !m_running_kernels[n]->no_more_ctas_to_run() )
return true;
@@ -503,7 +520,7 @@ kernel_info_t *gpgpu_sim::select_kernel()
{
for(unsigned n=0; n < m_running_kernels.size(); n++ ) {
unsigned idx = (n+m_last_issued_kernel+1)%m_config.max_concurrent_kernel;
- if( m_running_kernels[idx] && !m_running_kernels[idx]->no_more_ctas_to_run() ) {
+ if( kernel_more_cta_left(m_running_kernels[idx] ){
m_last_issued_kernel=idx;
// record this kernel for stat print if it is the first time this kernel is selected for execution
unsigned launch_uid = m_running_kernels[idx]->get_uid();
@@ -541,6 +558,16 @@ void gpgpu_sim::set_kernel_done( kernel_info_t *kernel )
assert( k != m_running_kernels.end() );
}
+void gpgpu_sim::stop_all_running_kernels(){
+ std::vector<kernel_info_t *>::iterator k;
+ for(k = m_running_kernels.begin(); k != m_running_kernels.end(); ++k){
+ if(*k != NULL){ // If a kernel is active
+ set_kernel_done(*k); // Stop the kernel
+ assert(*k==NULL);
+ }
+ }
+}
+
void set_ptx_warp_size(const struct core_config * warp_size);
gpgpu_sim::gpgpu_sim( const gpgpu_sim_config &config )
@@ -564,6 +591,7 @@ gpgpu_sim::gpgpu_sim( const gpgpu_sim_config &config )
gpu_sim_insn = 0;
gpu_tot_sim_insn = 0;
gpu_tot_issued_cta = 0;
+ m_total_cta_launched = 0;
gpu_deadlock = false;
@@ -720,6 +748,7 @@ void gpgpu_sim::update_stats() {
m_memory_stats->memlatstat_lat_pw();
gpu_tot_sim_cycle += gpu_sim_cycle;
gpu_tot_sim_insn += gpu_sim_insn;
+ gpu_tot_issued_cta += m_total_cta_launched;
}
void gpgpu_sim::print_stats()
@@ -892,7 +921,7 @@ void gpgpu_sim::gpu_print_stat()
printf("gpu_tot_sim_cycle = %lld\n", gpu_tot_sim_cycle+gpu_sim_cycle);
printf("gpu_tot_sim_insn = %lld\n", gpu_tot_sim_insn+gpu_sim_insn);
printf("gpu_tot_ipc = %12.4f\n", (float)(gpu_tot_sim_insn+gpu_sim_insn) / (gpu_tot_sim_cycle+gpu_sim_cycle));
- printf("gpu_tot_issued_cta = %lld\n", gpu_tot_issued_cta);
+ printf("gpu_tot_issued_cta = %lld\n", gpu_tot_issued_cta + m_total_cta_launched);
diff --git a/src/gpgpu-sim/gpu-sim.h b/src/gpgpu-sim/gpu-sim.h
index 4e6b7a5..33fffd3 100644
--- a/src/gpgpu-sim/gpu-sim.h
+++ b/src/gpgpu-sim/gpu-sim.h
@@ -372,10 +372,16 @@ public:
bool can_start_kernel();
unsigned finished_kernel();
void set_kernel_done( kernel_info_t *kernel );
+ void stop_all_running_kernels();
void init();
void cycle();
bool active();
+ bool cycle_insn_cta_max_hit() {
+ return (m_config.gpu_max_cycle_opt && (gpu_tot_sim_cycle + gpu_sim_cycle) >= m_config.gpu_max_cycle_opt) ||
+ (m_config.gpu_max_insn_opt && (gpu_tot_sim_insn + gpu_sim_insn) >= m_config.gpu_max_insn_opt) ||
+ (m_config.gpu_max_cta_opt && (gpu_tot_issued_cta >= m_config.gpu_max_cta_opt) );
+ }
void print_stats();
void update_stats();
void deadlock_check();
@@ -391,6 +397,8 @@ public:
unsigned threads_per_core() const;
bool get_more_cta_left() const;
+ bool kernel_more_cta_left(kernel_info_t *kernel) const;
+ bool hit_max_cta_count() const;
kernel_info_t *select_kernel();
const gpgpu_sim_config &get_config() const { return m_config; }
@@ -445,7 +453,10 @@ private:
unsigned m_last_issued_kernel;
std::list<unsigned> m_finished_kernel;
- unsigned m_total_cta_launched;
+ // m_total_cta_launched == per-kernel count. gpu_tot_issued_cta == global count.
+ unsigned long long m_total_cta_launched;
+ unsigned long long gpu_tot_issued_cta;
+
unsigned m_last_cluster_issue;
float * average_pipeline_duty_cycle;
float * active_sms;
@@ -470,7 +481,6 @@ private:
class memory_stats_t *m_memory_stats;
class power_stat_t *m_power_stats;
class gpgpu_sim_wrapper *m_gpgpusim_wrapper;
- unsigned long long gpu_tot_issued_cta;
unsigned long long last_gpu_sim_insn;
unsigned long long last_liveness_message_time;
@@ -488,8 +498,6 @@ public:
unsigned long long gpu_sim_insn_last_update;
unsigned gpu_sim_insn_last_update_sid;
-
-
FuncCache get_cache_config(std::string kernel_name);
void set_cache_config(std::string kernel_name, FuncCache cacheConfig );
bool has_special_cache_config(std::string kernel_name);
diff --git a/src/gpgpu-sim/shader.cc b/src/gpgpu-sim/shader.cc
index f3ad1b0..ff2fac7 100644
--- a/src/gpgpu-sim/shader.cc
+++ b/src/gpgpu-sim/shader.cc
@@ -21,7 +21,7 @@
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-// SERVICES; LOSSp OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1932,7 +1932,7 @@ void shader_core_ctx::register_cta_thread_exit( unsigned cta_num )
m_kernel->dec_running();
printf("GPGPU-Sim uArch: Shader %u empty (release kernel %u \'%s\').\n", m_sid, m_kernel->get_uid(),
m_kernel->name().c_str() );
- if( m_kernel->no_more_ctas_to_run() ) {
+ if( !m_gpu->kernel_more_cta_left(m_kernel) ) {
if( !m_kernel->running() ) {
printf("GPGPU-Sim uArch: GPU detected kernel \'%s\' finished on shader %u.\n", m_kernel->name().c_str(), m_sid );
m_gpu->set_kernel_done( m_kernel );
@@ -3246,7 +3246,7 @@ unsigned simt_core_cluster::issue_block2core()
}
}
kernel_info_t *kernel = m_core[core]->get_kernel();
- if( kernel && !kernel->no_more_ctas_to_run() && (m_core[core]->get_n_active_cta() < m_config->max_cta(*kernel)) ) {
+ if( m_gpu->kernel_more_cta_left(kernel) && (m_core[core]->get_n_active_cta() < m_config->max_cta(*kernel)) ) {
m_core[core]->issue_block2core(*kernel);
num_blocks_issued++;
m_cta_issue_next_core=core;
diff --git a/src/gpgpusim_entrypoint.cc b/src/gpgpusim_entrypoint.cc
index 28f909b..6ba38eb 100644
--- a/src/gpgpusim_entrypoint.cc
+++ b/src/gpgpusim_entrypoint.cc
@@ -96,10 +96,10 @@ void *gpgpu_sim_thread_concurrent(void*)
{
// concurrent kernel execution simulation thread
do {
- if(g_debug_execution >= 3) {
- printf("GPGPU-Sim: *** simulation thread starting and spinning waiting for work ***\n");
- fflush(stdout);
- }
+ if(g_debug_execution >= 3) {
+ printf("GPGPU-Sim: *** simulation thread starting and spinning waiting for work ***\n");
+ fflush(stdout);
+ }
while( g_stream_manager->empty_protected() && !g_sim_done )
;
if(g_debug_execution >= 3) {
@@ -131,7 +131,13 @@ void *gpgpu_sim_thread_concurrent(void*)
g_the_gpu->cycle();
sim_cycles = true;
g_the_gpu->deadlock_check();
+ }else {
+ if(g_the_gpu->cycle_insn_cta_max_hit()){
+ g_stream_manager->stop_all_running_kernels();
+ g_sim_done = true;
+ }
}
+
active=g_the_gpu->active() || !g_stream_manager->empty_protected();
} while( active );
if(g_debug_execution >= 3) {
diff --git a/src/stream_manager.cc b/src/stream_manager.cc
index 07cd44a..dd42f0a 100644
--- a/src/stream_manager.cc
+++ b/src/stream_manager.cc
@@ -223,19 +223,38 @@ bool stream_manager::register_finished_kernel(unsigned grid_uid)
{
// called by gpu simulation thread
if(grid_uid > 0){
- CUstream_st *stream = m_grid_id_to_stream[grid_uid];
- kernel_info_t *kernel = stream->front().get_kernel();
- assert( grid_uid == kernel->get_uid() );
- stream->record_next_done();
- m_grid_id_to_stream.erase(grid_uid);
- delete kernel;
- return true;
+ CUstream_st *stream = m_grid_id_to_stream[grid_uid];
+ kernel_info_t *kernel = stream->front().get_kernel();
+ assert( grid_uid == kernel->get_uid() );
+ stream->record_next_done();
+ m_grid_id_to_stream.erase(grid_uid);
+ delete kernel;
+ return true;
}else{
return false;
}
return false;
}
+void stream_manager::stop_all_running_kernels(){
+ pthread_mutex_lock(&m_lock);
+
+ // Signal m_gpu to stop all running kernels
+ m_gpu->stop_all_running_kernels();
+
+ // Clean up all streams waiting on running kernels
+ int count=0;
+ while(check_finished_kernel()){
+ count++;
+ }
+
+ // If any kernels completed, print out the current stats
+ if(count > 0)
+ m_gpu->print_stats();
+
+ pthread_mutex_unlock(&m_lock);
+}
+
stream_operation stream_manager::front()
{
// called by gpu simulation thread
@@ -366,11 +385,19 @@ void stream_manager::push( stream_operation op )
};
pthread_mutex_lock(&m_lock);
- if( stream && !m_cuda_launch_blocking ) {
- stream->push(op);
- } else {
- op.set_stream(&m_stream_zero);
- m_stream_zero.push(op);
+ if(!m_gpu->cycle_insn_cta_max_hit()) {
+ // Accept the stream operation if the maximum cycle/instruction/cta counts are not triggered
+ if( stream && !m_cuda_launch_blocking ) {
+ stream->push(op);
+ } else {
+ op.set_stream(&m_stream_zero);
+ m_stream_zero.push(op);
+ }
+ }else {
+ // Otherwise, ignore operation and continue
+ printf("GPGPU-Sim API: Maximum cycle, instruction, or CTA count hit. Skipping:");
+ op.print(stdout);
+ printf("\n");
}
if(g_debug_execution >= 3)
print_impl(stdout);
diff --git a/src/stream_manager.h b/src/stream_manager.h
index 7275402..701b33c 100644
--- a/src/stream_manager.h
+++ b/src/stream_manager.h
@@ -246,6 +246,7 @@ public:
void print( FILE *fp);
void push( stream_operation op );
bool operation(bool * sim);
+ void stop_all_running_kernels();
private:
void print_impl( FILE *fp);