CUDA Component: _cuda_update_control_state deadlock

Issue #121 resolved
john.rodgers created an issue

Using the latest version of PAPI, encountering a deadlock in _cuda_update_control_state for the following workflow:

  1. PAPI Init
  2. PAPI Thread Init
  3. Create Eventset
  4. PAPI Add Event1
  5. PAPI Add Event2

    1. Point where deadlock is observed

Source of deadlock appears to be a missing _papi_hwi_unlock in the if block on line 2406 just prior to the continue (encountered because the event added in step 4 is being skipped).

Preliminary tests show the following update (line 7 below) resolves the issue:

papi/src/components/cuda/linux-cuda.c::_cuda_update_control_state
...line 2404...
        /* if this event is already added continue to next ii, if not, mark it as being added */
        _papi_hwi_lock( COMPONENT_LOCK );
        if (gctxt->availEventIsBeingMeasuredInEventset[index] == 1) {       // If already being collected, skip it.
            SUBDBG("Skipping event %s which is already added\n", eventName);
            _papi_hwi_unlock( COMPONENT_LOCK );
            continue;
        } else {
            gctxt->availEventIsBeingMeasuredInEventset[index] = 1;          // If not being collected yet, flag it as being collected now.
        }

Comments (1)

  1. Giuseppe Congiu

    CUDA: Prevent component deadlock

    Add missing component unlock to _cuda_update_control_state to prevent deadlocks encountered when adding multiple events sequentially.

    Patch resolves issue #121

    → <<cset 24d6c781ef72>>

  2. Log in to comment