Changeset 5236


Ignore:
Timestamp:
Dec 23, 2016, 1:14:39 PM (12 months ago)
Author:
nmedfort
Message:

Reverted last change to support gcc 4.9 prior to changing UCD property table structure.

Location:
icGREP/icgrep-devel/icgrep
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/CMakeLists.txt

    r5235 r5236  
    138138SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
    139139
     140SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
     141
    140142SET(CMAKE_REQUIRED_FLAGS)
    141143
  • icGREP/icgrep-devel/icgrep/UCD/PropertyObjects.cpp

    r5234 r5236  
    1717namespace UCD {
    1818
    19 using PropertyStringStream =
    20     std::basic_stringstream<char, std::char_traits<char>, PropertyStringAllocator>;
    21 
    2219std::string canonicalize_value_name(const std::string & prop_or_val) {
    2320    std::locale loc;
     
    3532    throw std::runtime_error("Property " + value_spec + " unsupported.");
    3633}
    37 const PropertyString & PropertyObject::GetPropertyValueGrepString() {
     34const std::string & PropertyObject::GetPropertyValueGrepString() {
    3835    throw std::runtime_error("Property Value Grep String unsupported.");
    3936}
     
    8077    }
    8178    return enumeration_basis_sets;
    82 };
     79}
    8380
    84 const PropertyString &EnumeratedPropertyObject::GetPropertyValueGrepString() {
    85     if (LLVM_LIKELY(property_value_grep_string.empty())) {
    86         PropertyStringStream buffer;
     81const std::string & EnumeratedPropertyObject::GetPropertyValueGrepString() {
     82    if (LLVM_LIKELY(mPropertyValueGrepString.empty())) {
     83        std::stringstream buffer;
    8784        for (unsigned i = 0; i != property_value_full_names.size(); i++) {
    8885            buffer << canonicalize_value_name(property_value_full_names[i]) + "\n";
     
    9188            buffer << canonicalize_value_name(property_value_enum_names[i]) + "\n";
    9289        }
    93         property_value_grep_string.assign(buffer.str());
     90        mPropertyValueGrepString = buffer.str();
    9491    }
    95     return property_value_grep_string;
     92    return mPropertyValueGrepString;
    9693}
    9794
     
    145142}
    146143
    147 const PropertyString & ExtensionPropertyObject::GetPropertyValueGrepString() {
     144const std::string & ExtensionPropertyObject::GetPropertyValueGrepString() {
    148145    return property_object_table[base_property]->GetPropertyValueGrepString();
    149146}
     
    172169}
    173170
    174 const PropertyString & BinaryPropertyObject::GetPropertyValueGrepString() {
    175     if (property_value_grep_string.empty()) {
    176         PropertyStringStream buffer;
     171const std::string & BinaryPropertyObject::GetPropertyValueGrepString() {
     172    if (mPropertyValueGrepString.empty()) {
     173        std::stringstream buffer;
    177174        for (const auto & prop : Binary_ns::aliases_only_map) {
    178175            buffer << std::get<0>(prop) + "\n";
    179176        }
    180         property_value_grep_string.assign(buffer.str());
     177        mPropertyValueGrepString = buffer.str();
    181178    }
    182     return property_value_grep_string;
     179    return mPropertyValueGrepString;
    183180}
    184181
  • icGREP/icgrep-devel/icgrep/UCD/PropertyObjects.h

    r5235 r5236  
    1414#include <vector>
    1515#include <unordered_map>
    16 #include <util/aligned_allocator.h>
    1716
    1817namespace UCD {
    19 
    20 using PropertyStringAllocator = AlignedAllocator<char, 32>;
    21 
    22 using PropertyString =
    23     std::basic_string<char, std::char_traits<char>, PropertyStringAllocator>;
    2418
    2519std::string canonicalize_value_name(const std::string & prop_or_val);
     
    4842    PropertyObject(property_t p, ClassTypeId k) : the_property(p), the_kind(k) {}
    4943    virtual int GetPropertyValueEnumCode(const std::string & value_spec);
    50     virtual const PropertyString & GetPropertyValueGrepString();
     44    virtual const std::string & GetPropertyValueGrepString();
    5145    property_t the_property;
    5246    ClassTypeId the_kind;
     
    9690
    9791    virtual int GetPropertyValueEnumCode(const std::string & value_spec);
    98     virtual const PropertyString & GetPropertyValueGrepString();
     92    virtual const std::string & GetPropertyValueGrepString();
    9993    const UnicodeSet & GetCodepointSet(const std::string & value_spec);
    10094    const UnicodeSet & GetCodepointSet(const int property_enum_val) const;
     
    107101    }
    108102
    109      iterator end() const {
     103    iterator end() const {
    110104        return property_value_enum_names.cend();
    111105    }
     
    116110    const std::vector<std::string> & property_value_full_names;  // never changes
    117111    std::unordered_map<std::string, int> & property_value_aliases;
    118     PropertyString property_value_grep_string;
     112    std::string mPropertyValueGrepString;
    119113    bool uninitialized; // full names must be added dynamically.
    120114    const std::vector<const UnicodeSet *> property_value_sets;
     
    146140
    147141    virtual int GetPropertyValueEnumCode(const std::string & value_spec);
    148     virtual const PropertyString & GetPropertyValueGrepString();
     142    virtual const std::string & GetPropertyValueGrepString();
    149143    const UnicodeSet & GetCodepointSet(const std::string & value_spec);
    150144    const UnicodeSet & GetCodepointSet(const int property_enum_val) const;
     
    172166    const UnicodeSet & GetCodepointSet(const std::string & value_spec);
    173167    const UnicodeSet & GetCodepointSet(const int property_enum_val);
    174     virtual const PropertyString & GetPropertyValueGrepString();
     168    virtual const std::string & GetPropertyValueGrepString();
    175169private:
    176170    bool mNoUninitialized;
    177171    UnicodeSet mY;
    178172    UnicodeSet mN;
    179     PropertyString property_value_grep_string;
     173    std::string mPropertyValueGrepString;
    180174};
    181175
  • icGREP/icgrep-devel/icgrep/UCD/resolve_properties.cpp

    r5234 r5236  
    220220}
    221221
    222 const PropertyString & getPropertyValueGrepString(const std::string & prop) {
     222const std::string & getPropertyValueGrepString(const std::string & prop) {
    223223    auto propit = alias_map.find(canonicalize_value_name(prop));
    224224    if (propit == alias_map.end()) {
  • icGREP/icgrep-devel/icgrep/UCD/resolve_properties.h

    r5234 r5236  
    2727std::string resolvePropertyFunction(re::Name * const property);
    2828UCD::UnicodeSet resolveUnicodeSet(re::Name * const name);
    29 const PropertyString & getPropertyValueGrepString(const std::string & prop);
     29const std::string & getPropertyValueGrepString(const std::string & prop);
    3030
    3131}
  • icGREP/icgrep-devel/icgrep/grep_engine.cpp

    r5234 r5236  
    3636#include <IDISA/CudaDriver.h>
    3737#endif
     38#include <util/aligned_allocator.h>
    3839
    3940static cl::OptionCategory bGrepOutputOptions("Output Options",
     
    434435
    435436const std::vector<std::string> & GrepEngine::grepPropertyValues(const std::string& propertyName) {
     437    AlignedAllocator<char, 32> alloc;
    436438    setParsedPropertyValues();
    437     const auto & str = UCD::getPropertyValueGrepString(propertyName);
    438     mGrepFunction(const_cast<char *>(str.data()), str.size(), 0);
     439    const std::string & str = UCD::getPropertyValueGrepString(propertyName);
     440    char * aligned = alloc.allocate(str.length() + 1, 0);
     441    std::memcpy(aligned, str.data(), str.length());
     442    aligned[str.length()] = '\0';
     443    mGrepFunction(aligned, str.length(), 0);
     444    alloc.deallocate(aligned, 0);
    439445    return getParsedPropertyValues();
    440446}
  • icGREP/icgrep-devel/icgrep/icgrep.cpp

    r5230 r5236  
    303303    systemCall.append(grepArguments);
    304304
    305     system(systemCall.c_str());
     305    const auto rc = system(systemCall.c_str());
     306    if (LLVM_UNLIKELY(rc < 0)) {
     307        throw std::runtime_error("Error calling grep: " + std::string(strerror(errno)));
     308    }
    306309}
    307310
  • icGREP/icgrep-devel/icgrep/util/aligned_allocator.h

    r5235 r5236  
    33
    44#include <boost/version.hpp>
    5 #if BOOST_VERSION >= 105600
     5#if (BOOST_VERSION >= 105600)
    66#include <boost/align/aligned_allocator.hpp>
    7 template<typename T, unsigned Align>
    8 using AlignedAllocator = boost::alignment::aligned_allocator<T, Align>;
     7template<typename T, unsigned alignment>
     8using AlignedAllocator = boost::alignment::aligned_allocator<T, alignment>;
    99#else
    10 
    11 template <typename T, unsigned Align>
    12 class AlignedAllocator
    13 {
     10#include <stdlib.h>
     11template <typename T, unsigned alignment>
     12class AlignedAllocator {
     13    static_assert ((alignment & (alignment - 1)) == 0, "alignment must be power of two");
    1414public:
    1515    typedef T         value_type;
     
    2222
    2323    template <class U>
    24     struct rebind { typedef AlignedAllocator<U, Align> other; };
     24    struct rebind { typedef AlignedAllocator<U, alignment> other; };
    2525
    2626public:
    2727    AlignedAllocator() noexcept {}
    2828
    29     pointer allocate(size_type n, const_pointer = 0) {
     29    pointer allocate(const size_type n, const_pointer = 0) {
    3030        const auto size = n * sizeof(T);
    3131        if (size == 0) {
     
    3333        }
    3434        void * ptr = nullptr;
    35         int rc = posix_memalign(&ptr, Align, size);
    36         if (rc != 0) {
     35        if (LLVM_UNLIKELY(::posix_memalign(&ptr, alignment, size) != 0)) {
    3736            throw std::bad_alloc();
    3837        }
     38        assert (ptr && (reinterpret_cast<size_t>(ptr) & (alignment - 1)) == 0);
    3939        return reinterpret_cast<pointer>(ptr);
    4040    }
    4141
    42     template<typename Type, unsigned align>
    43     inline bool operator==(AlignedAllocator<Type, align> const &) {
     42    template<typename U, unsigned align>
     43    inline bool operator==(const AlignedAllocator<U, align> &) const {
    4444        return false;
    4545    }
    4646
    47     template<typename Type, unsigned align>
    48     inline bool operator!=(AlignedAllocator<Type, align> const &) {
     47    template<typename U, unsigned align>
     48    inline bool operator!=(const AlignedAllocator<U, align> &) const {
    4949        return true;
    5050    }
    5151
    52 
    5352    void deallocate(pointer p, size_type) noexcept {
    54         return free(p);
     53        return ::free(p);
    5554    }
    5655};
    57 
    5856#endif
    59 
    60 
    61 
    6257#endif // ALIGNED_ALLOCATOR_H
Note: See TracChangeset for help on using the changeset viewer.