Open MPI logo

Hardware Locality Users' Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Hardware Locality Users mailing list

Subject: Re: [hwloc-users] Windows api threading functions equivalent to hwloc?
From: Andrew Somorjai (verthex2099_at_[hidden])
Date: 2012-11-19 19:38:46

"CreateThread() and WaitForMultipleObjects() are not in hwloc since they have nothing to do with topologies."

I thought hwloc was also for threading?

"DWORD_PTR m_id = 0;
DWORD_PTR m_mask = 1 << i;

m_threads[i] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)threadMain, (LPVOID)i, NULL, &m_id);
SetThreadAffinityMask(m_threads[i], m_mask);

This will likely be something such as:

hwloc_bitmap_t bitmap = hwloc_bitmap_alloc();
hwloc_bitmap_set_only(bitmap, i);
hwloc_set_thread_cpubind(topology, m_threads[i], bitmap, 0);

How would I pass a function like threadMain in the above CreateThread function into the thread itself. Someone told me

to use this library for this purpose so I wasn't sure what it was made for.

How would I create an array m_threads and pass it
into hwloc_set_thread_cpubind. I would still need this part then correct?

m_threads[i] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)threadMain, (LPVOID)i, NULL, &m_id);

I would like to be independent of windows.h by the way, not using windows api calls is the motivation for all of this.