Exemple #1
0
int main(int argc, const char** argv) {
    SHOW_LOCATION("Numerics");
#define ITERATION_COUNT 5000000L 
    try {
        oobench::GaussPerformance<float> performance(argc, argv);
        performance.test(ITERATION_COUNT, "Gauss");
    } catch (...) {
        std::cerr << "Unknown exception caught" << std::endl;
    }

    try {
        oobench::GaussPerformance<double> performance(argc, argv);
        performance.test(ITERATION_COUNT, "Gauss");
    } catch (...) {
        std::cerr << "Unknown exception caught" << std::endl;
    }

    try {
        oobench::GaussPerformance<long double> performance(argc, argv);
        performance.test(ITERATION_COUNT, "Gauss");
    } catch (...) {
        std::cerr << "Unknown exception caught" << std::endl;
    }
    return 0;
    std::exit(0);
}
static void
record_layer(const char *name,
             bool dtls,
             bool isServer,
             bool read,
             tls_protocol_version version,
             uint16_t cipher,
             tls_buffer key,
             size_t blocksize,
             struct ccrng_state *rng)
{
    struct cipher_context context;
    size_t outsize;

    context.ofilter = tls_record_create(dtls, rng);
    if (context.ofilter == NULL)
        errx(1, "tls_record_create");

    context.ifilter = tls_record_create(dtls, rng);
    if (context.ifilter == NULL)
        errx(1, "tls_record_create");


    set_key(context.ofilter, isServer, version, cipher, key);
    set_key(context.ifilter, !isServer, version, cipher, key);

    context.inblock.length = blocksize;
    context.inblock.data = malloc(blocksize);

    if (ccrng_generate(rng, context.inblock.length, context.inblock.data))
        errx(1, "ccrng_generate");

    context.outblock.length = blocksize;
    context.outblock.data = malloc(blocksize);

    outsize = tls_record_encrypted_size(context.ofilter, tls_record_type_AppData, blocksize);

    context.encblock.data = malloc(outsize);
    context.encblock.length = outsize;

    outsize = tls_record_decrypted_size(context.ifilter, context.encblock.length);

    context.outblock.data = malloc(outsize);
    context.outblock.length = outsize;

    performance("enc+dec", name, TRIM_COUNTER, blocksize, enc_dec_func, &context);
    performance("enc", name, TRIM_COUNTER, blocksize, enc_func, &context);

    free(context.inblock.data);
    free(context.encblock.data);
    free(context.outblock.data);

    tls_record_destroy(context.ofilter);
    tls_record_destroy(context.ifilter);
}
int main(int argc, const char** argv) {
    SHOW_LOCATION("IO");
    try {
        oobench::ASyncPerformanceLarge performance(argc, argv);
        performance.test(50000L, "UNIX I/O, async");
    } catch (...) {
        std::cerr << "Unknown exception caught" << std::endl;
    }
    return 0;
    std::exit(0);
}
int main(int argc, const char** argv) {
    SHOW_LOCATION("Threads");
    try {
        oobench::ThreadCreationPerformance performance(argc, argv);
        performance.test(20000L);
    } catch (...) {
        std::cerr << "Unknown exception caught" << std::endl;
    }
    return 0;
    std::exit(0);
}
Exemple #5
0
int main(int argc, const char** argv) {
    SHOW_LOCATION("Messages");
    try {
        oobench::StaticPerformance performance(argc, argv);
        performance.test(500000000L, "static");
    } catch (...) {
        std::cerr << "Unknown exception caught" << std::endl;
    }
    return 0;
    std::exit(0);
}
Exemple #6
0
int main(int argc, const char** argv) {
    SHOW_LOCATION("STL/Algorithms");
    try {
        oobench::FunctionObjectPerformance performance(argc, argv);
        performance.test(50000000L, "invoking function object");
    } catch (...) {
        std::cerr << "Unknown exception caught" << std::endl;
    }
    return 0;
    std::exit(0);
}
SolarCollectorIntegralCollectorStorage::SolarCollectorIntegralCollectorStorage(const Model& model)
  : StraightComponent(SolarCollectorIntegralCollectorStorage::iddObjectType(),model)
{
  OS_ASSERT(getImpl<detail::SolarCollectorIntegralCollectorStorage_Impl>());

  SolarCollectorPerformanceIntegralCollectorStorage performance(model);

  bool ok = true;
  ok = getImpl<detail::SolarCollectorIntegralCollectorStorage_Impl>()->setSolarCollectorPerformanceNoClone(performance);
  OS_ASSERT(ok);
}
  void SolarCollectorIntegralCollectorStorage_Impl::resetSolarCollectorPerformance()
  {
    boost::optional<SolarCollectorPerformanceIntegralCollectorStorage> oldPerformance = getObject<ModelObject>().getModelObjectTarget<SolarCollectorPerformanceIntegralCollectorStorage>(OS_SolarCollector_IntegralCollectorStorageFields::IntegralCollectorStorageParametersName);
    if (oldPerformance){
      oldPerformance->remove();
    }

    SolarCollectorPerformanceIntegralCollectorStorage performance(this->model());
    bool ok = setSolarCollectorPerformanceNoClone(performance);
    OS_ASSERT(ok);
  }
