summaryrefslogtreecommitdiff
path: root/src/gpgpu-sim
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpgpu-sim')
-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
3 files changed, 50 insertions, 13 deletions
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;