Skip to content

Commit

Permalink
cleaning up windows config
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-eschmann committed Feb 13, 2024
1 parent 8869aae commit eeee39f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/build
/cmake-build-debug
/cmake-build-release
/cmake-build-release-visual-studio
/.idea
9 changes: 3 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#set(RL_TOOLS_BACKEND_ENABLE_MKL ON) # if you have MKL installed (fastest on Intel)
#set(RL_TOOLS_BACKEND_ENABLE_OPENBLAS ON) # if you have OpenBLAS installed
#set(RL_TOOLS_BACKEND_ENABLE_ACCELERATE ON) # if you are on macOS (fastest on Apple Silicon)
set(RL_TOOLS_DISABLE_TARGETS ON)
add_subdirectory(external/rl_tools)

add_executable(my_pendulum
Expand All @@ -10,11 +9,9 @@ add_executable(my_pendulum
#target_compile_definitions(my_pendulum PRIVATE BENCHMARK)
target_link_libraries(my_pendulum PRIVATE RLtools::RLtools)

if(MSVC)
target_compile_options(my_pendulum PRIVATE /arch:AVX2)
target_compile_options(my_pendulum PRIVATE /fp:fast)
target_compile_options(my_pendulum PRIVATE /O2)
else()


if(NOT MSVC)
target_compile_options(my_pendulum PRIVATE -Ofast)
if(NOT APPLE)
target_compile_options(my_pendulum PRIVATE -march=native)
Expand Down
21 changes: 15 additions & 6 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# RLtools Example: Implementing a Custom Environment

## UNIX (Linux / macOS)
```
git clone https://github.com/rl-tools/example
cd example
Expand All @@ -11,16 +12,24 @@ cmake --build .
./src/my_pendulum
```

This example should work out of the box, but it is relatively slow if you do not activate one of the BLAS backends. Depending on your platform uncomment the `set(RL_TOOLS_BACKEND_ENABLE_XXX ON)` line in `CMakeLists.txt` and re-run the previous steps to dispatch to the optimized BLAS routines:


## Windows
On windows you should use `cmake --build . --config Release` to build the executable. If you have [Intel MKL/oneMKL](https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-download.html) installed you should use the `Command Prompt` (not PowerShell) and initialize the MKL environment variables before running the commands:

```
"C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
git clone https://github.com/rl-tools/example
cd example
git submodule update --init external/rl_tools
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .
./src/my_pendulum
cmake --build . --config Release
Release\my_pendulum.exe
```

This should be substantially faster. To make it even fast you can disable the evaluation episodes (by enabling the `BENCHMARK` flag in the `CMakeLists.txt`). Furthermore, you can play with options like `-Ofast` and `-march=native` depending on your CPU architecture. For reference, this takes about 600ms on an `i9-10885H` and about 300ms on an `Apple M3`.
## BLAS Backend & Optimizations


On windows you should use `cmake --build . --config Release` to build the executable.
This example should work out of the box, but it is relatively slow if you do not activate one of the BLAS backends. Depending on your platform uncomment the `set(RL_TOOLS_BACKEND_ENABLE_XXX ON)` line in `CMakeLists.txt` and re-run the previous cmake config and build steps to dispatch to the optimized BLAS routines:
This should be substantially faster. To make it even fast you can disable the evaluation episodes (by enabling the `BENCHMARK` flag in the `CMakeLists.txt`). Furthermore, you can play with options like `-Ofast` and `-march=native` depending on your CPU architecture. For reference, this takes about 600ms on an `i9-10885H` and about 300ms on an `Apple M3`.

0 comments on commit eeee39f

Please sign in to comment.