From 7c5e3ddac5241c476eb0e463a710df67c9740c0f Mon Sep 17 00:00:00 2001
From: Sébastien Valat <sebastien.valat.dev@orange.fr>
Date: Thu, 29 Jun 2023 12:19:39 -0400
Subject: numaprof: New package (version : 1.1.4) (#35271)

* numaprof: New package (version : 1.1.4)
* numaprof: Improve the deps description by adding 'type'
* numaprof: Fix maintainer semantic
---
 .../numaprof/numaprof-1.1.4-pin-layout.patch       | 15 +++++++
 .../repos/builtin/packages/numaprof/package.py     | 47 ++++++++++++++++++++++
 2 files changed, 62 insertions(+)
 create mode 100644 var/spack/repos/builtin/packages/numaprof/numaprof-1.1.4-pin-layout.patch
 create mode 100644 var/spack/repos/builtin/packages/numaprof/package.py

diff --git a/var/spack/repos/builtin/packages/numaprof/numaprof-1.1.4-pin-layout.patch b/var/spack/repos/builtin/packages/numaprof/numaprof-1.1.4-pin-layout.patch
new file mode 100644
index 0000000000..bd53dbf702
--- /dev/null
+++ b/var/spack/repos/builtin/packages/numaprof/numaprof-1.1.4-pin-layout.patch
@@ -0,0 +1,15 @@
+diff --git a/src/integration/pintool/Makefile.pin.in b/src/integration/pintool/Makefile.pin.in
+index ec95b7b..1b84423 100644
+--- a/src/integration/pintool/Makefile.pin.in
++++ b/src/integration/pintool/Makefile.pin.in
+@@ -4,7 +4,8 @@
+ #
+ ##############################################################
+ 
+-PIN_ROOT=$(shell dirname @PINTOOL_PIN@)
++PIN_ROOT_BIN=$(shell dirname @PINTOOL_PIN@)
++PIN_ROOT=$(shell dirname $(PIN_ROOT_BIN))
+ MAKE+=-f Makefile.pin
+ SRCDIR=@CMAKE_CURRENT_SOURCE_DIR@
+ CST_DEBUG_FLAGS=@PINTOOL_CFLAGS@
+
diff --git a/var/spack/repos/builtin/packages/numaprof/package.py b/var/spack/repos/builtin/packages/numaprof/package.py
new file mode 100644
index 0000000000..22a8fa512d
--- /dev/null
+++ b/var/spack/repos/builtin/packages/numaprof/package.py
@@ -0,0 +1,47 @@
+# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack.package import *
+
+
+class Numaprof(CMakePackage):
+    """
+    NumaProf is a NUMA memory access profiling tool. It is based on Intel-PIN to intercept
+    all the memory access and report them on NUMA counters so we can tell by annotating the
+    source code where you make local, remote, unpinned memory accessed. It also provide
+    some charts to better understand the NUMA behavior of the application.
+    """
+
+    # Infos
+    homepage = "https://memtt.github.io/numaprof"
+    url = "https://github.com/memtt/numaprof/releases/download/v1.1.4/numaprof-1.1.4.tar.bz2"
+    maintainers("svalat")
+
+    # Versions
+    version("1.1.4", sha256="96cc5e153895f43d8be58e052433c9e7c9842071cc6bf915b3b1b346908cbbff")
+
+    # Variants
+    variant(
+        "qt", default=False, description="Build the QT embeded webview with Pyton + QT web toolkit"
+    )
+
+    # Dependencies
+    depends_on("python", type=("build", "run"))
+    depends_on("intel-pin", type=("build", "link", "run"))
+    depends_on("numactl")
+    depends_on("py-pyqt5", "+qt", type=("build", "run"))
+
+    # Patches
+    patch(
+        "numaprof-1.1.4-pin-layout.patch",
+        when="@1.1.4:",
+        sha256="a2e3242f72b502285da2ad41dd896382e99a8987bda9ff38e081a048776ee7b3",
+    )
+
+    # Generate build command
+    def cmake_args(self):
+        spec = self.spec
+        args = ["-DPINTOOL_PREFIX=" + spec["intel-pin"].prefix]
+        return args
-- 
cgit v1.2.3-70-g09d2