/*
- * Copyright (c) 2015, Intel Corporation
+ * Copyright (c) 2015-2016, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
// are given to rose &co
smallWriteLargestBufferBad(35),
limitSmallWriteOutfixSize(1048576), // 1 MB
+ smallWriteMaxPatterns(10000),
+ smallWriteMaxLiterals(10000),
dumpFlags(0),
limitPatternCount(8000000), // 8M patterns
limitPatternLength(16000), // 16K bytes
G_UPDATE(smallWriteLargestBuffer);
G_UPDATE(smallWriteLargestBufferBad);
G_UPDATE(limitSmallWriteOutfixSize);
+ G_UPDATE(smallWriteMaxPatterns);
+ G_UPDATE(smallWriteMaxLiterals);
G_UPDATE(limitPatternCount);
G_UPDATE(limitPatternLength);
G_UPDATE(limitGraphVertices);
/*
- * Copyright (c) 2015, Intel Corporation
+ * Copyright (c) 2015-2016, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
u32 smallWriteLargestBuffer; // largest buffer that can be small write
u32 smallWriteLargestBufferBad;// largest buffer that can be small write
u32 limitSmallWriteOutfixSize; //!< max total size of outfix DFAs
+ u32 smallWriteMaxPatterns; // only try small writes if fewer patterns
+ u32 smallWriteMaxLiterals; // only try small writes if fewer literals
enum DumpFlags {
DUMP_NONE = 0,
/*
- * Copyright (c) 2015, Intel Corporation
+ * Copyright (c) 2015-2016, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
: get_current_target();
CompileContext cc(isStreaming, isVectored, target_info, g);
- NG ng(cc, somPrecision);
+ NG ng(cc, elements, somPrecision);
try {
for (unsigned int i = 0; i < elements; i++) {
namespace ue2 {
-NG::NG(const CompileContext &in_cc, unsigned in_somPrecision)
+NG::NG(const CompileContext &in_cc, size_t num_patterns,
+ unsigned in_somPrecision)
: maxSomRevHistoryAvailable(in_cc.grey.somMaxRevNfaLength),
minWidth(depth::infinity()),
rm(in_cc.grey),
ssm(in_somPrecision),
cc(in_cc),
rose(makeRoseBuilder(rm, ssm, cc, boundary)),
- smwr(makeSmallWriteBuilder(rm, cc)) {
+ smwr(makeSmallWriteBuilder(num_patterns, rm, cc)) {
}
NG::~NG() {
/*
- * Copyright (c) 2015, Intel Corporation
+ * Copyright (c) 2015-2016, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
class NG : boost::noncopyable {
public:
- NG(const CompileContext &in_cc, unsigned in_somPrecision);
+ NG(const CompileContext &in_cc, size_t num_patterns,
+ unsigned in_somPrecision);
~NG();
/** \brief Consumes a pattern, returns false or throws a CompileError
// Concrete impl class
class SmallWriteBuildImpl : public SmallWriteBuild {
public:
- SmallWriteBuildImpl(const ReportManager &rm, const CompileContext &cc);
+ SmallWriteBuildImpl(size_t num_patterns, const ReportManager &rm,
+ const CompileContext &cc);
// Construct a runtime implementation.
aligned_unique_ptr<SmallWriteEngine> build(u32 roseQuality) override;
SmallWriteBuild::~SmallWriteBuild() { }
-SmallWriteBuildImpl::SmallWriteBuildImpl(const ReportManager &rm_in,
+SmallWriteBuildImpl::SmallWriteBuildImpl(size_t num_patterns,
+ const ReportManager &rm_in,
const CompileContext &cc_in)
: rm(rm_in), cc(cc_in),
/* small write is block mode only */
- poisoned(!cc.grey.allowSmallWrite || cc.streaming) {
+ poisoned(!cc.grey.allowSmallWrite
+ || cc.streaming
+ || num_patterns > cc.grey.smallWriteMaxPatterns) {
}
void SmallWriteBuildImpl::add(const NGWrapper &w) {
}
cand_literals.push_back(make_pair(literal, r));
+
+ if (cand_literals.size() > cc.grey.smallWriteMaxLiterals) {
+ poisoned = true;
+ }
}
static
bool SmallWriteBuildImpl::determiniseLiterals() {
DEBUG_PRINTF("handling literals\n");
assert(!poisoned);
+ assert(cand_literals.size() <= cc.grey.smallWriteMaxLiterals);
if (cand_literals.empty()) {
return true; /* nothing to do */
}
// SmallWriteBuild factory
-unique_ptr<SmallWriteBuild> makeSmallWriteBuilder(const ReportManager &rm,
+unique_ptr<SmallWriteBuild> makeSmallWriteBuilder(size_t num_patterns,
+ const ReportManager &rm,
const CompileContext &cc) {
- return ue2::make_unique<SmallWriteBuildImpl>(rm, cc);
+ return ue2::make_unique<SmallWriteBuildImpl>(num_patterns, rm, cc);
}
aligned_unique_ptr<SmallWriteEngine>
/*
- * Copyright (c) 2015, Intel Corporation
+ * Copyright (c) 2015-2016, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
};
// Construct a usable SmallWrite builder.
-std::unique_ptr<SmallWriteBuild> makeSmallWriteBuilder(const ReportManager &rm,
+std::unique_ptr<SmallWriteBuild> makeSmallWriteBuilder(size_t num_patterns,
+ const ReportManager &rm,
const CompileContext &cc);
size_t smwrSize(const SmallWriteEngine *t);