Ignore:
Timestamp:
Apr 10, 2017, 4:34:41 PM (2 years ago)
Author:
nmedfort
Message:

Moved toolchain and object_cache to kernels directory. Continued work on providing input consumed information.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/u8u16.cpp

    r5401 r5402  
    2323#include <pablo/pablo_toolchain.h>                 // for pablo_function_passes
    2424#include <pablo/pe_zeroes.h>
    25 #include <toolchain.h>                             // for JIT_to_ExecutionEn...
     25#include <kernels/toolchain.h>
    2626#include <boost/iostreams/device/mapped_file.hpp>  // for mapped_file_source
    2727#include <boost/filesystem.hpp>
     
    317317    DeleteByPEXTkernel delK(iBuilder, 64, 16, true);
    318318    pxDriver.addKernelCall(delK, {&U8u16Bits, &DelMask}, {&SwizzleFields0, &SwizzleFields1, &SwizzleFields2, &SwizzleFields3, &DeletionCounts});
    319 ;
     319
    320320    //  Produce fully compressed swizzled UTF-16 bit streams
    321321    SwizzledCopybackBuffer u16Swizzle0(iBuilder, iBuilder->getStreamSetTy(4), segmentSize * (bufferSegments+2), 1);
     
    506506
    507507void u8u16(u8u16FunctionType fn_ptr, const std::string & fileName) {
    508     std::string mFileName = fileName;
    509     size_t fileSize;
    510     char * fileBuffer;
    511    
    512     const boost::filesystem::path file(mFileName);
     508
     509    const boost::filesystem::path file(fileName);
    513510    if (exists(file)) {
    514511        if (is_directory(file)) {
     
    516513        }
    517514    } else {
    518         std::cerr << "Error: cannot open " << mFileName << " for processing. Skipped.\n";
     515        std::cerr << "Error: cannot open " << fileName << " for processing. Skipped.\n";
    519516        return;
    520517    }
    521518   
    522     fileSize = file_size(file);
    523     boost::iostreams::mapped_file_source mFile;
    524     if (fileSize == 0) {
    525         fileBuffer = nullptr;
    526     }
    527     else {
     519    size_t fileSize = file_size(file);
     520    boost::iostreams::mapped_file_source input;
     521
     522    char * fileBuffer = nullptr;
     523    if (fileSize) {
    528524        try {
    529             mFile.open(mFileName);
    530         } catch (std::exception &e) {
    531             std::cerr << "Error: Boost mmap of " << mFileName << ": " << e.what() << std::endl;
    532             return;
    533         }
    534         fileBuffer = const_cast<char *>(mFile.data());
     525            input.open(fileName);
     526            fileBuffer = const_cast<char *>(input.data());
     527        } catch (std::exception & e) {
     528            throw std::runtime_error("Boost mmap error: " + fileName + ": " + e.what());
     529        }       
    535530    }
    536531
     
    540535        outputBuffer.advise(boost::interprocess::mapped_region::advice_sequential);
    541536        fn_ptr(fileBuffer, static_cast<char*>(outputBuffer.get_address()), fileSize);
    542     }
    543     else if (memAlignBuffering) {
     537    } else if (memAlignBuffering) {
    544538        char * outputBuffer;
    545539        const auto r = posix_memalign(reinterpret_cast<void **>(&outputBuffer), 32, 2*fileSize);
     
    549543        fn_ptr(fileBuffer, outputBuffer, fileSize);
    550544        free(reinterpret_cast<void *>(outputBuffer));
    551     }
    552     else {
     545    } else {
    553546        /* No external output buffer */
    554547        fn_ptr(fileBuffer, nullptr, fileSize);
    555548    }
    556     mFile.close();
     549    input.close();
    557550   
    558551}
    559 
    560552
    561553int main(int argc, char *argv[]) {
     
    563555    cl::HideUnrelatedOptions(ArrayRef<const cl::OptionCategory *>{&u8u16Options, pablo::pablo_toolchain_flags(), codegen::codegen_flags()});
    564556    cl::ParseCommandLineOptions(argc, argv);
    565 
    566     u8u16FunctionType fn_ptr = u8u16CodeGen();
    567 
    568     u8u16(fn_ptr, inputFile);
    569 
     557    u8u16(u8u16CodeGen(), inputFile);
    570558    return 0;
    571559}
Note: See TracChangeset for help on using the changeset viewer.