Skip to content

Commit

Permalink
Various improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
hivert committed May 8, 2018
1 parent 94cde3f commit e08eb21
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ message(STATUS "*** Compiler id is ${CMAKE_CXX_COMPILER_ID}")
if ( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
# Workaround of CMAKE bug https://stackoverflow.com/questions/47213356/
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -std=c++11)
add_compile_options( -std=c++11 -Wall )
add_compile_options( -std=c++11 -Wall -g -pg)
endif ( )

###################
Expand Down
3 changes: 3 additions & 0 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
- Get rid of target_compile_options("-Wall -O3 + arch optim")
- https://cmake.org/Wiki/CMake:How_To_Write_Platform_Checks
- https://stackoverflow.com/questions/11944060/how-to-detect-target-architecture-using-cmake


Add method data in perm16 and perm_generic
5 changes: 3 additions & 2 deletions include/perm16.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
#define HPCOMBI_CONSTEXPR constexpr
#define HPCOMBI_CONSTEXPR_CONSTRUCTOR constexpr
#else
#pragma message "Using a constexpr broken compiler ! Performance may not be optimal"
#pragma message "Using a constexpr broken compiler ! "\
"Performance may not be optimal"
#define HPCOMBI_CONSTEXPR const
#define HPCOMBI_CONSTEXPR_CONSTRUCTOR
#endif
Expand Down Expand Up @@ -357,7 +358,7 @@ struct Perm16 : public Transf16 {
inline uint8_t nb_cycles_unroll() const;
inline uint8_t nb_cycles() const { return nb_cycles_unroll(); }

private:
private:
static const std::array<Perm16, 3> inverting_rounds;
};

Expand Down
37 changes: 19 additions & 18 deletions include/perm_generic.hpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/******************************************************************************/
/* Copyright (C) 2014 Florent Hivert <[email protected]>, */
/* */
/* Distributed under the terms of the GNU General Public License (GPL) */
/* */
/* This code is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
/* General Public License for more details. */
/* */
/* The full text of the GPL is available at: */
/* */
/* http://www.gnu.org/licenses/ */
/******************************************************************************/
//****************************************************************************//
// Copyright (C) 2016 Florent Hivert <[email protected]>, //
// //
// Distributed under the terms of the GNU General Public License (GPL) //
// //
// This code is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU //
// General Public License for more details. //
// //
// The full text of the GPL is available at: //
// //
// http://www.gnu.org/licenses/ //
//****************************************************************************//

#ifndef HPCOMBI_PERM_GENERIC_HPP
#define HPCOMBI_PERM_GENERIC_HPP
Expand Down Expand Up @@ -52,15 +52,16 @@ template <size_t _Size, typename Expo = uint8_t> struct VectGeneric {

char less_partial(const VectGeneric &u, int k) const {
uint64_t diff = first_diff(u, k);
return (diff == Size) ? 0 : char(v[diff]) - char(u[diff]);
return (diff == Size) ? 0
: static_cast<char>(v[diff]) - static_cast<char>(u[diff]);
}

VectGeneric permuted(const VectGeneric &u) const {
VectGeneric res;
for (uint64_t i = 0; i < Size; i++)
res[i] = v[u[i]];
return res;
};
}

uint64_t first_non_zero(size_t bound = Size) const {
for (uint64_t i = 0; i < bound; i++)
Expand Down Expand Up @@ -128,8 +129,8 @@ struct PermGeneric : public VectGeneric<_Size, Expo> {
using vect = VectGeneric<_Size, Expo>;

PermGeneric() = default;
// PermGeneric() { for (uint64_t i=0; i < _Size; i++) this->v[i] = i; };
PermGeneric(const vect u) : vect(u){};
// PermGeneric() { for (uint64_t i=0; i < _Size; i++) this->v[i] = i; }
PermGeneric(const vect u) : vect(u) {}
PermGeneric(std::initializer_list<Expo> il) {
assert(il.size() <= vect::Size);
std::copy(il.begin(), il.end(), this->v.begin());
Expand Down
4 changes: 3 additions & 1 deletion include/testtools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ std::vector<Perm16> all_perms(int n);
// function pointers and lambda
template <typename Func>
double timethat(Func fun, int rep = 1, double reftime = 0) {
using namespace std::chrono;
using std::chrono::duration;
using std::chrono::duration_cast;
using std::chrono::high_resolution_clock;
auto tstart = high_resolution_clock::now();
for (int i = 0; i < rep; i++)
fun();
Expand Down

0 comments on commit e08eb21

Please sign in to comment.