From 7e55e255f9676cb120517ff7e7672bd70842a59e Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Wed, 4 Feb 2026 11:53:01 +0100 Subject: [PATCH] Add OmpSs-2 simple example --- ompss2/.gitignore | 2 ++ ompss2/Makefile | 13 +++++++++++ ompss2/README.md | 57 +++++++++++++++++++++++++++++++++++++++++++++++ ompss2/flake.lock | 45 +++++++++++++++++++++++++++++++++++++ ompss2/flake.nix | 36 ++++++++++++++++++++++++++++++ ompss2/hello.c | 10 +++++++++ 6 files changed, 163 insertions(+) create mode 100644 ompss2/.gitignore create mode 100644 ompss2/Makefile create mode 100644 ompss2/README.md create mode 100644 ompss2/flake.lock create mode 100644 ompss2/flake.nix create mode 100644 ompss2/hello.c diff --git a/ompss2/.gitignore b/ompss2/.gitignore new file mode 100644 index 0000000..1b94007 --- /dev/null +++ b/ompss2/.gitignore @@ -0,0 +1,2 @@ +hello +ovni/ diff --git a/ompss2/Makefile b/ompss2/Makefile new file mode 100644 index 0000000..1ecf3c0 --- /dev/null +++ b/ompss2/Makefile @@ -0,0 +1,13 @@ +CC=clang +CFLAGS=-fompss-2 + +hello: hello.c + +trace: hello + rm -rf ovni/ + NOSV_CONFIG_OVERRIDE="instrumentation.version=ovni" NOSV_APPID=1 ./hello + ovniemu ovni/ + ls -l ovni/*.prv + +clean: + rm -rf hello ovni/ diff --git a/ompss2/README.md b/ompss2/README.md new file mode 100644 index 0000000..db410d4 --- /dev/null +++ b/ompss2/README.md @@ -0,0 +1,57 @@ +# OmpSs-2 environment + +This example shows how to include the LLVM compiler to build OmpSs-2 programs +with the new NODES and nOS-V runtime. The package `clangOmpss2Nodes` already +sets all the needed variables to locate the right runtime. + +Run `nix develop` then `make` to build the `hello` program: + + apex% nix develop + apex$ make + clang -fompss-2 hello.c -o hello + apex$ ./hello + hello from task 1 + hello from task 0 + hello from task 2 + hello from task 3 + hello from task 4 + hello from task 7 + hello from task 8 + hello from task 6 + hello from task 9 + hello from task 5 + +You can use `make trace` to run the hello program with instrumentation and +generate an ovni trace that is then converted to paraver: + + apex$ make trace + rm -rf ovni/ + NOSV_CONFIG_OVERRIDE="instrumentation.version=ovni" NOSV_APPID=1 ./hello + hello from task 1 + hello from task 0 + hello from task 3 + hello from task 4 + hello from task 5 + hello from task 6 + hello from task 2 + hello from task 8 + hello from task 7 + hello from task 9 + ovniemu ovni/ + ovniemu: INFO: loaded 58 streams + ovniemu: INFO: sorting looms by name + ovniemu: INFO: loaded 1 looms, 1 processes, 58 threads and 56 cpus + ovniemu: INFO: generated with libovni version 1.13.0 commit 0643266 + ovniemu: INFO: the following 2 models are enabled: + ovniemu: INFO: ovni 1.1.0 'O' (18 events) + ovniemu: INFO: nosv 2.6.0 'V' (64 events) + ovniemu: INFO: emulation starts + ovniemu: INFO: apex.nosv-u1880-p598308 burst stats: median/avg/max = 77/ 81/333 ns + ovniemu: WARN: ignoring old event OCn + ovniemu: INFO: 100.0% done at avg 42 kev/s + ovniemu: INFO: processed 711 input events in 0.02 s + ovniemu: INFO: writing traces to disk, please wait + ovniemu: INFO: emulation finished ok + ls -l ovni/*.prv + -rw-r--r-- 1 rarias Computational 48224 Feb 4 11:52 ovni/cpu.prv + -rw-r--r-- 1 rarias Computational 33689 Feb 4 11:52 ovni/thread.prv diff --git a/ompss2/flake.lock b/ompss2/flake.lock new file mode 100644 index 0000000..1770e34 --- /dev/null +++ b/ompss2/flake.lock @@ -0,0 +1,45 @@ +{ + "nodes": { + "jungle": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1770128250, + "narHash": "sha256-Kx3EwImhYCp4bLPNWGz4oL4IYVjkCLXwcVmXTY40MBc=", + "ref": "refs/heads/master", + "rev": "7a6e4232de0e181de97e099e600ffc3a964260e0", + "revCount": 1536, + "type": "git", + "url": "https://jungle.bsc.es/git/rarias/jungle" + }, + "original": { + "type": "git", + "url": "https://jungle.bsc.es/git/rarias/jungle" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1767634882, + "narHash": "sha256-2GffSfQxe3sedHzK+sTKlYo/NTIAGzbFCIsNMUPAAnk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3c9db02515ef1d9b6b709fc60ba9a540957f661c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-25.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "jungle": "jungle" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/ompss2/flake.nix b/ompss2/flake.nix new file mode 100644 index 0000000..4492cc1 --- /dev/null +++ b/ompss2/flake.nix @@ -0,0 +1,36 @@ +{ + inputs.jungle.url = "git+https://jungle.bsc.es/git/rarias/jungle"; + outputs = { self, jungle }: + let + nixpkgs = jungle.inputs.nixpkgs; + customOverlay = (final: prev: { + # Example overlay, for now empty + }); + pkgs = import nixpkgs { + system = "x86_64-linux"; + overlays = [ + # Apply jungle overlay to get our BSC custom packages + jungle.outputs.bscOverlay + # And on top apply our local changes to customize for cluster + customOverlay + ]; + }; + in { + devShells.x86_64-linux.default = pkgs.mkShell { + pname = "ompss2-devshell"; + # Include these packages in the shell + packages = with pkgs; [ + clangOmpss2Nodes + nodes + nosv + ovni + # Optional: Add wxparaver to open .prv traces (needs a working $DISPLAY) + # wxparaver + ]; + # The dependencies needed to build these packages will be also included + inputsFrom = with pkgs; [ + + ]; + }; + }; +} diff --git a/ompss2/hello.c b/ompss2/hello.c new file mode 100644 index 0000000..e948e4b --- /dev/null +++ b/ompss2/hello.c @@ -0,0 +1,10 @@ +#include + +int main() +{ + for (int i = 0; i < 10; i++) { + #pragma oss task + printf("hello from task %d\n", i); + } + return 0; +}