Re: [hwloc-devel] get_last_cpu_location for process (Was: Hardware locality (hwloc) v2.0.0-beta1 released)

2017-12-29 Thread Samuel Thibault
Brice Goglin, on ven. 29 déc. 2017 11:15:09 +0100, wrote:
> I couldn't test since binding doesn't seem to work in my qemu (always
> goes to PU #0), even when using qemu-x86_64 on x86_64. Is this fixed
> with your patches sent to qemu-devel yesterday?

My get/setaffinity patches shouldn't fix anything in that regard since
it's only for big/little endian conversion.

> Also sched_getcpu() isn't implemented in my qemu,

My getcpu patch fixes that.

Samuel
___
hwloc-devel mailing list
hwloc-devel@lists.open-mpi.org
https://lists.open-mpi.org/mailman/listinfo/hwloc-devel

Re: [hwloc-devel] get_last_cpu_location for process (Was: Hardware locality (hwloc) v2.0.0-beta1 released)

2017-12-29 Thread Brice Goglin
Le 28/12/2017 à 19:20, Samuel Thibault a écrit :
>> we can add a hwloc env var to disable process-wide asserts.
> So I would set it for all Debian builds? (we don't have a fixed set of
> archs which are built inside qemu-user)
>

Yes, if that's OK for you.

I couldn't test since binding doesn't seem to work in my qemu (always
goes to PU #0), even when using qemu-x86_64 on x86_64. Is this fixed
with your patches sent to qemu-devel yesterday?
Also sched_getcpu() isn't implemented in my qemu, but I can disable it
in config.h after configure.

Brice

___
hwloc-devel mailing list
hwloc-devel@lists.open-mpi.org
https://lists.open-mpi.org/mailman/listinfo/hwloc-devel

Re: [hwloc-devel] get_last_cpu_location for process (Was: Hardware locality (hwloc) v2.0.0-beta1 released)

2017-12-28 Thread Samuel Thibault
Brice Goglin, on jeu. 28 déc. 2017 18:47:29 +0100, wrote:
> Le 28/12/2017 à 16:18, Samuel Thibault a écrit :
> > Samuel Thibault, on jeu. 28 déc. 2017 15:08:30 +0100, wrote:
> >> Samuel Thibault, on mer. 20 déc. 2017 18:32:48 +0100, wrote:
> >>> I have uploaded it to debian experimental, so when it passes NEW,
> >>> various arch test results will show up on 
> >>>
> >>> https://buildd.debian.org/status/package.php?p=hwloc&suite=experimental
> >>>
> >>> so you can check the results on odd systems :)
> >> FI, the failure on m68k is due to a bug in qemu's linux-user emulation,
> >> which I'm currently fixing.
> > There is however an issue with the hwloc_get_last_cpu_location test when
> > run inside qemu's linux-user emulation, because in that case qemu
> > introduces a thread for its own purposes in addition to the normal
> > thread, and then the test looks like this:
> 
> Can you clarify what this qemu linux-user emulation does? Is it
> emulating each process of a "fake-VM" inside a dedicated process on the
> host?

Yes.

qemu-i386 /crossroot/bin/bash

will run an i386-based bash as a normal process, only emulating the
CPU part, all system calls are made normally (with a bit of data
translation).

> Any idea when this could be useful beside (I guess) cross-building
> platforms?

Mostly that :)

> we can add a hwloc env var to disable process-wide asserts.

So I would set it for all Debian builds? (we don't have a fixed set of
archs which are built inside qemu-user)

Samuel
___
hwloc-devel mailing list
hwloc-devel@lists.open-mpi.org
https://lists.open-mpi.org/mailman/listinfo/hwloc-devel

Re: [hwloc-devel] get_last_cpu_location for process (Was: Hardware locality (hwloc) v2.0.0-beta1 released)

2017-12-28 Thread Brice Goglin
Le 28/12/2017 à 16:18, Samuel Thibault a écrit :
> Samuel Thibault, on jeu. 28 déc. 2017 15:08:30 +0100, wrote:
>> Samuel Thibault, on mer. 20 déc. 2017 18:32:48 +0100, wrote:
>>> I have uploaded it to debian experimental, so when it passes NEW,
>>> various arch test results will show up on 
>>>
>>> https://buildd.debian.org/status/package.php?p=hwloc&suite=experimental
>>>
>>> so you can check the results on odd systems :)
>> FI, the failure on m68k is due to a bug in qemu's linux-user emulation,
>> which I'm currently fixing.
> There is however an issue with the hwloc_get_last_cpu_location test when
> run inside qemu's linux-user emulation, because in that case qemu
> introduces a thread for its own purposes in addition to the normal
> thread, and then the test looks like this:

