PRUNERS / archer

Archer, a data race detection tool for large OpenMP applications
https://pruners.github.io/archer
Apache License 2.0
62 stars 13 forks source link

Mac OSX #26

Closed SumedhArani closed 6 years ago

SumedhArani commented 7 years ago

Greetings !!

With great amount of help from @simoatze, I was able to finally get a working installation of clang-archer with OMPT-support on my machine. These were the necessary changes.

Thank you.

jprotze commented 7 years ago

I changed the base of the PR to be race_aggregation, because that's the base and provides a better readable diff. The original PR would have merged all changes into master

SumedhArani commented 7 years ago

Greetings! @dongahn @simoatze @jprotze This is the similar implementation of the task that I did last time. This is to check if I'm in line with your vision. This happens to be a naive case but I intended to use this if I should continue with the other case as well?

input.c

#include <stdio.h>
#define N 1000

int main (int argc, char **argv)
{
  int a;
  int b;
#pragma omp parallel for
{
  for (int i = 0; i < N - 1; i++) {
    a=i;
  }
}

#pragma omp parallel for
 {
  for (int i = 0; i < N - 1; i++) {
    b=i;
  }
 }
  return 0;
}

Archer generates six warnings for the above test case.

And this is the output I generate

current_report = 0x108503568 : Unique memory location
current_report = 0x108503568 : Unique line number

current_report = 0x108506ba8 : Duplicate of report 0x108503568 on basis of memory location
current_report = 0x108506ba8 : Duplicate of report 0x108503568 on basis of line number

current_report = 0x10850a1e8 : Duplicate of report 0x108503568 on basis of memory location
current_report = 0x10850a1e8 : Duplicate of report 0x108503568 on basis of line number

current_report = 0x108503568 : Unique memory location
current_report = 0x108503568 : Unique line number

current_report = 0x108506ba8 : Duplicate of report 0x108503568 on basis of memory location
current_report = 0x108506ba8 : Duplicate of report 0x108503568 on basis of line number

current_report = 0x10850d828 : Duplicate of report 0x108503568 on basis of memory location
current_report = 0x10850d828 : Duplicate of report 0x108503568 on basis of line number

Does this look good to you? I've used C++ STL map to reduce the search time @dongahn .

Should I proceed ahead with the other cases or do you intend to have some other changes as well in the output generated?

SumedhArani commented 7 years ago

test1.c


#include <stdio.h>     
#define N 1000

int main (int argc, char **argv) { int a[N];

pragma omp parallel for

for (int i = 0; i < N - 1; i++) { a[i] = a[i + 1]; } return 0; }

_Archer reports three warnings for the above case_

**The newer commit does reduction on the basis of line number in a file.**

The output generated by my code will be like this after every report. I've just redirected the output for convenience for now.

current_report = 0x105803568 : Unique memory location current_report = 0x105803568 : Unique line number

current_report = 0x105806ba8 : Unique memory location current_report = 0x105806ba8 : Duplicate of report 0x105803568 on basis of line number

current_report = 0x10580a1e8 : Unique memory location current_report = 0x10580a1e8 : Duplicate of report 0x105803568 on basis of line number


The above report is as such because there is an array and hence different memory locations are being updated but are of the same array and hence the data race.

Please let me know what you think of it @dongahn @simoatze @jprotze !
dongahn commented 7 years ago

Thanks! We're all a bit preoccupied at the moment but I will take a look at your work once I get out of the woods.

SumedhArani commented 7 years ago

That's no problem at all @dongahn !:)

SumedhArani commented 7 years ago

@dongahn @simoatze @jprotze Were you able to take a look at my work?

Thank you.

simoatze commented 7 years ago

@SumedhArani I was able to take a look to the code but I didn't try it. We are all overwhelmed with deadlines. Looking at the code looks ok, but to me doesn't seem that it will report the same type of report of archer (e.g., looks like many info are missing). Could you please make a simple example with a race that with the original Archer would be reported many times and then apply your reduction and show us your reduced report? Thanks!

p.s.: I was able to compiler Archer on MacOS, thanks!

SumedhArani commented 7 years ago

@simoatze Sorry for the late reply. I actually had replied back two days ago itself but somehow the comment didn't get posted.

For the following test case

#include <stdio.h>     
#define N 1000

int main (int argc, char **argv)
{
  int a[N];

#pragma omp parallel for
  for (int i = 0; i < N - 1; i++) {
    a[i] = a[i + 1];
  }
  return 0;
}

This is the output by my program

