Skip to content

Commit 259cd78

Browse files
authored
Allow configure to force use of hwloc even when it is unnecessary (#12)
* Added option to build using hwloc even when it is not required and fixed unit tests. * Updated tests to test with and without hwloc on linux and fixed hwloc implementation. * Now the code builds with -Wall -Werror -pedantic (because @eddelbuettel likes it that way)
1 parent a36460a commit 259cd78

File tree

13 files changed

+30
-16
lines changed

13 files changed

+30
-16
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ compiler:
1616
before_install:
1717
- echo $LANG
1818
- echo $LC_ALL
19-
- sudo apt-get update && sudo apt-get install -y automake autoconf
19+
- sudo apt-get update && sudo apt-get install -y automake autoconf libhwloc-dev
2020
- if [ $CXX == g++ ]; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test; sudo apt-get update -qq; fi
2121

2222
install:
@@ -26,7 +26,7 @@ before_script:
2626
- if [ $TRAVIS_OS_NAME == linux ]; then ./bootstrap.sh; fi
2727

2828
script:
29-
- ./configure && make && make check
29+
- ./configure && make && make check && ./cleanup.sh && ./bootstrap.sh && ./configure --with-hwloc && make && make check
3030

3131
notifications:
3232
email:

configure.ac

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,10 @@ case $host in
3131
;;
3232
esac
3333

34+
AC_ARG_WITH([hwloc], AS_HELP_STRING([--with-hwloc],
35+
[Use hwloc library even if this platform doesn't require it]),
36+
CPPFLAGS="$CPPFLAGS -DCPUAFF_USE_HWLOC" LIBS="$LIBS -lhwloc")
37+
38+
CXXFLAGS="$CXXFLAGS -Wall -Werror -pedantic"
39+
3440
AC_OUTPUT

include/cpuaff/config.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,4 @@ namespace cpuaff
112112
typedef basic_traits< impl::null::traits, impl::null::traits > traits;
113113
} // namespace cpuaff
114114

115-
#endif
115+
#endif

include/cpuaff/impl/basic_affinity_manager.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class basic_affinity_manager
152152
{
153153
if (has_cpus())
154154
{
155-
if (i >= 0 && i < cpu_by_index_.size())
155+
if (i >= 0 && uint32_t(i) < cpu_by_index_.size())
156156
{
157157
cpu = cpu_by_index_[i];
158158
return true;

include/cpuaff/impl/basic_affinity_stack.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,4 @@ class basic_affinity_stack
126126
std::stack< cpu_set_type > affinity_stack_;
127127
};
128128
} // namespace impl
129-
} // namespace cpuaff
129+
} // namespace cpuaff

include/cpuaff/impl/basic_cpu.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,4 @@ class basic_cpu
161161
numa_type numa_;
162162
};
163163
} // namespace impl
164-
} // namespace cpuaff
164+
} // namespace cpuaff

include/cpuaff/impl/basic_cpu_set.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ class basic_cpu_set : public std::set< basic_cpu< TRAITS > >
6666
};
6767

6868
} // namespace impl
69-
} // namespace cpuaff
69+
} // namespace cpuaff

include/cpuaff/impl/hwloc_impl/hwloc.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939

4040
#include <hwloc.h>
4141
#include <iostream>
42+
#include <cstdio>
43+
4244
namespace cpuaff
4345
{
4446
namespace impl
@@ -214,9 +216,9 @@ struct set_affinity
214216
hwloc_cpuset_t cpu_set = hwloc_bitmap_alloc();
215217
hwloc_bitmap_zero(cpu_set);
216218

217-
typename std::set< cpu_identifier_wrapper >::const_iterator i =
219+
std::set< cpu_identifier_wrapper >::const_iterator i =
218220
cpus.begin();
219-
typename std::set< cpu_identifier_wrapper >::const_iterator iend =
221+
std::set< cpu_identifier_wrapper >::const_iterator iend =
220222
cpus.end();
221223

222224
for (; i != iend; ++i)
@@ -227,6 +229,8 @@ struct set_affinity
227229
bool retval = (0 == hwloc_set_cpubind(topology::instance().get(),
228230
cpu_set, HWLOC_CPUBIND_THREAD));
229231
hwloc_bitmap_free(cpu_set);
232+
233+
return retval;
230234
}
231235
};
232236

include/cpuaff/impl/linux_impl/pci_device_reader.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,4 @@ class pci_device_reader
176176

177177
} // namespace linux_impl
178178
} // namespace impl
179-
} // namespace cpuaff
179+
} // namespace cpuaff

include/cpuaff/impl/linux_impl/set_reader.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,4 @@ inline bool read_int_set(std::set< int32_t > &set, const std::string &str)
9696
} // namespace set_reader
9797
} // namespace linux_impl
9898
} // namespace impl
99-
} // namespace cpuaff
99+
} // namespace cpuaff

0 commit comments

Comments
 (0)