Ignore:
Timestamp:
Dec 22, 2016, 2:35:46 PM (2 years ago)
Author:
nmedfort
Message:

Modified memory alignment mechanism for GetPropertyValueGrepString? + misc. changes.

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

Legend:

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

    r5232 r5234  
    99
    1010option(ENABLE_MULTIPLEXING "Compiling the Multiplexing Module")
    11 option(ENABLE_PREGENERATED_UCD_FUNCTIONS "Enable compiling the pregenerated UCD functions")
    1211option(PRINT_TIMING_INFORMATION "Write compilation and execution timing information to standard error stream")
    1312
     
    4342set(Boost_USE_STATIC_LIBS ON)
    4443set(Boost_USE_MULTITHREADED OFF)
    45 set(Boost_USE_STATIC_RUNTIME ON)
     44set(Boost_USE_STATIC_RUNTIME OFF)
    4645find_package(Boost 1.46 REQUIRED COMPONENTS system filesystem iostreams)
    4746
     
    7877target_link_libraries (RegExpCompiler RegExpADT)
    7978
    80 set(PRECOMPILED_FILES "")
    81 
    82 IF(NOT ENABLE_PREGENERATED_UCD_FUNCTIONS)
    83 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDISABLE_PREGENERATED_UCD_FUNCTIONS")
    84 ELSE()
    85 MESSAGE("Enabling predefined UCD functions...")
    86 # add the executable
    87 add_executable(generate_predefined_ucd_functions generate_predefined_ucd_functions.cpp)
    88 llvm_map_components_to_libnames(REQ_LLVM_TARGETS ${LLVM_TARGETS_TO_BUILD})
    89 target_link_libraries (generate_predefined_ucd_functions RegExpADT UCDlib PabloADT CCADT ${REQ_LLVM_TARGETS})
    90 
    91 set(PRECOMPILED_PROPERTIES_OBJ ${PROJECT_BINARY_DIR}/precompiled_properties.o)
    92 set(PRECOMPILED_FILES ${PRECOMPILED_PROPERTIES_OBJ} ${PROJECT_SOURCE_DIR}/UCD/precompiled_properties.cpp)
    93 
    94 if(ENABLE_MULTIPLEXING)
    95 set(MULTIPLEXING_FLAG -multiplexing -reassoc -multiplexing-dist=${PROJECT_BINARY_DIR}/ucd-multiplexing.csv) # -multiplexing-dist=${PROJECT_BINARY_DIR}/ucd-multiplexing.csv #-ldc=ldc.csv
    96 endif()
    97 
    98 add_custom_command(OUTPUT ${PRECOMPILED_FILES}
    99   COMMAND generate_predefined_ucd_functions
    100   ARGS -o ${PRECOMPILED_PROPERTIES_OBJ} -dir ${PROJECT_SOURCE_DIR}/UCD/ ${MULTIPLEXING_FLAG} -DefaultIfHierarchy
    101   DEPENDS generate_predefined_ucd_functions
    102   COMMENT "Building predefined UCD functions..."
    103   VERBATIM)
    104 
    105 add_custom_target(run_generate_predefined_ucd_functions DEPENDS ${PRECOMPILED_FILES})
    106 
    107 add_dependencies(RegExpCompiler run_generate_predefined_ucd_functions)
    108 ENDIF()
    109 
    110 add_executable(icgrep icgrep.cpp toolchain.cpp grep_engine.cpp kernels/pipeline.cpp kernels/scanmatchgen.cpp kernels/cc_kernel.cpp ${PRECOMPILED_FILES})
     79add_executable(icgrep icgrep.cpp toolchain.cpp grep_engine.cpp kernels/pipeline.cpp kernels/scanmatchgen.cpp kernels/cc_kernel.cpp)
    11180add_executable(u8u16 u8u16.cpp toolchain.cpp kernels/p2s_kernel.cpp kernels/pipeline.cpp kernels/deletion.cpp kernels/stdout_kernel.cpp)
    11281add_executable(base64 base64.cpp kernels/radix64.cpp toolchain.cpp kernels/p2s_kernel.cpp kernels/pipeline.cpp kernels/deletion.cpp kernels/stdout_kernel.cpp)
     
    11483add_executable(editd editd/editd.cpp editd/pattern_compiler.cpp toolchain.cpp kernels/pipeline.cpp editd/editdscan_kernel.cpp editd/editd_gpu_kernel.cpp editd/editd_cpu_kernel.cpp)
    11584add_executable(array-test array-test.cpp toolchain.cpp kernels/pipeline.cpp)
    116 
    117 IF(ENABLE_PREGENERATED_UCD_FUNCTIONS)
    118 add_dependencies(icgrep run_generate_predefined_ucd_functions)
    119 ENDIF()
    12085
    12186IF (PRINT_TIMING_INFORMATION)
  • icGREP/icgrep-devel/icgrep/UCD/PropertyObjects.cpp

    r5233 r5234  
    88#include "PropertyObjects.h"
    99#include "PropertyObjectTable.h"
    10 #include <sstream>
     10#include <llvm/Support/Casting.h>
    1111#include <algorithm>
    1212#include <assert.h>
    13 #include <llvm/Support/Casting.h>
     13#include <sstream>
    1414
    1515using namespace llvm;
     
    1717namespace UCD {
    1818
     19using PropertyStringStream =
     20    std::basic_stringstream<char, std::char_traits<char>, PropertyStringAllocator>;
     21
    1922std::string canonicalize_value_name(const std::string & prop_or_val) {
    2023    std::locale loc;
    2124    std::stringstream s;
     25
    2226    for (char c : prop_or_val) {
    2327        if ((c != '_') && (c != ' ') && (c != '-')) {
     
    3135    throw std::runtime_error("Property " + value_spec + " unsupported.");
    3236}
    33 const std::string& PropertyObject::GetPropertyValueGrepString() {
     37const PropertyString & PropertyObject::GetPropertyValueGrepString() {
    3438    throw std::runtime_error("Property Value Grep String unsupported.");
    3539}
     
    4448
    4549const UnicodeSet & EnumeratedPropertyObject::GetCodepointSet(const std::string & value_spec) {
    46     int property_enum_val = GetPropertyValueEnumCode(value_spec);
    47     if (property_enum_val == -1) {
    48         throw std::runtime_error("Enumerated Property " + UCD::property_full_name[the_property] +  ": unknown value: " + value_spec);
     50    const int property_enum_val = GetPropertyValueEnumCode(value_spec);
     51    if (property_enum_val < 0) {
     52        throw std::runtime_error("Enumerated Property " + UCD::property_full_name[the_property] + ": unknown value: " + value_spec);
    4953    }
    5054    return GetCodepointSet(property_enum_val);
     
    6367        // has bit i set, i.e., (e >> i) & 1 == 1.
    6468        unsigned basis_count = 1;
    65         while ((1 << basis_count) < independent_enum_count) basis_count++;
     69        while ((1UL << basis_count) < independent_enum_count) {
     70            basis_count++;
     71        }
    6672        for (unsigned i = 0; i < basis_count; i++) {
    6773            enumeration_basis_sets.push_back(UnicodeSet());
    6874            for (unsigned e = 0; e < independent_enum_count; e++) {
    69                 if (((e >> i) & 1) == 0) {
     75                if (((e >> i) & 1UL) == 0) {
    7076                    enumeration_basis_sets[i] = enumeration_basis_sets[i] + *property_value_sets[e];
    7177                }
     
    7682};
    7783
    78 const std::string& EnumeratedPropertyObject::GetPropertyValueGrepString() {
    79     if (!property_value_grep_string.size()) {
     84const PropertyString &EnumeratedPropertyObject::GetPropertyValueGrepString() {
     85    if (LLVM_LIKELY(property_value_grep_string.empty())) {
     86        PropertyStringStream buffer;
    8087        for (unsigned i = 0; i != property_value_full_names.size(); i++) {
    81             property_value_grep_string += canonicalize_value_name(property_value_full_names[i]) + "\n";
     88            buffer << canonicalize_value_name(property_value_full_names[i]) + "\n";
    8289        }
    8390        for (unsigned i = 0; i != property_value_enum_names.size(); i++) {
    84             property_value_grep_string += canonicalize_value_name(property_value_enum_names[i]) + "\n";
     91            buffer << canonicalize_value_name(property_value_enum_names[i]) + "\n";
    8592        }
     93        property_value_grep_string.assign(buffer.str());
    8694    }
    8795    return property_value_grep_string;
     
    137145}
    138146
    139 const std::string& ExtensionPropertyObject::GetPropertyValueGrepString() {
     147const PropertyString & ExtensionPropertyObject::GetPropertyValueGrepString() {
    140148    return property_object_table[base_property]->GetPropertyValueGrepString();
    141149}
     
    164172}
    165173
    166 const std::string& BinaryPropertyObject::GetPropertyValueGrepString() {
    167     if (!property_value_grep_string.size()) {
    168         for (auto iter = Binary_ns::aliases_only_map.begin(), end = Binary_ns::aliases_only_map.end(); iter != end; ++iter) {
    169             property_value_grep_string += iter->first + "\n";
     174const PropertyString & BinaryPropertyObject::GetPropertyValueGrepString() {
     175    if (property_value_grep_string.empty()) {
     176        PropertyStringStream buffer;
     177        for (const auto & prop : Binary_ns::aliases_only_map) {
     178            buffer << std::get<0>(prop) + "\n";
    170179        }
     180        property_value_grep_string.assign(buffer.str());
    171181    }
    172182    return property_value_grep_string;
  • icGREP/icgrep-devel/icgrep/UCD/PropertyObjects.h

    r5206 r5234  
    1414#include <vector>
    1515#include <unordered_map>
     16#include <boost/align/aligned_allocator.hpp>
    1617
    1718namespace UCD {
     19
     20using PropertyStringAllocator = boost::alignment::aligned_allocator<char, 32>;
     21
     22using PropertyString =
     23    std::basic_string<char, std::char_traits<char>, PropertyStringAllocator>;
    1824
    1925std::string canonicalize_value_name(const std::string & prop_or_val);
     
    3238        , UnsupportedProperty
    3339    };
     40
    3441    using iterator = const std::vector<std::string>::const_iterator;
    3542    inline ClassTypeId getClassTypeId() const {
     
    4148    PropertyObject(property_t p, ClassTypeId k) : the_property(p), the_kind(k) {}
    4249    virtual int GetPropertyValueEnumCode(const std::string & value_spec);
    43     virtual const std::string& GetPropertyValueGrepString();
     50    virtual const PropertyString & GetPropertyValueGrepString();
    4451    property_t the_property;
    4552    ClassTypeId the_kind;
     
    8996
    9097    virtual int GetPropertyValueEnumCode(const std::string & value_spec);
    91     virtual const std::string& GetPropertyValueGrepString();
     98    virtual const PropertyString & GetPropertyValueGrepString();
    9299    const UnicodeSet & GetCodepointSet(const std::string & value_spec);
    93100    const UnicodeSet & GetCodepointSet(const int property_enum_val) const;
     
    109116    const std::vector<std::string> & property_value_full_names;  // never changes
    110117    std::unordered_map<std::string, int> & property_value_aliases;
    111     std::string property_value_grep_string;
     118    PropertyString property_value_grep_string;
    112119    bool uninitialized; // full names must be added dynamically.
    113120    const std::vector<const UnicodeSet *> property_value_sets;
     
    139146
    140147    virtual int GetPropertyValueEnumCode(const std::string & value_spec);
    141     virtual const std::string& GetPropertyValueGrepString();
     148    virtual const PropertyString & GetPropertyValueGrepString();
    142149    const UnicodeSet & GetCodepointSet(const std::string & value_spec);
    143150    const UnicodeSet & GetCodepointSet(const int property_enum_val) const;
     
    165172    const UnicodeSet & GetCodepointSet(const std::string & value_spec);
    166173    const UnicodeSet & GetCodepointSet(const int property_enum_val);
    167     virtual const std::string& GetPropertyValueGrepString();
     174    virtual const PropertyString & GetPropertyValueGrepString();
    168175private:
    169176    bool mNoUninitialized;
    170177    UnicodeSet mY;
    171178    UnicodeSet mN;
    172     std::string property_value_grep_string;
     179    PropertyString property_value_grep_string;
    173180};
    174181
  • icGREP/icgrep-devel/icgrep/UCD/resolve_properties.cpp

    r5233 r5234  
    220220}
    221221
    222 const std::string& getPropertyValueGrepString(const std::string & prop) {
    223     auto propName = canonicalize_value_name(prop);
    224     auto propit = alias_map.find(propName);
     222const PropertyString & getPropertyValueGrepString(const std::string & prop) {
     223    auto propit = alias_map.find(canonicalize_value_name(prop));
    225224    if (propit == alias_map.end()) {
    226225        throw UnicodePropertyExpressionError("Expected a property name, but '" + prop + "' found instead");
  • icGREP/icgrep-devel/icgrep/UCD/resolve_properties.h

    r5206 r5234  
    44#include <string>
    55#include <UCD/unicode_set.h>
     6#include <UCD/PropertyObjects.h>
    67
    78namespace re {
     
    1112
    1213namespace UCD {
     14
    1315
    1416class UnicodePropertyExpressionError : public std::exception {
     
    2527std::string resolvePropertyFunction(re::Name * const property);
    2628UCD::UnicodeSet resolveUnicodeSet(re::Name * const name);
    27 const std::string& getPropertyValueGrepString(const std::string & prop);
     29const PropertyString & getPropertyValueGrepString(const std::string & prop);
    2830
    2931}
  • icGREP/icgrep-devel/icgrep/grep_engine.cpp

    r5230 r5234  
    55 */
    66
    7 #include <grep_engine.h>
     7#include "grep_engine.h"
     8#include <llvm/ExecutionEngine/MCJIT.h>
     9#include <llvm/IR/Verifier.h>
     10#include <llvm/IRReader/IRReader.h>
     11#include <llvm/Support/CommandLine.h>
     12#include <llvm/Support/Debug.h>
     13#include <boost/filesystem.hpp>
     14#include <boost/iostreams/device/mapped_file.hpp>
    815#include <IDISA/idisa_builder.h>
    916#include <IDISA/idisa_target.h>
    10 #include <llvm/Support/CommandLine.h>
    11 #include <re/re_toolchain.h>
    12 #include <re/re_cc.h>
    13 
    14 #include <pablo/pablo_toolchain.h>
    15 #include <toolchain.h>
    16 #include <pablo/pablo_compiler.h>
    17 #include <kernels/pipeline.h>
    18 #include <llvm/IR/Function.h>
    19 #include <llvm/IR/Type.h>
    20 #include <llvm/IR/Module.h>
    21 #include <llvm/ExecutionEngine/MCJIT.h>
    22 #include <llvm/IRReader/IRReader.h>
    23 #include <llvm/Support/Debug.h>
    24 #include <llvm/IR/Verifier.h>
    2517#include <UCD/UnicodeNameData.h>
    2618#include <UCD/resolve_properties.h>
    27 
    28 
     19#include <kernels/cc_kernel.h>
     20#include <kernels/kernel.h>
     21#include <kernels/pipeline.h>
     22#include <kernels/pipeline.h>
     23#include <kernels/s2p_kernel.h>
     24#include <kernels/scanmatchgen.h>
    2925#include <kernels/streamset.h>
    30 #include <kernels/scanmatchgen.h>
    31 #include <kernels/s2p_kernel.h>
    32 #include <kernels/cc_kernel.h>
    33 #include <kernels/pipeline.h>
    34 
     26#include <pablo/pablo_compiler.h>
    3527#include <pablo/pablo_kernel.h>
    3628#include <pablo/pablo_toolchain.h>
    37 
    38 #include <llvm/IR/Intrinsics.h>
    39 #include "llvm/Support/SourceMgr.h"
    40 #include "llvm/IRReader/IRReader.h"
    41 #include "llvm/Linker/Linker.h"
    42 #include "llvm-c/Core.h"
    43 
    44 #include <fstream>
     29#include <pablo/pablo_toolchain.h>
     30#include <re/re_cc.h>
     31#include <re/re_toolchain.h>
     32#include <toolchain.h>
     33#include <iostream>
    4534#include <sstream>
    46 #include <iostream>
    47 #include <string>
    48 #include <stdint.h>
    49 
    50 #include <stdio.h>
    51 #include <stdlib.h>
    52 #include <unistd.h>
    53 #include <errno.h>
    54 #include <sys/types.h>
    55 #include <sys/stat.h>
    56 #include <stdexcept>
    57 #include <cctype>
    58 
    59 
    60 #include <llvm/Support/raw_os_ostream.h>
    61 
    62 // mmap system
    63 #include <boost/filesystem.hpp>
    64 #include <boost/iostreams/device/mapped_file.hpp>
    65 
    66 #include <fcntl.h>
    67 
    68 #include <kernels/kernel.h>
    69 
    7035#ifdef CUDA_ENABLED
    7136#include <IDISA/CudaDriver.h>
     
    470435const std::vector<std::string> & GrepEngine::grepPropertyValues(const std::string& propertyName) {
    471436    setParsedPropertyValues();
    472 
    473     std::string str = UCD::getPropertyValueGrepString(propertyName);
    474     char* grepInput = nullptr;
    475     posix_memalign( (void**)&grepInput, 32, str.size() * sizeof(char));
    476     strncpy(grepInput, str.c_str(), str.size());
    477     mGrepFunction(grepInput, str.size(), 0);
    478     free(grepInput);
    479 
    480     return getParsedProeprtyValues();
     437    const auto & str = UCD::getPropertyValueGrepString(propertyName);
     438    mGrepFunction(const_cast<char *>(str.data()), str.size(), 0);
     439    return getParsedPropertyValues();
    481440}
    482441
     
    614573
    615574
    616 std::vector<std::string> parsedPropertyValues;
     575static std::vector<std::string> parsedPropertyValues;
    617576
    618577extern "C" {
     
    627586}
    628587
    629 inline const std::vector<std::string>& getParsedProeprtyValues() {
     588inline const std::vector<std::string>& getParsedPropertyValues() {
    630589    return parsedPropertyValues;
    631590}
     
    634593void icgrep_Linking(Module * m, ExecutionEngine * e) {
    635594    Module::FunctionListType & fns = m->getFunctionList();
    636     for (Module::FunctionListType::iterator it = fns.begin(), it_end = fns.end(); it != it_end; ++it) {
     595    for (auto it = fns.begin(), it_end = fns.end(); it != it_end; ++it) {
    637596        std::string fnName = it->getName().str();
    638597        if (fnName == "s2p_block") continue;
     
    649608            e->addGlobalMapping(cast<GlobalValue>(it), (void *)&insert_property_values);
    650609        }
    651 #ifndef DISABLE_PREGENERATED_UCD_FUNCTIONS
    652         else {
    653             const UCD::ExternalProperty & ep = UCD::resolveExternalProperty(fnName);
    654             e->addGlobalMapping(cast<GlobalValue>(it), std::get<0>(ep));
    655         }
    656 #endif
    657     }
    658 }
    659 
     610    }
     611}
     612
  • icGREP/icgrep-devel/icgrep/grep_engine.h

    r5206 r5234  
    5151void setParsedCodePointSet();
    5252
    53 const std::vector<std::string>& getParsedProeprtyValues();
     53const std::vector<std::string>& getParsedPropertyValues();
    5454void setParsedPropertyValues();
    5555
  • icGREP/icgrep-devel/icgrep/icgrep-devel.files

    r5230 r5234  
    573573IDISA/types/streamtype.cpp
    574574IDISA/types/streamtype.cpp
     575base64.cpp
  • icGREP/icgrep-devel/icgrep/kernels/pipeline.cpp

    r5227 r5234  
    7272        kernels[i]->createDoSegmentCall(instancePtrs[i], segmentBlocks);
    7373        // Must be the last action, for synchronization.
    74         kernels[i]->releaseLogicalSegmentNo(instancePtrs[i], iBuilder->CreateAdd(processedSegmentCount, ConstantInt::get(iBuilder->getSizeTy(), 1)));
     74        kernels[i]->releaseLogicalSegmentNo(instancePtrs[i], iBuilder->CreateAdd(processedSegmentCount, iBuilder->getSize(1)));
    7575        if (i == last_kernel) break;
    7676        iBuilder->CreateBr(segmentWait[i+1]);
     
    212212        kernels[i]->createDoSegmentCall(kernels[i]->getInstance(), segBlocks);
    213213        Value * segNo = kernels[i]->acquireLogicalSegmentNo(kernels[i]->getInstance());
    214         kernels[i]->releaseLogicalSegmentNo(kernels[i]->getInstance(), iBuilder->CreateAdd(segNo, ConstantInt::get(iBuilder->getSizeTy(), 1)));
     214        kernels[i]->releaseLogicalSegmentNo(kernels[i]->getInstance(), iBuilder->CreateAdd(segNo, iBuilder->getSize(1)));
    215215    }
    216216    Value * endSignal = kernels.back()->getTerminationSignal(kernels.back()->getInstance());
  • icGREP/icgrep-devel/icgrep/kernels/radix64.cpp

    r5232 r5234  
    291291    iBuilder->SetInsertPoint(BasicBlock::Create(iBuilder->getContext(), "entry", doBlockFunction, 0));
    292292    Value * self = getParameter(doBlockFunction, "self");
    293     iBuilder->CreateCall(doSegmentFunction, {self, ConstantInt::get(iBuilder->getSizeTy(), 1)});
     293    iBuilder->CreateCall(doSegmentFunction, {self, iBuilder->getSize(1)});
    294294    iBuilder->CreateRetVoid();
    295295    iBuilder->restoreIP(savePoint);
     
    358358    Value * self = &*(args++);
    359359    Value * remainingBytes = &*(args++);
    360     Value * remainMod4 = iBuilder->CreateAnd(remainingBytes, ConstantInt::get(iBuilder->getSizeTy(), 3));
     360    Value * remainMod4 = iBuilder->CreateAnd(remainingBytes, iBuilder->getSize(3));
    361361
    362362    const unsigned PACK_SIZE = iBuilder->getStride()/8;
     
    365365    Value * expandedstream_ptr = getStreamSetBlockPtr(self, "expandedStream", blockNo);
    366366    Value * radix64stream_ptr = getStreamSetBlockPtr(self, "radix64stream", blockNo);
    367     Type * i8_t = iBuilder->getInt8Ty();
    368 
    369     Value * step_right_6 = iBuilder->simd_fill(32, ConstantInt::get(iBuilder->getInt32Ty(), 0x00C00000));
    370     Value * step_left_8 = iBuilder->simd_fill(32, ConstantInt::get(iBuilder->getInt32Ty(), 0x003F0000));
    371     Value * step_right_4 = iBuilder->simd_fill(32, ConstantInt::get(iBuilder->getInt32Ty(), 0x0000F000));
    372     Value * step_left_10 = iBuilder->simd_fill(32, ConstantInt::get(iBuilder->getInt32Ty(), 0x00000F00));
    373     Value * step_right_2 = iBuilder->simd_fill(32, ConstantInt::get(iBuilder->getInt32Ty(), 0x000000FC));
    374     Value * step_left_12 = iBuilder->simd_fill(32, ConstantInt::get(iBuilder->getInt32Ty(), 0x00000003));
     367
     368    Value * step_right_6 = iBuilder->simd_fill(32, iBuilder->getInt32(0x00C00000));
     369    Value * step_left_8 = iBuilder->simd_fill(32, iBuilder->getInt32(0x003F0000));
     370    Value * step_right_4 = iBuilder->simd_fill(32, iBuilder->getInt32(0x0000F000));
     371    Value * step_left_10 = iBuilder->simd_fill(32, iBuilder->getInt32(0x00000F00));
     372    Value * step_right_2 = iBuilder->simd_fill(32, iBuilder->getInt32(0x000000FC));
     373    Value * step_left_12 = iBuilder->simd_fill(32, iBuilder->getInt32(0x00000003));
    375374
    376375
    377376    // Enter the loop only if there is at least one byte remaining to process.
    378     iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(remainingBytes, ConstantInt::get(iBuilder->getSizeTy(), 0)), fbExit, radix64_loop);
     377    iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(remainingBytes, iBuilder->getSize(0)), fbExit, radix64_loop);
    379378
    380379    iBuilder->SetInsertPoint(radix64_loop);
     
    412411    iBuilder->SetInsertPoint(loopExit);
    413412    // All base64 data has been computed, but we may need to set one or two '=' padding bytes.
    414     iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(remainMod4, ConstantInt::get(iBuilder->getSizeTy(), 0)), fbExit, handleRemainFirstByte);
     413    iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(remainMod4, iBuilder->getSize(0)), fbExit, handleRemainFirstByte);
    415414    iBuilder->SetInsertPoint(handleRemainFirstByte);
    416415    // At least one padding byte required.
     
    431430
    432431
    433     iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(remainMod4, ConstantInt::get(iBuilder->getSizeTy(), 1)), handleNoRemainSecondByte, handleRemainSecondByte);
     432    iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(remainMod4, iBuilder->getSize(1)), handleNoRemainSecondByte, handleRemainSecondByte);
    434433    iBuilder->SetInsertPoint(handleRemainSecondByte);
    435434
     
    450449
    451450    iBuilder->SetInsertPoint(fbExit);
    452     Value * outputNumberAdd = iBuilder->CreateSelect(iBuilder->CreateICmpEQ(remainMod4, ConstantInt::get(iBuilder->getSizeTy(), 0)), ConstantInt::get(iBuilder->getSizeTy(), 0), ConstantInt::get(iBuilder->getSizeTy(), 1));
     451    Value * outputNumberAdd = iBuilder->CreateSelect(iBuilder->CreateICmpEQ(remainMod4, iBuilder->getSize(0)), iBuilder->getSize(0), iBuilder->getSize(1));
    453452    Value * produced = iBuilder->CreateAdd(getProducedItemCount(self), iBuilder->CreateAdd(remainingBytes, outputNumberAdd));
    454453    setProducedItemCount(self, produced);
     
    477476void base64Kernel::generateDoBlockLogic(Value * self, Value * blockNo) {
    478477    Value * radix64stream_ptr = getStreamSetBlockPtr(self, "radix64stream", blockNo);
    479     Value * base64stream_ptr = getStreamSetBlockPtr(self, "base64stream", blockNo);
    480     Type * i8_t = iBuilder->getInt8Ty();
    481    
     478    Value * base64stream_ptr = getStreamSetBlockPtr(self, "base64stream", blockNo);   
    482479    for (unsigned i = 0; i < 8; i++) {
    483480        Value * bytepack = iBuilder->CreateBlockAlignedLoad(radix64stream_ptr, {iBuilder->getInt32(0), iBuilder->getInt32(0), iBuilder->getInt32(i)});
    484         Value * mask_gt_25 = iBuilder->simd_ugt(8, bytepack, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 25)));
    485         Value * mask_gt_51 = iBuilder->simd_ugt(8, bytepack, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 51)));
    486         Value * mask_eq_62 = iBuilder->simd_eq(8, bytepack, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 62)));
    487         Value * mask_eq_63 = iBuilder->simd_eq(8, bytepack, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 63)));
     481        Value * mask_gt_25 = iBuilder->simd_ugt(8, bytepack, iBuilder->simd_fill(8, iBuilder->getInt8(25)));
     482        Value * mask_gt_51 = iBuilder->simd_ugt(8, bytepack, iBuilder->simd_fill(8, iBuilder->getInt8(51)));
     483        Value * mask_eq_62 = iBuilder->simd_eq(8, bytepack, iBuilder->simd_fill(8, iBuilder->getInt8(62)));
     484        Value * mask_eq_63 = iBuilder->simd_eq(8, bytepack, iBuilder->simd_fill(8, iBuilder->getInt8(63)));
    488485        // Strategy:
    489486        // 1. add ord('A') = 65 to all radix64 values, this sets the correct values for entries 0 to 25.
     
    492489        // 4. subtract ord('0') - ord('+') + (62 - 52) = 15 for all values = 62
    493490        // 4. subtract ord('0') - ord('/') + (63 - 62) = 2 for all values = 63
    494         Value * t0_25 = iBuilder->simd_add(8, bytepack, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 'A')));
    495         Value * t0_51 = iBuilder->simd_add(8, t0_25, iBuilder->simd_and(mask_gt_25, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 6))));
    496         Value * t0_61 = iBuilder->simd_sub(8, t0_51, iBuilder->simd_and(mask_gt_51, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 75))));
    497         Value * t0_62 = iBuilder->simd_sub(8, t0_61, iBuilder->simd_and(mask_eq_62, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 15))));
    498         Value * base64pack = iBuilder->simd_sub(8, t0_62, iBuilder->simd_and(mask_eq_63, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 2))));
     491        Value * t0_25 = iBuilder->simd_add(8, bytepack, iBuilder->simd_fill(8, iBuilder->getInt8('A')));
     492        Value * t0_51 = iBuilder->simd_add(8, t0_25, iBuilder->simd_and(mask_gt_25, iBuilder->simd_fill(8, iBuilder->getInt8(6))));
     493        Value * t0_61 = iBuilder->simd_sub(8, t0_51, iBuilder->simd_and(mask_gt_51, iBuilder->simd_fill(8, iBuilder->getInt8(75))));
     494        Value * t0_62 = iBuilder->simd_sub(8, t0_61, iBuilder->simd_and(mask_eq_62, iBuilder->simd_fill(8, iBuilder->getInt8(15))));
     495        Value * base64pack = iBuilder->simd_sub(8, t0_62, iBuilder->simd_and(mask_eq_63, iBuilder->simd_fill(8, iBuilder->getInt8(2))));
    499496        iBuilder->CreateBlockAlignedStore(iBuilder->bitCast(base64pack), base64stream_ptr, {iBuilder->getInt32(0), iBuilder->getInt32(0), iBuilder->getInt32(i)});
    500497    }
     
    527524    padBytes = iBuilder->CreateAnd(padBytes, ConstantInt::get(iBuilder->getSizeTy(), 3));
    528525
    529     const unsigned PACK_SIZE = iBuilder->getStride()/8;
    530     Constant * packSize = ConstantInt::get(iBuilder->getSizeTy(), PACK_SIZE);
     526    Constant * packSize = iBuilder->getSize(iBuilder->getStride() / 8);
    531527    Value * blockNo = getScalarField(self, blockNoScalar);
    532528    Value * radix64stream_ptr = getStreamSetBlockPtr(self, "radix64stream", blockNo);
    533529    Value * base64stream_ptr = getStreamSetBlockPtr(self, "base64stream", blockNo);
    534     Type * i8_t = iBuilder->getInt8Ty();
    535530   
    536531    // Enter the loop only if there is at least one byte remaining to process.
    537     iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(remainingBytes, ConstantInt::get(iBuilder->getSizeTy(), 0)), fbExit, base64_loop);
     532    iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(remainingBytes, iBuilder->getSize(0)), fbExit, base64_loop);
    538533   
    539534    iBuilder->SetInsertPoint(base64_loop);
     
    543538    loopRemain->addIncoming(remainingBytes, base64_fb_entry);
    544539    Value * bytepack = iBuilder->CreateBlockAlignedLoad(radix64stream_ptr, {iBuilder->getInt32(0), iBuilder->getInt32(0), idx});
    545     Value * mask_gt_25 = iBuilder->simd_ugt(8, bytepack, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 25)));
    546     Value * mask_gt_51 = iBuilder->simd_ugt(8, bytepack, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 51)));
    547     Value * mask_eq_62 = iBuilder->simd_eq(8, bytepack, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 62)));
    548     Value * mask_eq_63 = iBuilder->simd_eq(8, bytepack, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 63)));
    549     Value * t0_25 = iBuilder->simd_add(8, bytepack, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 'A')));
    550     Value * t0_51 = iBuilder->simd_add(8, t0_25, iBuilder->simd_and(mask_gt_25, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 6))));
    551     Value * t0_61 = iBuilder->simd_sub(8, t0_51, iBuilder->simd_and(mask_gt_51, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 75))));
    552     Value * t0_62 = iBuilder->simd_sub(8, t0_61, iBuilder->simd_and(mask_eq_62, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 15))));
    553     Value * base64pack = iBuilder->simd_sub(8, t0_62, iBuilder->simd_and(mask_eq_63, iBuilder->simd_fill(8, ConstantInt::get(i8_t, 2))));
     540    Value * mask_gt_25 = iBuilder->simd_ugt(8, bytepack, iBuilder->simd_fill(8, iBuilder->getInt8(25)));
     541    Value * mask_gt_51 = iBuilder->simd_ugt(8, bytepack, iBuilder->simd_fill(8, iBuilder->getInt8(51)));
     542    Value * mask_eq_62 = iBuilder->simd_eq(8, bytepack, iBuilder->simd_fill(8, iBuilder->getInt8(62)));
     543    Value * mask_eq_63 = iBuilder->simd_eq(8, bytepack, iBuilder->simd_fill(8, iBuilder->getInt8(63)));
     544    Value * t0_25 = iBuilder->simd_add(8, bytepack, iBuilder->simd_fill(8, iBuilder->getInt8('A')));
     545    Value * t0_51 = iBuilder->simd_add(8, t0_25, iBuilder->simd_and(mask_gt_25, iBuilder->simd_fill(8, iBuilder->getInt8(6))));
     546    Value * t0_61 = iBuilder->simd_sub(8, t0_51, iBuilder->simd_and(mask_gt_51, iBuilder->simd_fill(8, iBuilder->getInt8(75))));
     547    Value * t0_62 = iBuilder->simd_sub(8, t0_61, iBuilder->simd_and(mask_eq_62, iBuilder->simd_fill(8, iBuilder->getInt8(15))));
     548    Value * base64pack = iBuilder->simd_sub(8, t0_62, iBuilder->simd_and(mask_eq_63, iBuilder->simd_fill(8, iBuilder->getInt8(2))));
    554549    iBuilder->CreateBlockAlignedStore(iBuilder->bitCast(base64pack), base64stream_ptr, {iBuilder->getInt32(0), iBuilder->getInt32(0), idx});
    555550    idx->addIncoming(iBuilder->CreateAdd(idx, ConstantInt::get(iBuilder->getInt32Ty(), 1)), base64_loop);
     
    561556
    562557    iBuilder->SetInsertPoint(loopExit);
    563     iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(padBytes, ConstantInt::get(iBuilder->getSizeTy(), 0)), fbExit, doPadding);
     558    iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(padBytes, iBuilder->getSize(0)), fbExit, doPadding);
    564559    iBuilder->SetInsertPoint(doPadding);
    565560    Value * i8output_ptr = iBuilder->CreatePointerCast(base64stream_ptr, iBuilder->getInt8PtrTy());
    566561    iBuilder->CreateStore(ConstantInt::get(iBuilder->getInt8Ty(), '='), iBuilder->CreateGEP(i8output_ptr, {remainingBytes}));
    567     iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(remainMod4, ConstantInt::get(iBuilder->getSizeTy(), 3)), fbExit, doPadding2);
     562    iBuilder->CreateCondBr(iBuilder->CreateICmpEQ(remainMod4, iBuilder->getSize(3)), fbExit, doPadding2);
    568563    iBuilder->SetInsertPoint(doPadding2);
    569     Value * finalPadPos = iBuilder->CreateAdd(remainingBytes, ConstantInt::get(iBuilder->getSizeTy(), 1));
     564    Value * finalPadPos = iBuilder->CreateAdd(remainingBytes, iBuilder->getSize(1));
    570565    iBuilder->CreateStore(ConstantInt::get(iBuilder->getInt8Ty(), '='), iBuilder->CreateGEP(i8output_ptr, {finalPadPos}));
    571566    iBuilder->CreateBr(fbExit);
  • icGREP/icgrep-devel/icgrep/kernels/s2p_kernel.cpp

    r5230 r5234  
    138138    BasicBlock * exitBlock = BasicBlock::Create(iBuilder->getContext(), "exit", finalBlockFunction, 0);
    139139   
    140     Value * emptyBlockCond = iBuilder->CreateICmpEQ(remainingBytes, ConstantInt::get(iBuilder->getSizeTy(), 0));
     140    Value * emptyBlockCond = iBuilder->CreateICmpEQ(remainingBytes, iBuilder->getSize(0));
    141141    iBuilder->CreateCondBr(emptyBlockCond, finalEmptyBlock, finalPartialBlock);
    142142    iBuilder->SetInsertPoint(finalPartialBlock);
  • icGREP/icgrep-devel/icgrep/kernels/stdout_kernel.cpp

    r5230 r5234  
    3131    iBuilder->SetInsertPoint(BasicBlock::Create(iBuilder->getContext(), "entry", doBlockFunction, 0));
    3232    Value * self = getParameter(doBlockFunction, "self");
    33     iBuilder->CreateCall(doSegmentFunction, {self, ConstantInt::get(iBuilder->getSizeTy(), 1)});
     33    iBuilder->CreateCall(doSegmentFunction, {self, iBuilder->getSize(1)});
    3434    iBuilder->CreateRetVoid();
    3535    iBuilder->restoreIP(savePoint);
  • icGREP/icgrep-devel/icgrep/kernels/symboltablepipeline.cpp

    r5230 r5234  
    279279    startIndexPhi1->addIncoming(startIndex, groupBody);
    280280    PHINode * startIV = iBuilder->CreatePHI(iBuilder->getSizeTy(), 2);
    281     startIV->addIncoming(ConstantInt::get(iBuilder->getSizeTy(), 0), groupBody);
     281    startIV->addIncoming(iBuilder->getSize(0), groupBody);
    282282    Value * startOuterTest = iBuilder->CreateICmpNE(startIV, ConstantInt::get(iBuilder->getSizeTy(), fieldCount));
    283283    iBuilder->CreateCondBr(startOuterTest, startOuterBody, endOuterCond);
     
    286286    iBuilder->SetInsertPoint(startOuterBody);
    287287    Value * startField = iBuilder->CreateExtractElement(startStream, startIV);
    288     startIV->addIncoming(iBuilder->CreateAdd(startIV, ConstantInt::get(iBuilder->getSizeTy(), 1)), startInnerCond);
     288    startIV->addIncoming(iBuilder->CreateAdd(startIV, iBuilder->getSize(1)), startInnerCond);
    289289    startBlockOffset->addIncoming(iBuilder->CreateAdd(startBlockOffset, ConstantInt::get(iBuilder->getSizeTy(), scanWordBitWidth)), startInnerCond);
    290290    iBuilder->CreateBr(startInnerCond);
     
    318318    startIndexPhi3->addIncoming(startIndexPhi1, startOuterCond);
    319319    PHINode * endIV = iBuilder->CreatePHI(iBuilder->getSizeTy(), 2);
    320     endIV->addIncoming(ConstantInt::get(iBuilder->getSizeTy(), 0), startOuterCond);
     320    endIV->addIncoming(iBuilder->getSize(0), startOuterCond);
    321321    Value * endOuterTest = iBuilder->CreateICmpNE(endIV, ConstantInt::get(iBuilder->getSizeTy(), fieldCount));
    322322    iBuilder->CreateCondBr(endOuterTest, endOuterBody, nextGroup);
     
    325325    iBuilder->SetInsertPoint(endOuterBody);
    326326    Value * endField = iBuilder->CreateExtractElement(endStream, endIV);
    327     endIV->addIncoming(iBuilder->CreateAdd(endIV, ConstantInt::get(iBuilder->getSizeTy(), 1)), endInnerCond);
     327    endIV->addIncoming(iBuilder->CreateAdd(endIV, iBuilder->getSize(1)), endInnerCond);
    328328    endBlockOffset->addIncoming(iBuilder->CreateAdd(endBlockOffset, ConstantInt::get(iBuilder->getSizeTy(), scanWordBitWidth)), endInnerCond);
    329329    iBuilder->CreateBr(endInnerCond);
     
    729729    remainingBytes3->addIncoming(bufferSize, partialLeadingCond);
    730730    remainingBytes3->addIncoming(remainingBytes2, regularCondBlock);
    731     Value * partialBlockCond = iBuilder->CreateICmpSGT(remainingBytes3, ConstantInt::get(iBuilder->getSizeTy(), 0));
     731    Value * partialBlockCond = iBuilder->CreateICmpSGT(remainingBytes3, iBuilder->getSize(0);
    732732    iBuilder->CreateCondBr(partialBlockCond, partialBodyBlock, flushLengthGroupsBlock);
    733733
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r5227 r5234  
    284284#ifdef ENABLE_BOUNDED_WHILE
    285285    if (whileStatement->getBound()) {
    286         Value * new_bound = iBuilder->CreateSub(bound_phi, ConstantInt::get(iBuilder->getSizeTy(), 1));
     286        Value * new_bound = iBuilder->CreateSub(bound_phi, iBuilder->getSize(1));
    287287        bound_phi->addIncoming(new_bound, whileExitBlock);
    288288        condition = iBuilder->CreateAnd(condition, iBuilder->CreateICmpUGT(new_bound, ConstantInt::getNullValue(iBuilder->getSizeTy())));
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r5233 r5234  
    2626#include <UCD/ucd_compiler.hpp>
    2727#include <UCD/resolve_properties.h>
    28 #ifndef DISABLE_PREGENERATED_UCD_FUNCTIONS
    29 #include <UCD/precompiled_properties.h>
    30 #endif
    3128#include <assert.h>
    3229#include <stdexcept>
  • icGREP/icgrep-devel/icgrep/re/re_name.h

    r5233 r5234  
    5555    , mName(replicateString(name, nameLength))
    5656    , mType(type)
    57     , mDefinition(defn)
    58     {
     57    , mDefinition(defn) {
    5958
    6059    }
  • icGREP/icgrep-devel/icgrep/re/re_name_resolve.cpp

    r5233 r5234  
    2626namespace re {
    2727 
    28 static inline CC * getDefinition(RE * re) {
     28static inline CC * extractCC(RE * re) {
    2929    if (isa<CC>(re)) {
    3030        return cast<CC>(re);
    3131    } else if (isa<Name>(re)) {
    32         return getDefinition(cast<Name>(re)->getDefinition());
     32        return extractCC(cast<Name>(re)->getDefinition());
    3333    }
    3434    return nullptr;
     
    4848                            mZeroWidth = name;
    4949                        }
    50                         resolve(name->getDefinition());
     50                        name->setDefinition(resolve(name->getDefinition()));
    5151                    } else {
    52                         #ifndef DISABLE_PREGENERATED_UCD_FUNCTIONS
    53                         if (AlgorithmOptionIsSet(UsePregeneratedUnicode)) {
    54                             const std::string functionName = UCD::resolvePropertyFunction(name);
    55                             const UCD::ExternalProperty & ep = UCD::resolveExternalProperty(functionName);
    56                             Call * call = mPB.createCall(Prototype::Create(functionName, std::get<1>(ep), std::get<2>(ep), std::get<0>(ep)), mCCCompiler.getBasisBits());
    57                             name->setCompiled(call);
    58                         } else {
    59                         #endif
    60                             name->setDefinition(makeCC(UCD::resolveUnicodeSet(name)));
    61                         #ifndef DISABLE_PREGENERATED_UCD_FUNCTIONS
    62                         }
    63                         #endif
     52                        name->setDefinition(makeCC(UCD::resolveUnicodeSet(name)));
    6453                    }
    6554                } else {
    66                 throw std::runtime_error("All non-unicode-property Name objects should have been defined prior to Unicode property resolution.");
     55                    throw std::runtime_error("All non-unicode-property Name objects should have been defined prior to Unicode property resolution.");
    6756                }
    6857            } else {
     
    7867            for (auto ai = alt->begin(); ai != alt->end(); ) {
    7968                RE * re = resolve(*ai);
    80                 if (CC * cc = getDefinition(re)) {
     69                if (CC * cc = extractCC(re)) {
    8170                    if (unionCC == nullptr) {
    8271                        unionCC = cc;
     
    112101            diff->setLH(resolve(diff->getLH()));
    113102            diff->setRH(resolve(diff->getRH()));
    114             CC * lh = getDefinition(diff->getLH());
    115             CC * rh = getDefinition(diff->getRH());
     103            CC * lh = extractCC(diff->getLH());
     104            CC * rh = extractCC(diff->getRH());
    116105            if (lh && rh) {
    117106                return resolve(makeName("diff", subtractCC(lh, rh)));
     
    120109            ix->setLH(resolve(ix->getLH()));
    121110            ix->setRH(resolve(ix->getRH()));
    122             CC * lh = getDefinition(ix->getLH());
    123             CC * rh = getDefinition(ix->getRH());
     111            CC * lh = extractCC(ix->getLH());
     112            CC * rh = extractCC(ix->getRH());
    124113            if (lh && rh) {
    125114                return resolve(makeName("intersect", intersectCC(lh, rh)));
  • icGREP/icgrep-devel/icgrep/re/re_parser.cpp

    r5224 r5234  
    6666
    6767RE_Parser::RE_Parser(const std::string & regular_expression)
    68     : fModeFlagSet(0)
    69     , fNested(false)
    70     , fGraphemeBoundaryPending(false)
    71     , fSupportNonCaptureGroup(false)
    72     , mCursor(regular_expression)
    73     , mCaptureGroupCount(0)
    74     , mReSyntax(RE_Syntax::PCRE)
    75     {
    76 
    77     }
     68: fModeFlagSet(0)
     69, fNested(false)
     70, fGraphemeBoundaryPending(false)
     71, fSupportNonCaptureGroup(false)
     72, mCursor(regular_expression)
     73, mCaptureGroupCount(0)
     74, mReSyntax(RE_Syntax::PCRE)
     75{
     76
     77}
    7878
    7979RE * makeAtomicGroup(RE * r) {
  • icGREP/icgrep-devel/icgrep/re/re_toolchain.cpp

    r5230 r5234  
    4646                              clEnumVal(DisableUnicodeLineBreak, "disable Unicode line breaks - use LF only"),
    4747                              clEnumValN(InvertMatches, "v", "select non-matching lines"),
    48 #ifndef DISABLE_PREGENERATED_UCD_FUNCTIONS
    49                               clEnumVal(UsePregeneratedUnicode, "use fixed pregenerated Unicode character class sets instead"),
    50 #endif
    5148                              clEnumValEnd),
    5249                   cl::cat(RegexOptions));
  • icGREP/icgrep-devel/icgrep/u8u16.cpp

    r5230 r5234  
    398398void u8u16(u8u16FunctionType fn_ptr, const std::string & fileName) {
    399399    std::string mFileName = fileName;
    400     size_t mFileSize;
    401     char * mFileBuffer;
     400    size_t fileSize;
     401    char * fileBuffer;
    402402   
    403403    const boost::filesystem::path file(mFileName);
     
    411411    }
    412412   
    413     mFileSize = file_size(file);
     413    fileSize = file_size(file);
    414414    boost::iostreams::mapped_file_source mFile;
    415     if (mFileSize == 0) {
    416         mFileBuffer = nullptr;
     415    if (fileSize == 0) {
     416        fileBuffer = nullptr;
    417417    }
    418418    else {
     
    423423            return;
    424424        }
    425         mFileBuffer = const_cast<char *>(mFile.data());
     425        fileBuffer = const_cast<char *>(mFile.data());
    426426    }
    427427
    428428    if (mMapBuffering) {
    429         boost::interprocess::mapped_region outputBuffer(boost::interprocess::anonymous_shared_memory(2*mFileSize));
     429        boost::interprocess::mapped_region outputBuffer(boost::interprocess::anonymous_shared_memory(2*fileSize));
    430430        outputBuffer.advise(boost::interprocess::mapped_region::advice_willneed);
    431431        outputBuffer.advise(boost::interprocess::mapped_region::advice_sequential);
    432         fn_ptr(mFileBuffer, static_cast<char*>(outputBuffer.get_address()), mFileSize);
     432        fn_ptr(fileBuffer, static_cast<char*>(outputBuffer.get_address()), fileSize);
    433433    }
    434434    else if (memAlignBuffering) {
    435435        char * outputBuffer;
    436         posix_memalign(reinterpret_cast<void **>(&outputBuffer), 32, 2*mFileSize);
    437         fn_ptr(mFileBuffer, outputBuffer, mFileSize);
     436        const auto r = posix_memalign(reinterpret_cast<void **>(&outputBuffer), 32, 2*fileSize);
     437        if (LLVM_UNLIKELY(r != 0)) {
     438            throw std::runtime_error("posix_memalign failed with return code " + std::to_string(r));
     439        }
     440        fn_ptr(fileBuffer, outputBuffer, fileSize);
    438441        free(reinterpret_cast<void *>(outputBuffer));
    439442    }
    440443    else {
    441444        /* No external output buffer */
    442         fn_ptr(mFileBuffer, nullptr, mFileSize);
     445        fn_ptr(fileBuffer, nullptr, fileSize);
    443446    }
    444447    mFile.close();
Note: See TracChangeset for help on using the changeset viewer.