Skip to content

Commit

Permalink
royal viking battles against my auto-formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
justend29 committed Jul 25, 2022
1 parent 72eeee9 commit 428454a
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions doc/tutorial/mutli_arch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ What is going on inside `compute` ?
afterward but understand that they are arbitrary. To do so, we use *Immediately Invoked Lambda
Expressions* to perform this initialisation.
+ Next, we load the `compute_kernel` symbol from the handle we just loaded. As opening and
fetching pointer to symbol can be costly, we will make it so those tasks are done once by storing
both results in static variables.
fetching pointer to symbol can be costly, we will make it so those tasks are done once by
storing both results in static variables.
+ Once everything is loaded and setup, we call the function pointer with the appropriate
parameters.
parameters.
Obviously, in realistic settings you would actually care about runtime issues, check that every
pointer are non-null, and use functions like `dlerror` to find out what would have caused an issue.
Expand Down Expand Up @@ -135,18 +135,18 @@ Let's get into the details:
**EVE** installation path, you may have to specify `CMAKE_PREFIX_PATH` for CMake to find it.
+ We define an INTERFACE library that use the main **EVE** interface and add some customisation.
+ We call `eve_build_variants` to build a set of targets. The base name will be `compute` and
there are three different target suffixes: `basic`, `advanced`, `perfect`. For each of those, the
following options will be used: `-msse2`, `-msse4.1`, `-march=haswell`. Each target is compiled
with its corresponding options. In the end, we expect three libraries to be compiled:
`libcompute_basic.so`, `libcompute_advanced.so`, and `libcompute_perfect.so`. Notice how the
suffixes are arbitrary. They just need to correspond to any naming scheme you see fit and those
names will have to be used in the dynamic loading function.
there are three different target suffixes: `basic`, `advanced`, `perfect`. For each of those,
the following options will be used: `-msse2`, `-msse4.1`, `-march=haswell`. Each target is
compiled with its corresponding options. In the end, we expect three libraries to be compiled:
`libcompute_basic.so`, `libcompute_advanced.so`, and `libcompute_perfect.so`. Notice how the
suffixes are arbitrary. They just need to correspond to any naming scheme you see fit and those
names will have to be used in the dynamic loading function.
+ To perform this compilation, we use the `setup` interface we customized earlier.
+ We add our executable target that just compiles a main file and the compute function. To be sure
we don't forget to compile the libraries when we compile the main executable, we use the
exported `eve_compute_variants` macro that contains the list of targets created by
`eve_build_variants`. Because we use `dlopen`, we need to link with the appropriate library which is
conveniently provided by `CMAKE_DL_LIBS`.
exported `eve_compute_variants` macro that contains the list of targets created by
`eve_build_variants`. Because we use `dlopen`, we need to link with the appropriate library
which is conveniently provided by `CMAKE_DL_LIBS`.
That's all. Once generated, this CMake file will let you compile the `multi-arch` target that will
trigger the compilation of the three libraries. Once compiled, the execution of the multi-arch
Expand All @@ -158,9 +158,7 @@ executable will produce some output:
>> compute with: X86 AVX2 (with FMA3 support)
>> eve::wide is: 8 elements large.
After:
2 2.82843 3.4641
4 4.47214 4.89898 5.2915 5.65685 6.32456 8.94427 10.9545 12.6491 14.1421 15.4919 16.7332 17.8885 18.9737
20 63.2456 200
2 2.82843 3.4641 4 4.47214 4.89898 5.2915 5.65685 6.32456 8.94427 10.9545 12.6491 14.1421 15.4919 16.7332 17.8885 18.9737 20 63.2456 200
```
The complete project is available as in the `examples/multi-arch` folder. As an exercise,
Expand Down

0 comments on commit 428454a

Please sign in to comment.