dev container for OpenMP backend#8
Conversation
f64b124 to
bdf40ec
Compare
tretre91
left a comment
There was a problem hiding this comment.
I could get the dev container to work with both docker and podman on a desktop with
- Fedora 43
- docker 29.4.3
- podman 5.8.2
- vscode 1.119.0
| } | ||
| } | ||
| }, | ||
| "postStartCommand": "cmake -DKokkos_ROOT=/opt/kokkos-install -DKokkos_ENABLE_OPENMP=ON -B build" |
There was a problem hiding this comment.
No need to repeat Kokkos_ENABLE_OPENMP here.
Using CMAKE_EXPORT_COMPILE_COMMANDS=ON will tell CMake to produce a compile_commands.json file, which can then be used by the C++ extension (or any other language server protocol extension) to get the info about the include path and the flags
| "postStartCommand": "cmake -DKokkos_ROOT=/opt/kokkos-install -DKokkos_ENABLE_OPENMP=ON -B build" | |
| "postStartCommand": "cmake -DKokkos_ROOT=/opt/kokkos-install -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -B build" |
There was a problem hiding this comment.
I am not sure why -DKokkos_ENABLE_OPENMP=ON was added here. It should go.
| "settings": { | ||
| "C_Cpp.default.includePath": [ | ||
| "/opt/kokkos-install/include/" | ||
| ] |
There was a problem hiding this comment.
This is the setting used by the C++ extension to locate the compile_commands.json, cmake puts it in the build directory.
Using this, Kokkos symbols are correctly recognized by Intellisense, it also removes the need for the export CPATH=...
| ] | |
| ], | |
| "C_Cpp.default.compileCommands": [ | |
| "./build/compile_commands.json" | |
| ] |
There was a problem hiding this comment.
Thank you. Nice to know.
| @@ -0,0 +1,22 @@ | |||
| FROM mcr.microsoft.com/vscode/devcontainers/cpp:ubuntu-22.04 | |||
|
|
|||
| # Install C++ development tools, Git and CMake | |||
There was a problem hiding this comment.
Trailing space
| # Install C++ development tools, Git and CMake | |
| # Install C++ development tools, Git and CMake |
| "ms-vscode.cpptools-extension-pack", | ||
| "ms-azuretools.vscode-docker" | ||
| ], | ||
| "settings": { |
There was a problem hiding this comment.
Trailing space
| "settings": { | |
| "settings": { |
There was a problem hiding this comment.
Thank you for your time, Trévis.
I am curious to know what approach you take to identify trailing white spaces in a file.
There was a problem hiding this comment.
My editor is configured to show spaces at the end of a line as visible characters (see the list and listchars options in vim)
There was a problem hiding this comment.
I will look into those vim options.
| cmake | ||
|
|
||
| RUN git clone https://github.com/kokkos/kokkos.git \ | ||
| --branch release-candidate-4.6.01 --depth=1 /opt/kokkos && \ |
There was a problem hiding this comment.
We can use a more recent kokkos version (and the release-candidate-4.6.01 branch doesn't exist anymore)
| --branch release-candidate-4.6.01 --depth=1 /opt/kokkos && \ | |
| --branch 5.1.1 --depth=1 /opt/kokkos && \ |
|
|
||
| There is a simple C++ project that links with [Kokkos](https://cexa-project.org/news/2025-03-19-ninth-kokkos-tea-time/) to be built and run in `devc_hellow`. One can see in the `CMakeLists.txt` file that CMake expects Kokkos to be installed, in order to build the project. The container image takes care of this requirement. | ||
|
|
||
| In `devcontainer.json`, one can specify a "postStartCommand". For e.g., it is defined as "cmake -DKokkos_ROOT=/opt/kokkos-install -DKokkos_ENABLE_OPENMP=ON -B build" in our case. This ensures that a `build` directory is generated by CMake. See below for some observations with Docker and Podman regarding "postStartCommand". |
There was a problem hiding this comment.
| In `devcontainer.json`, one can specify a "postStartCommand". For e.g., it is defined as "cmake -DKokkos_ROOT=/opt/kokkos-install -DKokkos_ENABLE_OPENMP=ON -B build" in our case. This ensures that a `build` directory is generated by CMake. See below for some observations with Docker and Podman regarding "postStartCommand". | |
| In `devcontainer.json`, one can specify a "postStartCommand". For e.g., it is defined as "cmake -DKokkos_ROOT=/opt/kokkos-install -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -B build" in our case. This ensures that a `build` directory is generated by CMake, and that compile commands are exported (helpful for getting Intellisense to work). See below for some observations with Docker and Podman regarding "postStartCommand". |
| * Currently, "postStartCommand" works only with Docker and not with Podman. One gets an error like the following with Podman: | ||
|
|
||
| Error: error parsing environment variables: name "\afbfa9712-93dc-4bca-8ecc-99ffb315ae27\x1b]0;vscode@mdlspc111.extra.cea.fr: cat /proc/self/environ\aREMOTE_CONTAINERS_IPC" has white spaces, poorly formatted name | ||
| [147463 ms] postStartCommand from devcontainer.json failed with exit code 125. Skipping any further user-provided commands. | ||
| * Podman takes more time to build and run the container. Probably, it takes more time to restart a container also. | ||
| * With Podman, VS Code disconnects and reconnects to the container from time to time. | ||
|
|
||
| Probably, these issues with Podman can be resolved by using a more recent version of Podman. For example, VS Code recommends version 5+. However, Podman offers much better support for Red Hat distributions like Fedora. |
There was a problem hiding this comment.
Note that I did not get any issue using podman, but as you mention it might be because I have a fairly recent version (5.8.2)
|
|
||
| #### Some technical points | ||
| * In order to enable networking while building the container, define `"build"` as `"build": { …, "options": ["--network=host"], …}`. This may be needed in order to `git clone` the Kokkos repository. Also, note that `“runArgs”: [“--network=host”]` is for enabling network connection while running the container. | ||
| * Setting the environment variable `CPATH` as `CPATH="/opt/kokkos-install/include:$CPATH"` helps with IntelliSense recognizing Kokkos header files. |
There was a problem hiding this comment.
| * Setting the environment variable `CPATH` as `CPATH="/opt/kokkos-install/include:$CPATH"` helps with IntelliSense recognizing Kokkos header files. |
| * In the Command Palette enter ">Dev Containers: Rebuild Without Cache and Reopen in Container" whenever you need to rebuild the container after making changes to either `devcontainer.json` or `Dockerfile`. | ||
|
|
||
| #### To explore further | ||
| * Kokkos functions are incorrectly flagged by IntelliSense. |
There was a problem hiding this comment.
Addressed by the compile_commands thing
| * Kokkos functions are incorrectly flagged by IntelliSense. |
| * Try installing the following extensions in VS Code to check for a better experience with Podman. | ||
| * "Container Tools" and "Pod Manager". Note: These extensions have been released relatively recently. |
There was a problem hiding this comment.
I only needed to install the dev container extension for it to work
Dev container for IDEs like VSCode for Kokkos OpenMP backend.
More details in the README.md file.