Skip to content

Commit 0c4da87

Browse files
committed
We have actual code now!
1 parent 9183957 commit 0c4da87

31 files changed

+12397
-6947
lines changed

examples/affinity_stack.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,70 +27,70 @@
2727
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2828
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
30-
30+
3131
#include <cpuaff/cpuaff.hpp>
3232
#include <iostream>
3333

3434
int main(int argc, char *argv[])
3535
{
3636
cpuaff::affinity_manager manager;
37-
38-
if (manager.initialize(false))
39-
{
37+
38+
if (manager.initialize())
39+
{
4040
cpuaff::affinity_stack stack(manager);
41-
42-
cpuaff::cpu_set_type cpus;
41+
42+
cpuaff::cpu_set cpus;
4343
manager.get_affinity(cpus);
44-
44+
4545
std::cout << "Initial Affinity:" << std::endl;
46-
47-
cpuaff::cpu_set_type::iterator i = cpus.begin();
48-
cpuaff::cpu_set_type::iterator iend = cpus.end();
49-
50-
for ( ; i != iend; ++i)
46+
47+
cpuaff::cpu_set::iterator i = cpus.begin();
48+
cpuaff::cpu_set::iterator iend = cpus.end();
49+
50+
for (; i != iend; ++i)
5151
{
5252
std::cout << " " << (*i) << std::endl;
5353
}
54-
54+
5555
std::cout << std::endl;
56-
56+
5757
stack.push_affinity();
58-
58+
5959
// set the affinity to all the processing units on the first core
60-
cpuaff::cpu_set_type core_0;
60+
cpuaff::cpu_set core_0;
6161
manager.get_cpus_by_core(core_0, 0);
62-
62+
6363
manager.set_affinity(core_0);
6464
manager.get_affinity(cpus);
65-
65+
6666
std::cout << "Affinity After Calling set_affinity():" << std::endl;
6767
i = cpus.begin();
6868
iend = cpus.end();
69-
70-
for ( ; i != iend; ++i)
69+
70+
for (; i != iend; ++i)
7171
{
7272
std::cout << " " << (*i) << std::endl;
7373
}
74-
74+
7575
std::cout << std::endl;
76-
76+
7777
// restore the affinity to its initial value
7878
stack.pop_affinity();
79-
79+
8080
manager.get_affinity(cpus);
81-
81+
8282
std::cout << "Affinity After Calling pop_affinity():" << std::endl;
8383
i = cpus.begin();
8484
iend = cpus.end();
85-
86-
for ( ; i != iend; ++i)
85+
86+
for (; i != iend; ++i)
8787
{
8888
std::cout << " " << (*i) << std::endl;
8989
}
90-
90+
9191
return 0;
9292
}
93-
93+
9494
std::cerr << "cpuaff: unable to load cpus." << std::endl;
9595
return -1;
9696
}

examples/list_cpus.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,30 @@
2727
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2828
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
30-
30+
3131
#include <cpuaff/cpuaff.hpp>
3232
#include <iostream>
3333

3434
int main(int argc, char *argv[])
3535
{
3636
cpuaff::affinity_manager manager;
37-
38-
if (manager.initialize(false))
39-
{
40-
cpuaff::cpu_set_type cpus;
37+
38+
if (manager.initialize())
39+
{
40+
cpuaff::cpu_set cpus;
4141
manager.get_cpus(cpus);
42-
43-
cpuaff::cpu_set_type::iterator i = cpus.begin();
44-
cpuaff::cpu_set_type::iterator iend = cpus.end();
45-
46-
for ( ; i != iend; ++i)
42+
43+
cpuaff::cpu_set::iterator i = cpus.begin();
44+
cpuaff::cpu_set::iterator iend = cpus.end();
45+
46+
for (; i != iend; ++i)
4747
{
4848
std::cout << (*i) << std::endl;
4949
}
50-
50+
5151
return 0;
5252
}
53-
53+
5454
std::cerr << "cpuaff: unable to load cpus." << std::endl;
5555
return -1;
5656
}

examples/list_nearby_cpus.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,52 +27,52 @@
2727
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2828
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
30-
30+
3131
#include <cpuaff/cpuaff.hpp>
3232
#include <iostream>
3333

3434
int main(int argc, char *argv[])
3535
{
3636
#if defined(CPUAFF_PCI_SUPPORTED)
3737
cpuaff::affinity_manager manager;
38-
39-
if (manager.initialize(false))
40-
{
4138

39+
if (manager.initialize())
40+
{
4241
cpuaff::pci_device_set devices;
4342
manager.get_pci_devices(devices);
44-
43+
4544
cpuaff::pci_name_resolver resolver;
4645
resolver.initialize("/usr/share/hwdata/pci.ids");
47-
46+
4847
cpuaff::pci_device_set::iterator i = devices.begin();
4948
cpuaff::pci_device_set::iterator iend = devices.end();
50-
51-
for ( ; i != iend; ++i)
49+
50+
for (; i != iend; ++i)
5251
{
5352
cpuaff::pci_device_description des;
54-
resolver.get_description(des, *i);
53+
resolver.get_description(des, i->spec());
5554
std::cout << (*i) << " - " << des << std::endl;
56-
57-
cpuaff::cpu_set_type cpus;
55+
56+
cpuaff::cpu_set cpus;
5857
manager.get_nearby_cpus(cpus, *i);
59-
60-
cpuaff::cpu_set_type::iterator i = cpus.begin();
61-
cpuaff::cpu_set_type::iterator iend = cpus.end();
62-
63-
for ( ; i != iend; ++i)
58+
59+
cpuaff::cpu_set::iterator i = cpus.begin();
60+
cpuaff::cpu_set::iterator iend = cpus.end();
61+
62+
for (; i != iend; ++i)
6463
{
6564
std::cout << " " << (*i) << std::endl;
6665
}
6766
}
68-
67+
6968
return 0;
7069
}
71-
70+
7271
std::cerr << "cpuaff: unable to initialize affinity_manager." << std::endl;
7372
return -1;
7473
#else
75-
std::cerr << "cpuaff: PCI mapping not supported on this platform." << std::endl;
74+
std::cerr << "cpuaff: PCI mapping not supported on this platform."
75+
<< std::endl;
7676
return -1;
7777
#endif
7878
}

examples/list_pci_devices.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,41 +27,41 @@
2727
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2828
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
30-
30+
3131
#include <cpuaff/cpuaff.hpp>
3232
#include <iostream>
3333

3434
int main(int argc, char *argv[])
3535
{
3636
#if defined(CPUAFF_PCI_SUPPORTED)
3737
cpuaff::affinity_manager manager;
38-
39-
if (manager.initialize(false))
40-
{
4138

39+
if (manager.initialize())
40+
{
4241
cpuaff::pci_device_set devices;
4342
manager.get_pci_devices(devices);
44-
43+
4544
cpuaff::pci_name_resolver resolver;
4645
resolver.initialize("/usr/share/hwdata/pci.ids");
47-
46+
4847
cpuaff::pci_device_set::iterator i = devices.begin();
4948
cpuaff::pci_device_set::iterator iend = devices.end();
50-
51-
for ( ; i != iend; ++i)
49+
50+
for (; i != iend; ++i)
5251
{
5352
cpuaff::pci_device_description des;
54-
resolver.get_description(des, *i);
53+
resolver.get_description(des, i->spec());
5554
std::cout << (*i) << " - " << des << std::endl;
5655
}
57-
56+
5857
return 0;
5958
}
60-
59+
6160
std::cerr << "cpuaff: unable to initialize affinity_manager." << std::endl;
6261
return -1;
6362
#else
64-
std::cerr << "cpuaff: PCI mapping not supported on this platform." << std::endl;
63+
std::cerr << "cpuaff: PCI mapping not supported on this platform."
64+
<< std::endl;
6565
return -1;
6666
#endif
6767
}

examples/simple_affinity.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,50 +27,50 @@
2727
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2828
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
30-
30+
3131
#include <cpuaff/cpuaff.hpp>
3232
#include <iostream>
3333

3434
int main(int argc, char *argv[])
3535
{
3636
cpuaff::affinity_manager manager;
37-
38-
if (manager.initialize(false))
39-
{
40-
cpuaff::cpu_set_type cpus;
37+
38+
if (manager.initialize())
39+
{
40+
cpuaff::cpu_set cpus;
4141
manager.get_affinity(cpus);
42-
42+
4343
std::cout << "Initial Affinity:" << std::endl;
44-
45-
cpuaff::cpu_set_type::iterator i = cpus.begin();
46-
cpuaff::cpu_set_type::iterator iend = cpus.end();
47-
48-
for ( ; i != iend; ++i)
44+
45+
cpuaff::cpu_set::iterator i = cpus.begin();
46+
cpuaff::cpu_set::iterator iend = cpus.end();
47+
48+
for (; i != iend; ++i)
4949
{
5050
std::cout << " " << (*i) << std::endl;
5151
}
52-
52+
5353
std::cout << std::endl;
54-
54+
5555
// set the affinity to all the processing units on the first core
56-
cpuaff::cpu_set_type core_0;
56+
cpuaff::cpu_set core_0;
5757
manager.get_cpus_by_core(core_0, 0);
58-
58+
5959
manager.set_affinity(core_0);
6060
manager.get_affinity(cpus);
61-
61+
6262
std::cout << "Affinity After Calling set_affinity():" << std::endl;
6363
i = cpus.begin();
6464
iend = cpus.end();
65-
66-
for ( ; i != iend; ++i)
65+
66+
for (; i != iend; ++i)
6767
{
6868
std::cout << " " << (*i) << std::endl;
6969
}
70-
70+
7171
return 0;
7272
}
73-
73+
7474
std::cerr << "cpuaff: unable to load cpus." << std::endl;
7575
return -1;
7676
}

include/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nobase_include_HEADERS = cpuaff/*.hpp cpuaff/impl/linux_impl/*.hpp cpuaff/impl/hwloc_impl/*.hpp cpuaff/impl/null_impl/*.hpp
1+
nobase_include_HEADERS = cpuaff/*.hpp cpuaff/impl/*.hpp cpuaff/impl/linux_impl/*.hpp cpuaff/impl/hwloc_impl/*.hpp cpuaff/impl/null_impl/*.hpp

0 commit comments

Comments
 (0)