Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attach original file/info in the transformed file #132

Open
yanyh15 opened this issue Dec 9, 2022 · 0 comments
Open

Attach original file/info in the transformed file #132

yanyh15 opened this issue Dec 9, 2022 · 0 comments

Comments

@yanyh15
Copy link
Member

yanyh15 commented Dec 9, 2022

Just like how c preprocessing attaches the original filename/line in the processed file. We can add the similar kind info to the transformed file. I believe this is actually used by the debugger. e.g. The original file:

  1 #include<stdio.h>
  2 #include<omp.h>
  3 int main(int argc, char * argv[])
  4 {
  5     //Initialize array     
  6     int arr[] = {1, 2, 3, 4, 5};
  7     int sum = 0;
  8 
  9     //Calculate length of array arr    
 10     int length = sizeof(arr)/sizeof(arr[0]);
 11 
 12     //Loop through the array to calculate sum of elements
 13 #pragma omp parallel
 14     printf("thread %d of team %d\n", omp_get_thread_num(), omp_get_num_threads());
 15 #pragma omp parallel for reduction(+:sum)
 16     for (int i = 0; i < length; i++) {
 17        sum = sum + arr[i];
 18     }
 19     printf("Sum of all the elements of an array: %d\n", sum);
 20     return 0;
 21 }


The preprocessed file:

  1 # 1 "sum_openmp.c"
  2 # 1 "<built-in>"
  3 # 1 "<command-line>"
  4 # 1 "/usr/include/stdc-predef.h" 1 3 4
  5 # 1 "<command-line>" 2
  6 # 1 "sum_openmp.c"
  7 # 1 "/usr/include/stdio.h" 1 3 4
  8 # 27 "/usr/include/stdio.h" 3 4
  9 # 1 "/usr/include/x86_64-linux-gnu/bits/libc-header-start.h" 1 3 4
 10 # 33 "/usr/include/x86_64-linux-gnu/bits/libc-header-start.h" 3 4
 11 # 1 "/usr/include/features.h" 1 3 4
 12 # 461 "/usr/include/features.h" 3 4
 13 # 1 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 1 3 4

.....

886 # 3 "sum_openmp.c" 2
887 
888 # 3 "sum_openmp.c"
889 int main(int argc, char * argv[])
890 {
891 
892     int arr[] = {1, 2, 3, 4, 5};
893     int sum = 0;
894 
895     
896     int length = sizeof(arr)/sizeof(arr[0]);
897 
898 
899         
900 # 13 "sum_openmp.c"
901 #pragma omp parallel
902 # 13 "sum_openmp.c"
903     
904     printf("thread %d of team %d\n", omp_get_thread_num(), omp_get_num_threads());
905         
906 # 15 "sum_openmp.c"
907 #pragma omp parallel for reduction(+:sum)
908 # 15 "sum_openmp.c"
909     
910     for (int i = 0; i < length; i++) {
911        sum = sum + arr[i];
912     }
913     printf("Sum of all the elements of an array: %d\n", sum);
914     return 0;
915 }



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant