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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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   
Note: See TracChangeset for help on using the changeset viewer.