Ignore:
Timestamp:
Sep 19, 2015, 7:25:09 AM (4 years ago)
Author:
cameron
Message:

Hongpu's option to use Boost mmap; fix an include for std::iota

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

Legend:

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

    r4777 r4778  
    1515endif()
    1616option(ENABLE_MULTIPLEXING "Compiling the Multiplexing Module")
     17option(USE_BOOST_MMAP "Using mmap from Boost.Iostreams")
    1718option(DISABLE_PREGENERATED_UCD_FUNCTIONS "Disable compiling the pregenerated UCD functions")
    1819
     
    5657
    5758if(ENABLE_MULTIPLEXING)
    58 find_package(Boost COMPONENTS system REQUIRED)
    59 else()
    60 find_package(Boost)
     59  SET(REQ_BOOST_COMPONENTS ${REQ_BOOST_COMPONENTS} system)
     60endif()
     61if(USE_BOOST_MMAP)
     62  SET(REQ_BOOST_COMPONENTS ${REQ_BOOST_COMPONENTS} iostreams)
     63endif()
     64
     65if(REQ_BOOST_COMPONENTS)
     66  find_package(Boost COMPONENTS ${REQ_BOOST_COMPONENTS} REQUIRED)
    6167endif()
    6268
     
    121127    link_directories(${Boost_LIBRARY_DIR})
    122128    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_BOOST")
     129    target_link_libraries(icgrep ${Boost_LIBRARIES})
    123130ENDIF()
    124131
    125132target_link_libraries (icgrep UCDlib PabloADT RegExpCompiler CCADT ${REQ_LLVM_LIBRARIES})
    126133
     134IF(USE_BOOST_MMAP)
     135  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_BOOST_MMAP")
     136ENDIF()
    127137
    128138
  • icGREP/icgrep-devel/icgrep/do_grep.cpp

    r4750 r4778  
    2828
    2929// mmap system
     30#ifdef USE_BOOST_MMAP
     31#include <boost/iostreams/device/mapped_file.hpp>
     32#else
    3033#include <sys/mman.h>
     34#endif
    3135#include <fcntl.h>
    3236
     
    165169    // 1 guard byte.  PROT_WRITE enables writing the sentinel.
    166170    const size_t mmap_sentinel_bytes = 2; 
     171#ifdef USE_BOOST_MMAP
     172    boost::iostreams::mapped_file mFile;
     173    try {
     174        mFile.open(
     175            infilename,
     176            boost::iostreams::mapped_file_base::mapmode::priv,
     177            mFileSize + mmap_sentinel_bytes, 0
     178        );
     179    } catch (std::ios_base::failure e) {
     180        std::cerr << "Error: Boost mmap " << e.what() << std::endl;
     181        return;
     182    }
     183    mFileBuffer = mFile.data();
     184#else
    167185    mFileBuffer = (char *) mmap(NULL, mFileSize + mmap_sentinel_bytes, PROT_READ|PROT_WRITE, MAP_PRIVATE, fdSrc, 0);
    168186    if (mFileBuffer == MAP_FAILED) {
     
    175193        return;
    176194    }
     195#endif
    177196    char * buffer_ptr;
    178197    size_t segment = 0;
     
    313332    }
    314333   
     334#ifdef USE_BOOST_MMAP
     335    mFile.close();
     336#else
    315337    munmap((void *) mFileBuffer, mFileSize + mmap_sentinel_bytes);
     338#endif
    316339    close(fdSrc);
    317340   
  • icGREP/icgrep-devel/icgrep/pablo/optimizers/booleanreassociationpass.cpp

    r4775 r4778  
    1010#include <pablo/analysis/pabloverifier.hpp>
    1111#include <algorithm>
     12#include <numeric> // std::iota
    1213#include <queue>
    1314#include <set>
Note: See TracChangeset for help on using the changeset viewer.