How to compile ClangTool and feature extraction

galabc edited this page Aug 2, 2018 · 6 revisions

install LLVM*

module load clang/6.0.0
module load cmake/3.9.0
wget http://releases.llvm.org/6.0.0/llvm-6.0.0.src.tar.xz
tar -xvf llvm-6.0.0.src.tar.xz
cd llvm-6.0.0.src/ && mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86" ..
make -j

Build Clang on Rostam

export PATH=path/to/LLVM/llvm-6.0.0.src/build/bin/:$PATH
wget http://releases.llvm.org/6.0.0/cfe-6.0.0.src.tar.xz
tar -xvf cfe-6.0.0.src.tar.xz
cd cfe-6.0.0.src/ 
cd tools
mkdir extra && cd extra
wget http://releases.llvm.org/6.0.0/clang-tools-extra-6.0.0.src.tar.xz
tar -xvf clang-tools-extra-6.0.0.src.tar.xz
cp -r clang-tools-extra-6.0.0.src/* .
cd ../..
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j 

Build ClangTool

mkdir ../tools/extra/loop-convert
cp path/to/hpxML//ClangTool/LoopConvert.cpp ../tools/extra/loop-convert
cp path/to/hpxML/ClangTool/CMakeLists.txt ../tools/extra/loop-convert
echo 'add_subdirectory(loop-convert)' >> ../tools/extra/CMakeLists.txt
cmake ..
make loop-convert

The executable can be used in two ways

Data Generation Mode

In this mode, the executable will print features in the console which is usefull to make a dataset. To print out features, the boolean parameter -P must be put to TRUE.

path/to/cfe-6.0.0.src/build/bin/loop-convert main.cpp -P=TRUE -- -Iinclude path/to/hpx path/to/Boost

This will output the static in the console which is useful when you want to generate data.

Loop Conversion Mode

In this mode, the executable will convert HPX for-each loops that contains the execution policies par_if,adaptive_chunk_size,make_prefetcher_policy. To convert a loop, the parameter -C must be set to TRUE.

path/to/cfe-6.0.0.src/build/bin/loop-convert main.cpp -C=TRUE -- -Iinclude path/to/hpx path/to/Boost

when using this command on a main.cpp that contains some of these loops

hpx::parallel::for_each(hpx::parallel::par_if, time_range.begin(), time_range.end(), f);

hpx::parallel::for_each(hpx::parallel::par.with(hpx::parallel::adaptive_chunk_size()), time_range.begin(), time_range.end(), f);	

hpx::parallel::for_each(hpx::parallel::execution::make_prefetcher_policy(policy, prefetching_distance_factor, ...), time_range.begin(), time_range.end(), f);

These will be changed to:

hpx::parallel::for_each(hpx::parallel::par, time_range.begin(), time_range.end(), f);

hpx::parallel::for_each(hpx::parallel::par.with(hpx::parallel::chunk_size_determination(EXTRACTED_STATICE_DYNAMIC_FEATURES)), time_range.begin(), time_range.end(), f);	

hpx::parallel::for_each(hpx::parallel::execution::make_prefetcher_policy(policy, hpx::parallel::prefetching_distance_determination(EXTRACTED_STATICE_DYNAMIC_FEATURES), ...), time_range.begin(), time_range.end(), f);

#Note the execution policies par_if, adaptive_chunk_size() and make_prefetcher_policy() are not defined and therefore the compiler will bring an error unless they are defined as empty structures

For example

namespace hpx { namespace parallel { struct adaptive_chunk_size {};}}
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.