Can you clarify what this qemu linux-user emulation does? Is it
emulating each process of a "fake-VM" inside a dedicated process on the
host?
Any idea when this could be useful beside (I guess) cross-building
platforms?

> I'm tid 15573
> trying 0x0003 1
> setaffinity 15573 3 gave 0
> setaffinity 15606 3 gave 0
> getting last location for 15573
> got 0
> getting last location for 15606
> got 2
> got 0x0005
> hwloc_get_last_cpu_location: hwloc_get_last_cpu_location.c:38: check: 
> Assertion `hwloc_bitmap_isincluded(last, set)' failed.
>
> I.e. when trying check(set, HWLOC_CPUBIND_PROCESS);, the
> hwloc_set_cpubind() call does bind the two threads of the process, and
> then looks for the CPU locations of the two threads, but probably thread
> 15606 didn't actually run in between, and thus the last CPU location is
> still with the old binding, and that fails the assertion.
>
> Of course, in the Debian package I could patch over this test to ignore
> the failure, possibly by blacklisting architectures which are known to
> be built inside qemu, but it could pose problem more generally. Perhaps
> we should use the attached patch, to try to check inclusion only from
> the result of the current-thread-only method?

If this failure isn't expected to matter in normal cases, I'd like to
keep the opportunity to check the process-wide cpulocation when possible.
I couldn't find an env var for detecting qemu user-emulation, but we can
add a hwloc env var to disable process-wide asserts. Something like the
attached patch (which adds lots of printf and just disables the assert
if flags!=THREAD or if HWLOC_TEST_DONTCHECK_PROC_CPULOCATION is set in
the env).

Brice

diff --git a/tests/hwloc/hwloc_get_last_cpu_location.c b/tests/hwloc/hwloc_get_last_cpu_location.c
index 03ab103b..01373a7d 100644
--- a/tests/hwloc/hwloc_get_last_cpu_location.c
+++ b/tests/hwloc/hwloc_get_last_cpu_location.c
@@ -5,6 +5,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 
@@ -13,21 +14,29 @@
 hwloc_topology_t topology;
 const struct hwloc_topology_support *support;
 
+static int checkprocincluded;
+
 /* check that a bound process execs on a non-empty cpuset included in the binding */
 static int check(hwloc_const_cpuset_t set, int flags)
 {
   hwloc_cpuset_t last;
   int ret;
 
+  printf("  binding\n");
   ret = hwloc_set_cpubind(topology, set, flags);
   if (ret)
 return 0;
 
+  printf("  getting cpu location\n");
   last = hwloc_bitmap_alloc();
   ret = hwloc_get_last_cpu_location(topology, last, flags);
   assert(!ret);
   assert(!hwloc_bitmap_iszero(last));
-  assert(hwloc_bitmap_isincluded(last, set));
+
+  if (flags == HWLOC_CPUBIND_THREAD || checkprocincluded) {
+printf("  checking inclusion\n");
+assert(hwloc_bitmap_isincluded(last, set));
+  }
 
   hwloc_bitmap_free(last);
   return 0;
@@ -35,12 +44,18 @@ static int check(hwloc_const_cpuset_t set, int flags)
 
 static int checkall(hwloc_const_cpuset_t set)
 {
-  if (support->cpubind->get_thisthread_last_cpu_location)
+  if (support->cpubind->get_thisthread_last_cpu_location) {
+printf(" with HWLOC_CPUBIND_THREAD...\n");
 check(set, HWLOC_CPUBIND_THREAD);
-  if (support->cpubind->get_thisproc_last_cpu_location)
+  }
+  if (support->cpubind->get_thisproc_last_cpu_location) {
+printf(" with HWLOC_CPUBIND_PROCESS...\n");
 check(set, HWLOC_CPUBIND_PROCESS);
-  if (support->cpubind->get_thisthread_last_cpu_location || support->cpubind->get_thisproc_last_cpu_location)
+  }
+  if (support->cpubind->get_thisthread_last_cpu_location || support->cpubind->get_thisproc_last_cpu_location) {
+printf(" with flags 0...\n");
 check(set, 0);
+  }
   return 0;
 }
 
@@ -49,24 +64,29 @@ int main(void)
   unsigned depth;
   hwloc_obj_t obj;
 
+  checkprocincluded = (NULL == getenv("HWLOC_TEST_DONTCHECK_PROC_CPULOCATION"));
+
   hwloc_topology_init(&topology);
   hwloc_topology_load(topology);
 
   support = hwloc_topology_get_support(topology);
 
   /* check at top level */
+  printf("testing at top level\n");
   obj = hwloc_get_root_obj(topology);
   checkall(obj->cpuset);
 
   depth = hwloc_topology_get_depth(topology);
   /* check at intermediate level if it exists */
   if (depth