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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.