Skip to content

Instantly share code, notes, and snippets.

@spagnuolocarmine
Last active May 4, 2021 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spagnuolocarmine/60a5f8c065f9577c25a6717681bd84d1 to your computer and use it in GitHub Desktop.
Save spagnuolocarmine/60a5f8c065f9577c25a6717681bd84d1 to your computer and use it in GitHub Desktop.
Compile and execute MPI C program on Visual Studio Code using Docker
{"lastUpload":"2021-05-04T16:03:20.713Z","extensionVersion":"v3.4.3"}
[
{
"metadata": {
"id": "e337c67b-55c2-4fef-8949-eb260e7fb7fd",
"publisherId": "Shan.code-settings-sync",
"publisherDisplayName": "Shan"
},
"name": "code-settings-sync",
"publisher": "Shan",
"version": "3.4.3"
},
{
"metadata": {
"id": "f0c5397b-d357-4197-99f0-cb4202f22818",
"publisherId": "ms-vscode-remote.remote-wsl",
"publisherDisplayName": "ms-vscode-remote"
},
"name": "remote-wsl",
"publisher": "ms-vscode-remote",
"version": "0.54.6"
}
]
{
"sync.gist": "60a5f8c065f9577c25a6717681bd84d1"
}
@fasanosalvatore
Copy link

To input the number of processes modify the code as follows:

{
  "version": "2.0.0",
  "tasks": [
    {
      "type": "shell",
      "label": "MPI compile active file (mpicc)",
      "command": "docker run -it --mount src=\"$(pwd)\",target=/home,type=bind spagnuolocarmine/docker-mpi:latest mpicc -g /home/${fileBasename} -o /home/${fileBasenameNoExtension}",
      "presentation": {
        "reveal": "always"
      },
      "problemMatcher": ["$eslint-compact"]
    },
    {
      "type": "shell",
      "label": "MPI run active file (mpicc && mpirun)",
      "command": "docker run -it --mount src=\"$(pwd)\",target=/home,type=bind spagnuolocarmine/docker-mpi:latest mpirun --allow-run-as-root -np ${input:np} /home/${fileBasenameNoExtension}",
      "dependsOn": ["MPI compile active file (mpicc)"],
      "presentation": {
        "reveal": "always"
      },
      "problemMatcher": ["$eslint-compact"]
    }
  ],
  "inputs": [
    {
      "id": "np",
      "description": "Number of processes:",
      "default": "4",
      "type": "promptString"
    }
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment