From eeee39f63963f8ae103003e7fb4c42b89fe77256 Mon Sep 17 00:00:00 2001 From: Jonas Eschmann Date: Tue, 13 Feb 2024 21:08:17 +0400 Subject: [PATCH] cleaning up windows config --- .gitignore | 1 + CMakeLists.txt | 9 +++------ README.MD | 21 +++++++++++++++------ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 595532b..73a8dc4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /build /cmake-build-debug /cmake-build-release +/cmake-build-release-visual-studio /.idea diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ba8ab8..85c25ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 @@ -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) diff --git a/README.MD b/README.MD index c71a52c..a73ff50 100644 --- a/README.MD +++ b/README.MD @@ -1,5 +1,6 @@ # RLtools Example: Implementing a Custom Environment +## UNIX (Linux / macOS) ``` git clone https://github.com/rl-tools/example cd example @@ -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. \ No newline at end of file +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`.