Analyzers
Talk to fellow users of Intel Analyzer tools (Intel VTune™ Profiler, Intel Advisor)
4998 Discussions

Parallel Inspector reporting Data Race in Microsoft PPL

Sai_V_
Beginner
300 Views

Hello,

I am trying to use Intel Parallel Inspector for validating a concurrent program I wrote using VC++12 STL async which is implemented using PPL Thread Pool. On execution the Inspector doesn't complain of any problems in the application but identified data races in PPL's Work Stealing Queues. But with all reasoning I did I couldn't understand why Inspector is reporting a data race as well how can PPL thread pool contain a data race which I suppose is well tested. An example of a problem reported is the construction of the task created and the access of the task status happens concurrently and has a data race. Here is the example code I used for this. I am using Visual Studio compiler 2013. Any help with this is appreciated. Let me know if I am missing something in this.

#include "stdafx.h"
#include <future>
#include <iostream>
#include <vector>
#include <thread>
#include <chrono>
using namespace std;

 


int main() {

    auto foo = []() {
        int sum = 0;
        for (int i = 0; i < 100; ++i)
            sum += i;
        return sum;
    };


    vector<future<int>> fs;
    int r[2];
    int i = 0;
    

    for (int i = 0; i < 2; ++i) {
        fs.push_back(async(foo));
    }

    for (auto& f : fs) {
         r = f.get();
        i++;
    }

    cout << r[0] << r[1] << endl;
    fs.clear();

    return 0;
}

0 Kudos
1 Reply
Mark_D_Intel
Employee
300 Views

Microsoft PPL and C++ futures are not supported by IXE.

It is common to see data races in parallel frameworks that IXE does not support.   One of the key properties of a parallel framework is to construct properly synchronized actions out of unsynchronized accesses.   For example, consider a simple implementation of a spin lock - multiple threads will race to access a shared location, and the first one to access will obtain the lock.  If IXE does not know this access is supposed to be a lock, then it will report a data race  (there is an API to communicate this information to IXE, for users with their own locks).

 

 

 

0 Kudos
Reply