Exemple #9
0
int main(int argc, const char** argv) {
    SHOW_LOCATION("Patterns/MVC");
    try {
        oobench::MVCPerformance performance(argc, argv);
        performance.test(50000L);
    } catch (...) {
        std::cerr << "Unknown exception caught" << std::endl;
    }
    std::exit(0);
    return 0;
}
Exemple #10
0
int main(int argc, const char** argv) {
    SHOW_LOCATION("STL/Containers");
    try {
        oobench::SetPerformance<std::set<oobench::Integer>, 
                oobench::Integer> performance(argc, argv);
        performance.test(500000L, "std::set<oobench::Integer>");
    } catch (...) {
        std::cerr << "Unknown exception caught" << std::endl;
    }
    return 0;
}
Exemple #11
0
GdkPixbuf *
gth_icon_cache_get_pixbuf (GthIconCache *icon_cache,
			   GIcon        *icon)
{
	const char *key;
	GdkPixbuf  *pixbuf;

	key = NULL;
	if (icon != NULL)
		key = _gth_icon_cache_get_icon_key (icon);

	if (key == NULL)
		key = VOID_PIXBUF_KEY;

	performance (DEBUG_INFO, "get pixbuf for %s", key);

	pixbuf = g_hash_table_lookup (icon_cache->cache, key);
	if (pixbuf != NULL) {
		g_object_ref (pixbuf);
		return pixbuf;
	}

	if (icon != NULL)
		pixbuf = _g_icon_get_pixbuf (icon, icon_cache->icon_size, icon_cache->icon_theme);

	if (pixbuf == NULL) {
		GIcon *unknown_icon;

		unknown_icon = g_themed_icon_new ("missing-image");
		pixbuf = _g_icon_get_pixbuf (unknown_icon, icon_cache->icon_size, icon_cache->icon_theme);

		g_object_unref (unknown_icon);
	}

	g_hash_table_insert (icon_cache->cache, (gpointer) key, g_object_ref (pixbuf));

	performance (DEBUG_INFO, "done (not cached)");

	return pixbuf;
}
int main(int argc, char** argv) {
  DataStoreNodeTemplate tlb_stat("tlb_stat"); {
    tlb_stat.summable = 1;
    tlb_stat.addint("hits");
    tlb_stat.addint("misses");
  }
  DataStoreNodeTemplate PerContextOutOfOrderCoreStats("PerContextOutOfOrderCoreStats"); {
    DataStoreNodeTemplate& fetch = PerContextOutOfOrderCoreStats("fetch"); {
      DataStoreNodeTemplate& stop = fetch("stop"); {
        stop.summable = 1;
        stop.addint("stalled");
        stop.addint("icache_miss");
        stop.addint("fetchq_full");
        stop.addint("issueq_quota_full");
        stop.addint("bogus_rip");
        stop.addint("microcode_assist");
        stop.addint("branch_taken");
        stop.addint("full_width");
        stop.addint("icache_stalled");
        stop.addint("invalid_blocks");
      }
      fetch.histogram("opclass", 29, opclass_names);
      fetch.histogram("width", OutOfOrderModel::FETCH_WIDTH+1, 0, OutOfOrderModel::FETCH_WIDTH, 1);
      fetch.addint("blocks");
      fetch.addint("uops");
      fetch.addint("user_insns");
    }
    DataStoreNodeTemplate& frontend = PerContextOutOfOrderCoreStats("frontend"); {
      DataStoreNodeTemplate& status = frontend("status"); {
        status.summable = 1;
        status.addint("complete");
        status.addint("fetchq_empty");
        status.addint("rob_full");
        status.addint("physregs_full");
        status.addint("ldq_full");
        status.addint("stq_full");
      }
      frontend.histogram("width", OutOfOrderModel::FRONTEND_WIDTH+1, 0, OutOfOrderModel::FRONTEND_WIDTH, 1);
      DataStoreNodeTemplate& renamed = frontend("renamed"); {
        renamed.addint("none");
        renamed.addint("reg");
        renamed.addint("flags");
        renamed.addint("reg_and_flags");
      }
      DataStoreNodeTemplate& alloc = frontend("alloc"); {
        alloc.addint("reg");
        alloc.addint("ldreg");
        alloc.addint("sfr");
        alloc.addint("br");
      }
      frontend.histogram("consumer_count", 256, 0, 255, 1);
    }
    DataStoreNodeTemplate& dispatch = PerContextOutOfOrderCoreStats("dispatch"); {
      dispatch.histogram("cluster", OutOfOrderModel::MAX_CLUSTERS, OutOfOrderModel::cluster_names);
      DataStoreNodeTemplate& redispatch = dispatch("redispatch"); {
        redispatch.addint("trigger_uops");
        redispatch.addint("deadlock_flushes");
        redispatch.addint("deadlock_uops_flushed");
        redispatch.histogram("dependent_uops", OutOfOrderModel::ROB_SIZE+1, 0, OutOfOrderModel::ROB_SIZE, 1);
      }
    }
    DataStoreNodeTemplate& issue = PerContextOutOfOrderCoreStats("issue"); {
      issue.addint("uops");
      issue.addfloat("uipc");
      DataStoreNodeTemplate& result = issue("result"); {
        result.summable = 1;
        result.addint("no_fu");
        result.addint("replay");
        result.addint("misspeculated");
        result.addint("refetch");
        result.addint("branch_mispredict");
        result.addint("exception");
        result.addint("complete");
      }
      issue.histogram("opclass", 29, opclass_names);
    }
    DataStoreNodeTemplate& writeback = PerContextOutOfOrderCoreStats("writeback"); {
      writeback.histogram("writebacks", OutOfOrderModel::PHYS_REG_FILE_COUNT, OutOfOrderModel::phys_reg_file_names);
    }
    DataStoreNodeTemplate& commit = PerContextOutOfOrderCoreStats("commit"); {
      commit.addint("uops");
      commit.addint("insns");
      commit.addfloat("uipc");
      commit.addfloat("ipc");
      DataStoreNodeTemplate& result = commit("result"); {
        result.summable = 1;
        result.addint("none");
        result.addint("ok");
        result.addint("exception");
        result.addint("skipblock");
        result.addint("barrier");
        result.addint("smc");
        result.addint("memlocked");
        result.addint("stop");
        result.addint("dcache_stall");
      }
      DataStoreNodeTemplate& fail = commit("fail"); {
        fail.summable = 1;
        fail.addint("free_list");
        fail.addint("frontend_list");
        fail.addint("ready_to_dispatch_list");
        fail.addint("dispatched_list");
        fail.addint("ready_to_issue_list");
        fail.addint("ready_to_store_list");
        fail.addint("ready_to_load_list");
        fail.addint("issued_list");
        fail.addint("completed_list");
        fail.addint("ready_to_writeback_list");
        fail.addint("cache_miss_list");
        fail.addint("tlb_miss_list");
        fail.addint("memory_fence_list");
        fail.addint("ready_to_commit_queue");
      }
      DataStoreNodeTemplate& setflags = commit("setflags"); {
        setflags.summable = 1;
        setflags.addint("yes");
        setflags.addint("no");
      }
      commit.histogram("opclass", 29, opclass_names);
    }
    DataStoreNodeTemplate& branchpred = PerContextOutOfOrderCoreStats("branchpred"); {
      branchpred.addint("predictions");
      branchpred.addint("updates");
      branchpred.histogram("cond", 2, branchpred_outcome_names);
      branchpred.histogram("indir", 2, branchpred_outcome_names);
      branchpred.histogram("ret", 2, branchpred_outcome_names);
      branchpred.histogram("summary", 2, branchpred_outcome_names);
      DataStoreNodeTemplate& ras = branchpred("ras"); {
        ras.summable = 1;
        ras.addint("pushes");
        ras.addint("overflows");
        ras.addint("pops");
        ras.addint("underflows");
        ras.addint("annuls");
      }
    }
    DataStoreNodeTemplate& dcache = PerContextOutOfOrderCoreStats("dcache"); {
      DataStoreNodeTemplate& load = dcache("load"); {
        DataStoreNodeTemplate& issue = load("issue"); {
          issue.summable = 1;
          issue.addint("complete");
          issue.addint("miss");
          issue.addint("exception");
          issue.addint("ordering");
          issue.addint("unaligned");
          DataStoreNodeTemplate& replay = issue("replay"); {
            replay.summable = 1;
            replay.addint("sfr_addr_and_data_not_ready");
            replay.addint("sfr_addr_not_ready");
            replay.addint("sfr_data_not_ready");
            replay.addint("missbuf_full");
            replay.addint("interlocked");
            replay.addint("interlock_overflow");
            replay.addint("fence");
            replay.addint("bank_conflict");
            replay.addint("dcache_stall");
          }
        }
        DataStoreNodeTemplate& forward = load("forward"); {
          forward.summable = 1;
          forward.addint("cache");
          forward.addint("sfr");
          forward.addint("sfr_and_cache");
        }
        DataStoreNodeTemplate& dependency = load("dependency"); {
          dependency.summable = 1;
          dependency.addint("independent");
          dependency.addint("predicted_alias_unresolved");
          dependency.addint("stq_address_match");
          dependency.addint("stq_address_not_ready");
          dependency.addint("fence");
          dependency.addint("mmio");
        }
        DataStoreNodeTemplate& type = load("type"); {
          type.summable = 1;
          type.addint("aligned");
          type.addint("unaligned");
          type.addint("internal");
        }
        load.histogram("size", 4, sizeshift_names);
        load.histogram("datatype", DATATYPE_COUNT, datatype_names);
      }
      DataStoreNodeTemplate& store = dcache("store"); {
        DataStoreNodeTemplate& issue = store("issue"); {
          issue.summable = 1;
          issue.addint("complete");
          issue.addint("exception");
          issue.addint("ordering");
          issue.addint("unaligned");
          DataStoreNodeTemplate& replay = issue("replay"); {
            replay.summable = 1;
            replay.addint("sfr_addr_and_data_not_ready");
            replay.addint("sfr_addr_not_ready");
            replay.addint("sfr_data_not_ready");
            replay.addint("sfr_addr_and_data_and_data_to_store_not_ready");
            replay.addint("sfr_addr_and_data_to_store_not_ready");
            replay.addint("sfr_data_and_data_to_store_not_ready");
            replay.addint("interlocked");
            replay.addint("fence");
            replay.addint("parallel_aliasing");
            replay.addint("bank_conflict");
          }
        }
        DataStoreNodeTemplate& forward = store("forward"); {
          forward.summable = 1;
          forward.addint("zero");
          forward.addint("sfr");
        }
        DataStoreNodeTemplate& type = store("type"); {
          type.summable = 1;
          type.addint("aligned");
          type.addint("unaligned");
          type.addint("internal");
        }
        store.histogram("size", 4, sizeshift_names);
        store.histogram("datatype", DATATYPE_COUNT, datatype_names);
      }
      DataStoreNodeTemplate& fence = dcache("fence"); {
        fence.summable = 1;
        fence.addint("lfence");
        fence.addint("sfence");
        fence.addint("mfence");
      }
      dcache.add("dtlb", tlb_stat);
      dcache.add("itlb", tlb_stat);
      dcache.histogram("dtlb_latency", 1001, 0, 200, 1);
      dcache.histogram("itlb_latency", 1001, 0, 200, 1);
    }
    PerContextOutOfOrderCoreStats.addint("interrupt_requests");
    PerContextOutOfOrderCoreStats.addint("cpu_exit_requests");
    PerContextOutOfOrderCoreStats.addint("cycles_in_pause");
  }
  DataStoreNodeTemplate OutOfOrderCoreStats("OutOfOrderCoreStats"); {
    OutOfOrderCoreStats.addint("cycles");
    DataStoreNodeTemplate& dispatch = OutOfOrderCoreStats("dispatch"); {
      DataStoreNodeTemplate& source = dispatch("source"); {
        source.summable = 1;
        source.histogram("integer", OutOfOrderModel::MAX_PHYSREG_STATE, OutOfOrderModel::physreg_state_names);
        source.histogram("fp", OutOfOrderModel::MAX_PHYSREG_STATE, OutOfOrderModel::physreg_state_names);
        source.histogram("st", OutOfOrderModel::MAX_PHYSREG_STATE, OutOfOrderModel::physreg_state_names);
        source.histogram("br", OutOfOrderModel::MAX_PHYSREG_STATE, OutOfOrderModel::physreg_state_names);
      }
      dispatch.histogram("width", OutOfOrderModel::DISPATCH_WIDTH+1, 0, OutOfOrderModel::DISPATCH_WIDTH, 1);
    }
    DataStoreNodeTemplate& issue = OutOfOrderCoreStats("issue"); {
      DataStoreNodeTemplate& source = issue("source"); {
        source.summable = 1;
        source.histogram("integer", OutOfOrderModel::MAX_PHYSREG_STATE, OutOfOrderModel::physreg_state_names);
        source.histogram("fp", OutOfOrderModel::MAX_PHYSREG_STATE, OutOfOrderModel::physreg_state_names);
        source.histogram("st", OutOfOrderModel::MAX_PHYSREG_STATE, OutOfOrderModel::physreg_state_names);
        source.histogram("br", OutOfOrderModel::MAX_PHYSREG_STATE, OutOfOrderModel::physreg_state_names);
      }
      DataStoreNodeTemplate& width = issue("width"); {
        width.histogram("all", OutOfOrderModel::MAX_ISSUE_WIDTH+1, 0, OutOfOrderModel::MAX_ISSUE_WIDTH, 1);
      }
    }
    DataStoreNodeTemplate& writeback = OutOfOrderCoreStats("writeback"); {
      DataStoreNodeTemplate& width = writeback("width"); {
        width.histogram("all", OutOfOrderModel::MAX_ISSUE_WIDTH+1, 0, OutOfOrderModel::MAX_ISSUE_WIDTH, 1);
      }
    }
    DataStoreNodeTemplate& commit = OutOfOrderCoreStats("commit"); {
      DataStoreNodeTemplate& freereg = commit("freereg"); {
        freereg.summable = 1;
        freereg.addint("pending");
        freereg.addint("free");
      }
      commit.addint("free_regs_recycled");
      commit.histogram("width", OutOfOrderModel::COMMIT_WIDTH+1, 0, OutOfOrderModel::COMMIT_WIDTH, 1);
    }
    DataStoreNodeTemplate& branchpred = OutOfOrderCoreStats("branchpred"); {
      branchpred.addint("predictions");
      branchpred.addint("updates");
      branchpred.histogram("cond", 2, branchpred_outcome_names);
      branchpred.histogram("indir", 2, branchpred_outcome_names);
      branchpred.histogram("ret", 2, branchpred_outcome_names);
      branchpred.histogram("summary", 2, branchpred_outcome_names);
      DataStoreNodeTemplate& ras = branchpred("ras"); {
        ras.summable = 1;
        ras.addint("pushes");
        ras.addint("overflows");
        ras.addint("pops");
        ras.addint("underflows");
        ras.addint("annuls");
      }
    }
    OutOfOrderCoreStats.add("total", PerContextOutOfOrderCoreStats);
    OutOfOrderCoreStats.add("vcpu0", PerContextOutOfOrderCoreStats);
    OutOfOrderCoreStats.add("vcpu1", PerContextOutOfOrderCoreStats);
    OutOfOrderCoreStats.add("vcpu2", PerContextOutOfOrderCoreStats);
    OutOfOrderCoreStats.add("vcpu3", PerContextOutOfOrderCoreStats);
    DataStoreNodeTemplate& simulator = OutOfOrderCoreStats("simulator"); {
      simulator.addfloat("total_time");
      DataStoreNodeTemplate& cputime = simulator("cputime"); {
        cputime.summable = 1;
        cputime.addfloat("fetch");
        cputime.addfloat("decode");
        cputime.addfloat("rename");
        cputime.addfloat("frontend");
        cputime.addfloat("dispatch");
        cputime.addfloat("issue");
        cputime.addfloat("issueload");
        cputime.addfloat("issuestore");
        cputime.addfloat("complete");
        cputime.addfloat("transfer");
        cputime.addfloat("writeback");
        cputime.addfloat("commit");
      }
    }
  }
  DataStoreNodeTemplate PerContextDataCacheStats("PerContextDataCacheStats"); {
    DataStoreNodeTemplate& load = PerContextDataCacheStats("load"); {
      DataStoreNodeTemplate& hit = load("hit"); {
        hit.summable = 1;
        hit.addint("L1");
        hit.addint("L2");
        hit.addint("L3");
        hit.addint("mem");
      }
      DataStoreNodeTemplate& dtlb = load("dtlb"); {
        dtlb.summable = 1;
        dtlb.addint("hits");
        dtlb.addint("misses");
      }
      DataStoreNodeTemplate& tlbwalk = load("tlbwalk"); {
        tlbwalk.summable = 1;
        tlbwalk.addint("L1_dcache_hit");
        tlbwalk.addint("L1_dcache_miss");
        tlbwalk.addint("no_lfrq_mb");
      }
    }
    DataStoreNodeTemplate& fetch = PerContextDataCacheStats("fetch"); {
      DataStoreNodeTemplate& hit = fetch("hit"); {
        hit.summable = 1;
        hit.addint("L1");
        hit.addint("L2");
        hit.addint("L3");
        hit.addint("mem");
      }
      DataStoreNodeTemplate& itlb = fetch("itlb"); {
        itlb.summable = 1;
        itlb.addint("hits");
        itlb.addint("misses");
      }
      DataStoreNodeTemplate& tlbwalk = fetch("tlbwalk"); {
        tlbwalk.summable = 1;
        tlbwalk.addint("L1_dcache_hit");
        tlbwalk.addint("L1_dcache_miss");
        tlbwalk.addint("no_lfrq_mb");
      }
    }
    DataStoreNodeTemplate& store = PerContextDataCacheStats("store"); {
      store.addint("prefetches");
    }
  }
  DataStoreNodeTemplate DataCacheStats("DataCacheStats"); {
    DataStoreNodeTemplate& load = DataCacheStats("load"); {
      DataStoreNodeTemplate& transfer = load("transfer"); {
        transfer.summable = 1;
        transfer.addint("L2_to_L1_full");
        transfer.addint("L2_to_L1_partial");
        transfer.addint("L2_L1I_full");
      }
    }
    DataStoreNodeTemplate& missbuf = DataCacheStats("missbuf"); {
      missbuf.addint("inserts");
      DataStoreNodeTemplate& deliver = missbuf("deliver"); {
        deliver.summable = 1;
        deliver.addint("mem_to_L3");
        deliver.addint("L3_to_L2");
        deliver.addint("L2_to_L1D");
        deliver.addint("L2_to_L1I");
      }
    }
    DataStoreNodeTemplate& prefetch = DataCacheStats("prefetch"); {
      prefetch.summable = 1;
      prefetch.addint("in_L1");
      prefetch.addint("in_L2");
      prefetch.addint("required");
    }
    DataStoreNodeTemplate& lfrq = DataCacheStats("lfrq"); {
      lfrq.addint("inserts");
      lfrq.addint("wakeups");
      lfrq.addint("annuls");
      lfrq.addint("resets");
      lfrq.addint("total_latency");
      lfrq.addfloat("average_latency");
      lfrq.histogram("width", CacheSubsystem::MAX_WAKEUPS_PER_CYCLE+1, 0, CacheSubsystem::MAX_WAKEUPS_PER_CYCLE+1, 1);
    }
    DataCacheStats.add("total", PerContextDataCacheStats);
    DataCacheStats.add("vcpu0", PerContextDataCacheStats);
    DataCacheStats.add("vcpu1", PerContextDataCacheStats);
    DataCacheStats.add("vcpu2", PerContextDataCacheStats);
    DataCacheStats.add("vcpu3", PerContextDataCacheStats);
  }
  DataStoreNodeTemplate stall_sub("stall_sub"); {
    stall_sub.summable = 1;
    stall_sub.addint("dependency");
    stall_sub.addint("cache_port");
    stall_sub.addint("buffer_full");
  }
  DataStoreNodeTemplate CacheStats("CacheStats"); {
    DataStoreNodeTemplate& cpurequest = CacheStats("cpurequest"); {
      DataStoreNodeTemplate& count = cpurequest("count"); {
        count.summable = 1;
        DataStoreNodeTemplate& hit = count("hit"); {
          DataStoreNodeTemplate& read = hit("read"); {
            read.summable = 1;
            DataStoreNodeTemplate& hit = read("hit"); {
              hit.summable = 1;
              hit.addint("hit");
              hit.addint("forward");
            }
          }
          DataStoreNodeTemplate& write = hit("write"); {
            write.summable = 1;
            DataStoreNodeTemplate& hit = write("hit"); {
              hit.summable = 1;
              hit.addint("hit");
              hit.addint("forward");
            }
          }
        }
        DataStoreNodeTemplate& miss = count("miss"); {
          miss.summable = 1;
          miss.addint("read");
          miss.addint("write");
        }
      }
      DataStoreNodeTemplate& stall = cpurequest("stall"); {
        stall.summable = 1;
        stall.add("read", stall_sub);
        stall.add("write", stall_sub);
      }
      cpurequest.addint("redirects");
    }
    DataStoreNodeTemplate& snooprequest = CacheStats("snooprequest"); {
      snooprequest.summable = 1;
      snooprequest.addint("hit");
      snooprequest.addint("miss");
    }
    CacheStats.addint("annul");
    CacheStats.addint("queueFull");
    DataStoreNodeTemplate& latency = CacheStats("latency"); {
      latency.summable = 1;
      latency.addint("IF");
      latency.addint("load");
      latency.addint("store");
    }
    DataStoreNodeTemplate& lat_count = CacheStats("lat_count"); {
      lat_count.summable = 1;
      lat_count.addint("IF");
      lat_count.addint("load");
      lat_count.addint("store");
    }
    DataStoreNodeTemplate& mesi_stats = CacheStats("mesi_stats"); {
      DataStoreNodeTemplate& hit_state = mesi_stats("hit_state"); {
        hit_state.summable = 1;
        hit_state.histogram("snoop", 5, 0, 4, 1);
        hit_state.histogram("cpu", 5, 0, 4, 1);
      }
      mesi_stats.histogram("state_transition", 17, 0, 16, 1);
    }
  }
  DataStoreNodeTemplate PerCoreCacheStats("PerCoreCacheStats"); {
    PerCoreCacheStats.add("CPUController", CacheStats);
    PerCoreCacheStats.add("L1I", CacheStats);
    PerCoreCacheStats.add("L1D", CacheStats);
    PerCoreCacheStats.add("L2", CacheStats);
    PerCoreCacheStats.add("L3", CacheStats);
  }
  DataStoreNodeTemplate BusStats("BusStats"); {
    DataStoreNodeTemplate& broadcasts = BusStats("broadcasts"); {
      broadcasts.summable = 1;
      broadcasts.addint("read");
      broadcasts.addint("write");
      broadcasts.addint("update");
    }
    DataStoreNodeTemplate& broadcast_cycles = BusStats("broadcast_cycles"); {
      broadcast_cycles.summable = 1;
      broadcast_cycles.addint("read");
      broadcast_cycles.addint("write");
      broadcast_cycles.addint("update");
    }
    BusStats.addint("addr_bus_cycles");
    BusStats.addint("data_bus_cycles");
  }
  DataStoreNodeTemplate EventsInMode("EventsInMode"); {
    EventsInMode.summable = 1;
    EventsInMode.addint("user64");
    EventsInMode.addint("user32");
    EventsInMode.addint("kernel64");
    EventsInMode.addint("kernel32");
    EventsInMode.addint("legacy16");
    EventsInMode.addint("userlib");
    EventsInMode.addint("microcode");
    EventsInMode.addint("idle");
  }
  DataStoreNodeTemplate PerCoreEvents("PerCoreEvents"); {
    PerCoreEvents.add("cycles_in_mode", EventsInMode);
    PerCoreEvents.add("insns_in_mode", EventsInMode);
    PerCoreEvents.add("uops_in_mode", EventsInMode);
  }
  DataStoreNodeTemplate PTLsimStats("PTLsimStats"); {
    PTLsimStats.addint("snapshot_uuid");
    PTLsimStats.addstring("snapshot_name", 64);
    DataStoreNodeTemplate& summary = PTLsimStats("summary"); {
      summary.addint("cycles");
      summary.addint("insns");
      summary.addint("uops");
      summary.addint("basicblocks");
    }
    DataStoreNodeTemplate& simulator = PTLsimStats("simulator"); {
      DataStoreNodeTemplate& version = simulator("version"); {
        version.addstring("build_timestamp", 32);
        version.addint("svn_revision");
        version.addstring("svn_timestamp", 32);
        version.addstring("build_hostname", 64);
        version.addstring("build_compiler", 16);
      }
      DataStoreNodeTemplate& run = simulator("run"); {
        run.addint("timestamp");
        run.addstring("hostname", 64);
        run.addstring("kernel_version", 32);
        run.addstring("hypervisor_version", 32);
        run.addint("native_cpuid");
        run.addint("native_hz");
      }
      DataStoreNodeTemplate& config = simulator("config"); {
        config.addstring("config", 256);
      }
      DataStoreNodeTemplate& performance = simulator("performance"); {
        DataStoreNodeTemplate& rate = performance("rate"); {
          rate.addfloat("cycles_per_sec");
          rate.addfloat("issues_per_sec");
          rate.addfloat("user_commits_per_sec");
        }
      }
    }
    DataStoreNodeTemplate& decoder = PTLsimStats("decoder"); {
      DataStoreNodeTemplate& throughput = decoder("throughput"); {
        throughput.addint("basic_blocks");
        throughput.addint("x86_insns");
        throughput.addint("uops");
        throughput.addint("bytes");
      }
      decoder.histogram("x86_decode_type", DECODE_TYPE_COUNT, decode_type_names);
      DataStoreNodeTemplate& bb_decode_type = decoder("bb_decode_type"); {
        bb_decode_type.summable = 1;
        bb_decode_type.addint("all_insns_fast");
        bb_decode_type.addint("some_complex_insns");
      }
      DataStoreNodeTemplate& page_crossings = decoder("page_crossings"); {
        page_crossings.summable = 1;
        page_crossings.addint("within_page");
        page_crossings.addint("crosses_page");
      }
      DataStoreNodeTemplate& bbcache = decoder("bbcache"); {
        bbcache.addint("count");
        bbcache.addint("inserts");
        bbcache.histogram("invalidates", INVALIDATE_REASON_COUNT, invalidate_reason_names);
      }
      DataStoreNodeTemplate& pagecache = decoder("pagecache"); {
        pagecache.addint("count");
        pagecache.addint("inserts");
        pagecache.histogram("invalidates", INVALIDATE_REASON_COUNT, invalidate_reason_names);
      }
      decoder.addint("reclaim_rounds");
    }
    PTLsimStats.add("ooocore_total", OutOfOrderCoreStats);
    PTLsimStats.add("ooocore_context_total", PerContextOutOfOrderCoreStats);
    PTLsimStats.addint("elapse_seconds");
    DataStoreNodeTemplate& ooocore = PTLsimStats("ooocore"); {
      ooocore.add("total", OutOfOrderCoreStats);
      ooocore.add("c0", OutOfOrderCoreStats);
      ooocore.add("c1", OutOfOrderCoreStats);
      ooocore.add("c2", OutOfOrderCoreStats);
      ooocore.add("c3", OutOfOrderCoreStats);
      ooocore.add("c4", OutOfOrderCoreStats);
      ooocore.add("c5", OutOfOrderCoreStats);
      ooocore.add("c6", OutOfOrderCoreStats);
      ooocore.add("c7", OutOfOrderCoreStats);
    }
    DataStoreNodeTemplate& dcache = PTLsimStats("dcache"); {
      dcache.add("total", DataCacheStats);
      dcache.add("c0", DataCacheStats);
      dcache.add("c1", DataCacheStats);
      dcache.add("c2", DataCacheStats);
      dcache.add("c3", DataCacheStats);
      dcache.add("c4", DataCacheStats);
      dcache.add("c5", DataCacheStats);
      dcache.add("c6", DataCacheStats);
      dcache.add("c7", DataCacheStats);
    }
    DataStoreNodeTemplate& external = PTLsimStats("external"); {
      external.histogram("assists", ASSIST_COUNT, assist_names);
      external.histogram("l_assists", L_ASSIST_COUNT, light_assist_names);
      external.histogram("traps", 256, x86_exception_names);
      external.add("total", PerCoreEvents);
      external.add("c0", PerCoreEvents);
      external.add("c1", PerCoreEvents);
      external.add("c2", PerCoreEvents);
      external.add("c3", PerCoreEvents);
      external.add("c4", PerCoreEvents);
      external.add("c5", PerCoreEvents);
      external.add("c6", PerCoreEvents);
      external.add("c7", PerCoreEvents);
    }
    DataStoreNodeTemplate& memory = PTLsimStats("memory"); {
      memory.add("total", PerCoreCacheStats);
      memory.add("c0", PerCoreCacheStats);
      memory.add("c1", PerCoreCacheStats);
      memory.add("c2", PerCoreCacheStats);
      memory.add("c3", PerCoreCacheStats);
      memory.add("c4", PerCoreCacheStats);
      memory.add("c5", PerCoreCacheStats);
      memory.add("c6", PerCoreCacheStats);
      memory.add("c7", PerCoreCacheStats);
      memory.add("bus", BusStats);
      memory.histogram("dcache_latency", 200, 0, 199, 1);
      memory.histogram("icache_latency", 200, 0, 199, 1);
    }
  }
  ofstream os(argv[1], std::ios::binary |std::ios::out);
  PTLsimStats.write(os);
  os.close();
}
Exemple #13
0
// The main method used by the command line test routine.
int main(int argc, char* argv[]) {
	fiftyoneDegreesDataSet dataSet;
	fiftyoneDegreesResultsetCache *cache;
	fiftyoneDegreesWorksetPool *pool;

	char *dataSetFileName = argc > 1 ? argv[1] : "../../../data/51Degrees-LiteV3.2.dat";
	char *inputFileName = argc > 2 ? argv[2] : "../../../data/20000 User Agents.csv";
    char *requiredProperties = argc > 3 ? argv[3] : NULL;
    int cacheSize = argc > 4 ? atoi(argv[4]) : 5000;

	printf("\n");
	printf("\t#############################################################\n");
    printf("\t#                                                           #\n");
    printf("\t#  This program can be used to test the performance of the  #\n");
    printf("\t#                51Degrees 'Pattern' C API.                 #\n");
    printf("\t#                                                           #\n");
    printf("\t#   The test will read a list of User Agents and calculate  #\n");
    printf("\t#            the number of detections per second.           #\n");
    printf("\t#                                                           #\n");
	printf("\t#  Command line arguments should be a csv file containing   #\n");
    printf("\t#  a list of user agents. A test file of 1 million can be   #\n");
	printf("\t#    downloaded from http://51degrees.com/million.zip       #\n");
	printf("\t#                                                           #\n");
    printf("\t#############################################################\n");

    if (dataSetFileName == NULL || inputFileName == NULL)
    {
        printf("Not enough arguments supplied. Expecting path/to/51Degrees.dat path/to/test_file.csv \n");
        return 0;
    }

    switch(fiftyoneDegreesInitWithPropertyString(dataSetFileName, &dataSet, requiredProperties)) {
        case DATA_SET_INIT_STATUS_INSUFFICIENT_MEMORY:
            printf("Insufficient memory to load '%s'.", argv[1]);
            break;
		case DATA_SET_INIT_STATUS_POINTER_OUT_OF_BOUNDS:
        case DATA_SET_INIT_STATUS_CORRUPT_DATA:
            printf("Device data file '%s' is corrupted.", argv[1]);
            break;
        case DATA_SET_INIT_STATUS_INCORRECT_VERSION:
            printf("Device data file '%s' is not correct version.", argv[1]);
            break;
        case DATA_SET_INIT_STATUS_FILE_NOT_FOUND:
            printf("Device data file '%s' not found.", argv[1]);
            break;
        case DATA_SET_INIT_STATUS_NOT_SET:
            printf("Device data file '%s' could not be used to initialise.", argv[1]);
            break;
		case DATA_SET_INIT_STATUS_NULL_POINTER:
			printf("Null pointer prevented loading of '%s'.", argv[1]);
		default: {
			cache = fiftyoneDegreesResultsetCacheCreate(&dataSet, cacheSize);
            pool = fiftyoneDegreesWorksetPoolCreate(&dataSet, cache, THREAD_COUNT);
            if (pool != NULL) {
                printf("\n\nUseragents file is: %s\n", findFileNames(inputFileName));
                if (pool->cache != NULL) {
                    printf("Cache Size is: %d\n\n", pool->cache->total);
                } else {
                    printf("No Cache\n\n");
                }
                performance(inputFileName, pool);
                fiftyoneDegreesWorksetPoolFree(pool);
            }
			if (cache != NULL) {
				fiftyoneDegreesResultsetCacheFree(cache);
			}
            fiftyoneDegreesDataSetFree(&dataSet);
        }
        break;
    }
	return 0;
}
IncrementalOrder::IncrementalOrderResults* IncrementalOrder::perform_order_selection(void)
{
    IncrementalOrderResults* results = new IncrementalOrderResults();

    NeuralNetwork* neural_network_pointer = training_strategy_pointer->get_performance_functional_pointer()->get_neural_network_pointer();
    MultilayerPerceptron* multilayer_perceptron_pointer = neural_network_pointer->get_multilayer_perceptron_pointer();

    const size_t inputs_number = multilayer_perceptron_pointer->get_inputs_number();
    const size_t outputs_number = multilayer_perceptron_pointer->get_outputs_number();

    Vector<double> performance(2);
    double prev_generalization_performance = 1.0e99;

    size_t optimal_order;
    Vector<double> optimum_parameters;
    double optimum_generalization_performance;

    Vector<double> parameters_history_row;
    double current_training_performance, current_generalization_performance;

    size_t order = minimum_order;
    size_t iterations = 0;
    size_t selection_failures = 0;

    bool end = false;

    time_t beginning_time, current_time;
    double elapsed_time;

    if (display)
        std::cout << "Performing Incremental order selection..." << std::endl;

    time(&beginning_time);

    while (!end)
    {
        performance = calculate_performances(order);
        current_training_performance = performance[0];
        current_generalization_performance = performance[1];

        time(&current_time);
        elapsed_time = difftime(current_time, beginning_time);

        results->order_data.push_back(order);

        if (reserve_performance_data)
        {
            results->performance_data.push_back(current_training_performance);
        }

        if (reserve_generalization_performance_data)
        {
            results->generalization_performance_data.push_back(current_generalization_performance);
        }

        if (reserve_parameters_data)
        {
            parameters_history_row = get_parameters_order(order);
            results->parameters_data.push_back(parameters_history_row);
        }

        if (iterations == 0
        || (optimum_generalization_performance > current_generalization_performance
        && fabs(optimum_generalization_performance - current_generalization_performance) > tolerance))
        {
            optimal_order = order;
            optimum_generalization_performance = current_generalization_performance;
            optimum_parameters = get_parameters_order(optimal_order);
        }else if (prev_generalization_performance < current_generalization_performance)
            selection_failures++;

        prev_generalization_performance = current_generalization_performance;
        iterations++;

        // Stopping criteria

        if (elapsed_time > maximum_time)
        {
            end = true;
            if (display)
                std::cout << "Maximum time reached." << std::endl;
            results->stopping_condition = IncrementalOrder::MaximumTime;
        }else if (performance[1] < selection_performance_goal)
        {
            end = true;
            if (display)
                std::cout << "Generalization performance reached." << std::endl;
            results->stopping_condition = IncrementalOrder::SelectionPerformanceGoal;
        }else if (iterations > maximum_iterations_number)
        {
            end = true;
            if (display)
                std::cout << "Maximum number of iterations reached." << std::endl;
            results->stopping_condition = IncrementalOrder::MaximumIterations;
        }else if (selection_failures >= maximum_selection_failures)
        {
            end = true;
            if (display)
                std::cout << "Maximum generalization performance failures("<<selection_failures<<") reached." << std::endl;
            results->stopping_condition = IncrementalOrder::MaximumSelectionFailures;
        }else if (order == maximum_order)
        {
            end = true;
            if (display)
                std::cout << "Algorithm finished" << std::endl;
            results->stopping_condition = IncrementalOrder::AlgorithmFinished;
        }

        if (display)
        {
            std::cout << "Iteration : " << iterations << std::endl;
            std::cout << "Hidden Perceptron Number : " << order << std::endl;
            std::cout << "Final Training Performance : " << performance[0] << std::endl;
            std::cout << "Final Generalization Performance : " << performance[1] << std::endl;
            std::cout << "Elapsed time : " << elapsed_time << std::endl;
        }

        if (!end)
            order = std::min(maximum_order, order+step);
    }

    if (display)
        std::cout << "Optimal order : " << optimal_order << std:: endl;

    multilayer_perceptron_pointer->set(inputs_number, optimal_order, outputs_number);
    multilayer_perceptron_pointer->set_parameters(optimum_parameters);

    if (reserve_minimal_parameters)
        results->minimal_parameters = optimum_parameters;

    results->optimal_order = optimal_order;
    results->final_generalization_performance = optimum_generalization_performance;
    results->final_performance = calculate_performances(optimal_order)[0];
    results->iterations_number = iterations;
    results->elapsed_time = elapsed_time;

    return(results);
}
int main(int argc, const char* argv[])
{
    // Print OpenCV build info:
    std::cout << cv::getBuildInformation() << std::endl;

    std::vector<FeatureAlgorithm>              algorithms;
    std::vector<cv::Ptr<ImageTransformation> > transformations;

    bool useCrossCheck = true;

    // Initialize list of algorithm tuples:
    algorithms.push_back(FeatureAlgorithm("BRISK/BRISK/BF",
        new cv::BriskFeatureDetector(60,4),
        new cv::BriskDescriptorExtractor(),
        new cv::BFMatcher(cv::NORM_HAMMING, useCrossCheck)));

    algorithms.push_back(FeatureAlgorithm("ORB/ORB/BF",
        new cv::ORB(),
        new cv::ORB(),
        new cv::BFMatcher(cv::NORM_HAMMING, useCrossCheck)));

    algorithms.push_back(FeatureAlgorithm("SURF/BRISK/BF",
        new cv::SurfFeatureDetector(),
        new cv::BriskDescriptorExtractor(),
        new cv::BFMatcher(cv::NORM_HAMMING, useCrossCheck)));

    algorithms.push_back(FeatureAlgorithm("SURF/FREAK/BF",
        new cv::SurfFeatureDetector(),
        new cv::FREAK(),
        new cv::BFMatcher(cv::NORM_HAMMING, useCrossCheck)));

    algorithms.push_back(FeatureAlgorithm("ORB3/ORB3/BF",
        new cv::ORB(500, 1.2f, 8,31, 0, 3),
        new cv::ORB(500, 1.2f, 8,31, 0, 3),
        new cv::BFMatcher(cv::NORM_HAMMING2, useCrossCheck)));

    algorithms.push_back(FeatureAlgorithm("ORB4/ORB4/BF",
        new cv::ORB(500, 1.2f, 8, 31, 0, 4),
        new cv::ORB(500, 1.2f, 8, 31, 0, 4),
        new cv::BFMatcher(cv::NORM_HAMMING2, useCrossCheck)));

    algorithms.push_back(FeatureAlgorithm("FAST/BRIEF/BF",
        new cv::FastFeatureDetector(50),
        new cv::BriefDescriptorExtractor(),
        new cv::BFMatcher(cv::NORM_HAMMING, useCrossCheck)));

    algorithms.push_back(FeatureAlgorithm("ORB/FREAK/BF",
        new cv::OrbFeatureDetector(),
        new cv::FREAK(),
        new cv::BFMatcher(cv::NORM_HAMMING, useCrossCheck)));

    algorithms.push_back(FeatureAlgorithm("SURF/SURF/BF",
        new cv::SurfFeatureDetector(),
        new cv::SurfDescriptorExtractor(),
        new cv::BFMatcher(cv::NORM_L2, useCrossCheck)));

    algorithms.push_back(FeatureAlgorithm("SURF/SURF/FLANN",
        new cv::SurfFeatureDetector(),
        new cv::SurfDescriptorExtractor(),
        new cv::FlannBasedMatcher()));

    /**/

    // Initialize list of used transformations:
    if (USE_VERBOSE_TRANSFORMATIONS)
    {
        transformations.push_back(new GaussianBlurTransform(9));
        transformations.push_back(new BrightnessImageTransform(-127, +127,1));
        transformations.push_back(new ImageRotationTransformation(0, 360, 1, cv::Point2f(0.5f,0.5f)));
        transformations.push_back(new ImageScalingTransformation(0.25f, 2.0f, 0.01f));
    }
    else
    {
        transformations.push_back(new GaussianBlurTransform(9));
        transformations.push_back(new BrightnessImageTransform(-127, +127, 10));
        transformations.push_back(new ImageRotationTransformation(0, 360, 10, cv::Point2f(0.5f,0.5f)));
        transformations.push_back(new ImageScalingTransformation(0.25f, 2.0f, 0.1f));
    }

    if (argc < 2)
    {
        std::cout << "At least one input image should be passed" << std::endl;
    }

    for (int imageIndex = 1; imageIndex < argc; imageIndex++)
    {
        std::string testImagePath(argv[imageIndex]);
        cv::Mat testImage = cv::imread(testImagePath);

        CollectedStatistics fullStat;

        if (testImage.empty())
        {
            std::cout << "Cannot read image from " << testImagePath << std::endl;
        }

        for (size_t algIndex = 0; algIndex < algorithms.size(); algIndex++)
        {
            const FeatureAlgorithm& alg   = algorithms[algIndex];

            std::cout << "Testing " << alg.name << "...";

            for (size_t transformIndex = 0; transformIndex < transformations.size(); transformIndex++)
            {
                const ImageTransformation& trans = *transformations[transformIndex].obj;

                performEstimation(alg, trans, testImage.clone(), fullStat.getStatistics(alg.name, trans.name));
            }

            std::cout << "done." << std::endl;
        }

        std::ofstream performance("Performance.csv");
        fullStat.printPerformanceStatistics(performance);
        std::ofstream matchingRatio("MatchingRatio.csv");
        fullStat.printStatistics(matchingRatio,StatisticsElementMatchingRatio);
        std::ofstream percentOfMatches("PercentOfMatches.csv");
        fullStat.printStatistics(percentOfMatches,StatisticsElementPercentOfMatches);
        std::ofstream percentOfCorrectMatches("PercentOfCorrectMatches.csv");
        fullStat.printStatistics(percentOfCorrectMatches,StatisticsElementPercentOfCorrectMatches);
        std::ofstream meanDistance("MeanDistance.csv");
        fullStat.printStatistics(meanDistance,StatisticsElementMeanDistance);
    }

    return 0;
}