gpgpu-sim / gpgpu-sim_distribution

GPGPU-Sim provides a detailed simulation model of contemporary NVIDIA GPUs running CUDA and/or OpenCL workloads. It includes support for features such as TensorCores and CUDA Dynamic Parallelism as well as a performance visualization tool, AerialVisoin, and an integrated energy model, GPUWattch.
Other
1.11k stars 505 forks source link

Deadlock problem strategy? #226

Open jin8495 opened 3 years ago

jin8495 commented 3 years ago

Hi, I am facing deadlock on gpgpu-sim. Is there any strategy to solve deadlock problem? In the gpgpu-sim manual, there is a section for "debugging errors in performance simulation, deadlock". However, there is no content in it.

I found out that one thread is stuck in

void stream_manager::push(stream_operation op) {
    ...
    while (!empty()) {
        // sleep to prevent CPU hog by empty spin
        // sleep time increased exponentially ensure fast response when needed
        usleep(wait_amount);
        wait_amount *= 2;
        if (wait_amount > wait_cap) wait_amount = wait_cap;
    }
    ...
}

the other thread is stuck in

void *gpgpu_sim_thread_concurrent(void *ctx_ptr) {
    ...
    do {
        // check if a kernel has completed
        // launch operation on device if one is pending and can be run

        // Need to break this loop when a kernel completes. This was a 
        // source of non-deterministic behaviour in GPGPU-Sim (bug 147)
        // If another stream operation is available, g_the_gpu reamins active,
        // causing this loop to not break. If the next operation happens to be
        //  another kernel, the gpu is not re-initialized and the inter-kernel
        //  behaviour may be incorrect. Check that a kernel has finished and
        //  no other kernel is currently running.
        if (ctx->the_gpgpusim->g_stream_manager->operation(&sim_cycles) &&
            !ctx->the_gpgpusim->g_the_gpu()->active())
            break;

        // functional simulation
        if (ctx->the_gpgpusim->g_the_gpu->is_functional_sim()) {
            kernel_info_t *kernel =
                ctx->the_gpgpusim->g_the_gpu->get_functional_kernel();
            assert(kernel);
            ctx->the_gpgpusim->gpgpu_ctx->func_sim->gpgpu_cuda_ptx_sim_main_func(
                *kernel);
            ctx->the_gpgpusim->g_the_gpu->finish_functional_sim(kernel);
       }

       // performance simulation
       if (ctx->the_gpgpusim->g_the_gpu->active()) {
           ctx->the_gpgpusim->g_the_gpu->cycle();
           sim_cycles = true;
           ctx->the_gpgpusim->g_the_gpu->deadlock_check();
       } else {
          if (ctx->the_gpgpusim->g_the_gpu->cycle_insn_cta_max_hit()) {
              ctx->the_gpgpusim->g_stream_manager->stop_all_running_kernels();
              ctx->the_gpgpusim->g_sim_done = true;
              ctx->the_gpgpusim->break_limit = true;
         }
     }

    actvie = ctx->the_gpgpusim->g_the_gpu->active() ||
        !(ctx->the_gpgpusim->g_stream_manager->empty_protected());
} while (active && !ctx->the_gpgpusim->g_sim_done);

I did gdb backtrace to debug. But hard to find what went wrong.

my env: docker container - ubuntu 16.04 cuda 8.0 config : SM7_TITANV benchmark: ispass-2009 AES, RAY

SIPUNK commented 2 years ago

Hi, I have the same problem as you, have you solved it?

jin8495 commented 2 years ago

@SIPUNK No. I almost forgot this issue, because I decided to skip this problem.