Arani:test_cases Sumedh$ clang-archer test1.c 
Arani:test_cases Sumedh$ ./a.out 
==================
WARNING: ThreadSanitizer: data race (pid=14338)
  Read of size 4 at 0x7fff5c3f2c78 by main thread:
    #0 .omp_outlined. /Users/Sumedh/Software/ARCHER_dev/test_cases/test1.c:10:12 (a.out:x86_64+0x10001907f)
    #1 __kmp_invoke_microtask <null> (libomp.dylib:x86_64+0x42022)
    #2 start <null> (libdyld.dylib:x86_64+0x5254)

  Previous write of size 4 at 0x7fff5c3f2c78 by thread T2:
    #0 .omp_outlined. /Users/Sumedh/Software/ARCHER_dev/test_cases/test1.c:10:10 (a.out:x86_64+0x1000190b3)
    #1 __kmp_invoke_microtask <null> (libomp.dylib:x86_64+0x42022)

  Location is stack of main thread.

  Thread T2 (tid=216736, running) created by main thread at:
    #0 pthread_create <null> (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x74ae)
    #1 __kmp_create_worker <null> (libomp.dylib:x86_64+0x21db7)
    #2 start <null> (libdyld.dylib:x86_64+0x5254)

SUMMARY: ThreadSanitizer: data race /Users/Sumedh/Software/ARCHER_dev/test_cases/test1.c:10:12 in .omp_outlined.
==================
current_report = 0x105f03568 : Unique memory location
current_report = 0x105f03568 : Unique line number
==================
WARNING: ThreadSanitizer: data race (pid=14338)
  Read of size 4 at 0x7fff5c3f3060 by thread T2:
    #0 .omp_outlined. /Users/Sumedh/Software/ARCHER_dev/test_cases/test1.c:10:12 (a.out:x86_64+0x10001907f)
    #1 __kmp_invoke_microtask <null> (libomp.dylib:x86_64+0x42022)

  Previous write of size 4 at 0x7fff5c3f3060 by thread T3:
    #0 .omp_outlined. /Users/Sumedh/Software/ARCHER_dev/test_cases/test1.c:10:10 (a.out:x86_64+0x1000190b3)
    #1 __kmp_invoke_microtask <null> (libomp.dylib:x86_64+0x42022)

  Location is stack of main thread.

  Thread T2 (tid=216736, running) created by main thread at:
    #0 pthread_create <null> (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x74ae)
    #1 __kmp_create_worker <null> (libomp.dylib:x86_64+0x21db7)
    #2 start <null> (libdyld.dylib:x86_64+0x5254)

  Thread T3 (tid=216737, running) created by main thread at:
    #0 pthread_create <null> (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x74ae)
    #1 __kmp_create_worker <null> (libomp.dylib:x86_64+0x21db7)
    #2 start <null> (libdyld.dylib:x86_64+0x5254)

SUMMARY: ThreadSanitizer: data race /Users/Sumedh/Software/ARCHER_dev/test_cases/test1.c:10:12 in .omp_outlined.
==================
current_report = 0x105f06ba8 : Unique memory location
current_report = 0x105f06ba8 : Duplicate of report 0x105f03568 on basis of line number
==================
WARNING: ThreadSanitizer: data race (pid=14338)
  Read of size 4 at 0x7fff5c3f3448 by thread T3:
    #0 .omp_outlined. /Users/Sumedh/Software/ARCHER_dev/test_cases/test1.c:10:12 (a.out:x86_64+0x10001907f)
    #1 __kmp_invoke_microtask <null> (libomp.dylib:x86_64+0x42022)

  Previous write of size 4 at 0x7fff5c3f3448 by thread T4:
    #0 .omp_outlined. /Users/Sumedh/Software/ARCHER_dev/test_cases/test1.c:10:10 (a.out:x86_64+0x1000190b3)
    #1 __kmp_invoke_microtask <null> (libomp.dylib:x86_64+0x42022)

  Location is stack of main thread.

  Thread T3 (tid=216737, running) created by main thread at:
    #0 pthread_create <null> (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x74ae)
    #1 __kmp_create_worker <null> (libomp.dylib:x86_64+0x21db7)
    #2 start <null> (libdyld.dylib:x86_64+0x5254)

  Thread T4 (tid=216738, running) created by main thread at:
    #0 pthread_create <null> (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x74ae)
    #1 __kmp_create_worker <null> (libomp.dylib:x86_64+0x21db7)
    #2 start <null> (libdyld.dylib:x86_64+0x5254)

SUMMARY: ThreadSanitizer: data race /Users/Sumedh/Software/ARCHER_dev/test_cases/test1.c:10:12 in .omp_outlined.
==================
current_report = 0x105f0a1e8 : Unique memory location
current_report = 0x105f0a1e8 : Duplicate of report 0x105f03568 on basis of line number
ThreadSanitizer: reported 3 warnings

I've given my specific output to stdout compared to report of tsan being printed out to the stderr. Collecting the output generated other than that shown by tsan is as follows

current_report = 0x105803568 : Unique memory location
current_report = 0x105803568 : Unique line number

current_report = 0x105806ba8 : Unique memory location
current_report = 0x105806ba8 : Duplicate of report 0x105803568 on basis of line number

current_report = 0x10580a1e8 : Unique memory location
current_report = 0x10580a1e8 : Duplicate of report 0x105803568 on basis of line number

This output is embedded within the output of tsan report. This is because tsan supports either you print everything or you don't print anything. This reduction is done using the tsan_on_report function.

Have a check and do let me know.

Thank you.