Support for Debugging Neko Simulations in VS Code #1638
-
I want to use Visual Studio Code (VS Code) as my IDE for working with Neko, particularly to leverage its debugging capabilities. However, setting this up does not seem straightforward to me. When attempting to debug, VS Code prompts me to select a debugger and create My environment includes Windows Subsystem for Linux (WSL) and Open MPI. I aim to debug code using MPI and CUDA. I request your support on:
If VS Code is not ideal for this application, I’d appreciate suggestions for alternative IDEs or tools better suited for Fortran, MPI, and CUDA debugging workflows. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
@timfelle might be able to help. I believe I managed to do this on one machine for the CPU, and incidentally I will have access to it next week, so I can share the setup. |
Beta Was this translation helpful? Give feedback.
-
Hi, Yes I have indeed dabbled a bit in this. Extensions (I think these are enough, its been a while):
An example of a I have done so, however, I am not working directly on neko but through an extension library for Topology Optimization, hence the build system is quite different from Neko itself. But the gist of the preLaunchTask is to define something like the second dropdown, where you do your general setup of Neko. And then also run the "makeneko" script for the specific example you want to use for debugging if you have user defined code in there. I have a few notes in the Neko-TOP repository on Cuda and WSL if that is useful to you: Another note: My `launch.json`{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Fortran Neko-Top Debugging",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/neko",
"args": [
"cylinder.case"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/examples/cylinder",
"environment": [
{
"name": "NEKO_LOG_LEVEL",
"value": "10"
},
{
"name": "NEKO_LOG_FILE",
"value": "neko.log"
},
{
"name": "LD_LIBRARY_PATH",
"value": "/path/to/json-fortran/lib"
}
],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
// "preLaunchTask": "Initialize Debug",
}
]
} tasks.json{
"version": "2.0.0",
"tasks": [
{
"detail": "Prepare the Neko-TOP debug environment",
"type": "shell",
"label": "Initialize Debug",
"command": "${workspaceFolder}/configure",
"args": [
"--prefix=${workspaceFolder",
"FC=/some/compiler"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [ ],
"dependsOn": [
"Prepare environment",
],
"presentation": {
"echo": true,
"reveal": "never",
"revealProblems": "onProblem",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false,
"close": true
}
}
]
} |
Beta Was this translation helpful? Give feedback.
-
Hi @timofeymukha & @timfelle, Thank you so much for the detailed responses and the sample configurations! Your guidance was invaluable in setting it up. Following are the same files for the case I'm running & as per my system settings: I assume that the above does the following:
The above is working perfectly fine. It is opening the debugger & stops at breakpoints. However, I’d like to include mpirun in the workflow to run the case with MPI, as follows: For this I tried to modify launch.json, as follows:
Please let me know how do I specify |
Beta Was this translation helpful? Give feedback.
-
So in general i think VSCode will fall short if you wish to do MPI based debugging. VSCode calls gdb internally and judging from: https://stackoverflow.com/questions/329259/how-do-i-debug-an-mpi-program I think you would need to launch a gdb session for each of the mpi ranks, which I don't see how you would do in the vscode system. |
Beta Was this translation helpful? Give feedback.
-
Let's convert this into a discussion, feel free to continue the discussion in the converted thread under Q&A |
Beta Was this translation helpful? Give feedback.
Hi, Yes I have indeed dabbled a bit in this.
Extensions (I think these are enough, its been a while):
An example of a
launch.json
is given below.I would suggest you look into the "preLaunchTask" which would go into a
tasks.json
if you want to compile the code before the debug is launched.I have done so, however, I am not working directly on neko but through an extension library for Topology Optimization, hence the build system is quite different from Neko itself.
But the gist of the preLaunchTask is to define something like the second dropdown, where you do your general setup of Neko. And then also run the "makeneko" script for the speci…