File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,11 @@ if(NOT LLVM_IR2VEC)
2424 # llvm_map_components_to_libnames(llvm_libs all)
2525 llvm_map_components_to_libnames(llvm_libs support core irreader analysis TransformUtils)
2626
27+ # Check if OpenMP is supported by the compiler
28+ find_package (OpenMP REQUIRED)
29+
2730 add_executable (${PROJECT_NAME} ${binsrc} )
28- target_link_libraries (${PROJECT_NAME} ${llvm_libs} objlib)
31+ target_link_libraries (${PROJECT_NAME} ${llvm_libs} objlib OpenMP::OpenMP_CXX )
2932 target_include_directories (${PROJECT_NAME} PRIVATE .)
3033
3134 add_library (objlib OBJECT ${libsrc} )
@@ -48,6 +51,9 @@ if(NOT LLVM_IR2VEC)
4851 PUBLIC_HEADER DESTINATION include
4952 RESOURCE DESTINATION ./)
5053
54+ # Add compiler flags for OpenMP
55+ target_compile_options (${PROJECT_NAME} PRIVATE ${OpenMP_CXX_FLAGS} )
56+
5157 add_subdirectory (test -suite)
5258
5359 add_custom_target (check
Original file line number Diff line number Diff line change 1212#include " llvm/Support/CommandLine.h"
1313#include < stdio.h>
1414#include < time.h>
15+ #include < omp.h>
1516
1617using namespace llvm ;
1718using namespace IR2Vec ;
@@ -69,6 +70,20 @@ void printVersion(raw_ostream &ostream) {
6970}
7071
7172int main (int argc, char **argv) {
73+ int N = 100 ;
74+ float a[N], b[N], result[N];
75+
76+ // Initialize arrays a and b with some values
77+ #pragma omp parallel for
78+ for (int i = 0 ; i < N; ++i) {
79+ a[i] = i;
80+ b[i] = i * 2 ;
81+ }
82+ #pragma omp parallel for
83+ for (int i = 0 ; i < N; ++i) {
84+ result[i] = a[i] + b[i];
85+ }
86+
7287 cl::SetVersionPrinter (printVersion);
7388 cl::HideUnrelatedOptions (category);
7489 cl::ParseCommandLineOptions (argc, argv);
You can’t perform that action at this time.
0 commit comments