From 3d2921beb0b8ae6c6f052a7a12bd0a67daf1cf1a Mon Sep 17 00:00:00 2001
From: Matthias Diener <mdiener@illinois.edu>
Date: Thu, 28 Jan 2021 19:38:21 -0800
Subject: [PATCH] add DOMAIN_ID to nvidia device info extension

---
 doc/make_constants.py  | 1 +
 src/clinfo_ext.h       | 1 +
 src/pyopencl_ext.h     | 4 ++++
 src/wrap_cl.hpp        | 4 ++++
 src/wrap_constants.cpp | 3 +++
 5 files changed, 13 insertions(+)

diff --git a/doc/make_constants.py b/doc/make_constants.py
index d2c7a42b..00162371 100644
--- a/doc/make_constants.py
+++ b/doc/make_constants.py
@@ -112,6 +112,7 @@ const_ext_lookup = {
             "ATTRIBUTE_ASYNC_ENGINE_COUNT_NV": nv_devattr,
             "PCI_BUS_ID_NV": nv_devattr,
             "PCI_BUS_SLOT_NV": nv_devattr,
+            "PCI_BUS_DOMAIN_NV": nv_devattr,
 
             "DOUBLE_FP_CONFIG":
             ("cl_khr_fp64", "2011.1"),
diff --git a/src/clinfo_ext.h b/src/clinfo_ext.h
index dc4d6a8e..bcd2ae57 100644
--- a/src/clinfo_ext.h
+++ b/src/clinfo_ext.h
@@ -49,6 +49,7 @@
 #define CL_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT_NV	0x4007
 #define CL_DEVICE_PCI_BUS_ID_NV				0x4008
 #define CL_DEVICE_PCI_SLOT_ID_NV			0x4009
+#define CL_DEVICE_PCI_DOMAIN_ID_NV          0x4010
 
 /* cl_ext_atomic_counters_{32,64} */
 #define CL_DEVICE_MAX_ATOMIC_COUNTERS_EXT		0x4032
diff --git a/src/pyopencl_ext.h b/src/pyopencl_ext.h
index a9792d8b..ef49b6b2 100644
--- a/src/pyopencl_ext.h
+++ b/src/pyopencl_ext.h
@@ -49,6 +49,10 @@ typedef union
 #define CL_DEVICE_PCI_SLOT_ID_NV                        0x4009
 #endif
 
+#ifndef CL_DEVICE_PCI_DOMAIN_ID_NV
+#define CL_DEVICE_PCI_DOMAIN_ID_NV                      0x4010
+#endif
+
 /* }}} */
 
 #endif
diff --git a/src/wrap_cl.hpp b/src/wrap_cl.hpp
index f00a6b88..03932d82 100644
--- a/src/wrap_cl.hpp
+++ b/src/wrap_cl.hpp
@@ -811,6 +811,10 @@ namespace pyopencl
           case CL_DEVICE_PCI_SLOT_ID_NV:
             DEV_GET_INT_INF(cl_uint);
 #endif
+#ifdef CL_DEVICE_PCI_DOMAIN_ID_NV
+          case CL_DEVICE_PCI_DOMAIN_ID_NV:
+            DEV_GET_INT_INF(cl_uint);
+#endif
 #ifdef CL_DEVICE_THREAD_TRACE_SUPPORTED_AMD
           case CL_DEVICE_THREAD_TRACE_SUPPORTED_AMD: DEV_GET_INT_INF(cl_bool);
 #endif
diff --git a/src/wrap_constants.cpp b/src/wrap_constants.cpp
index 0cc20d8f..77dbc25f 100644
--- a/src/wrap_constants.cpp
+++ b/src/wrap_constants.cpp
@@ -378,6 +378,9 @@ void pyopencl_expose_constants(py::module &m)
 #ifdef CL_DEVICE_PCI_SLOT_ID_NV
     ADD_ATTR(DEVICE_, PCI_SLOT_ID_NV);
 #endif
+#ifdef CL_DEVICE_PCI_SLOT_ID_NV
+    ADD_ATTR(DEVICE_, PCI_DOMAIN_ID_NV);
+#endif
 #endif
 
 // {{{ cl_amd_device_attribute_query
-- 
GitLab