// benchmark a single CPU // int cpu_benchmarks(BENCHMARK_DESC* bdp) { HOST_INFO host_info; int retval; double vax_mips, int_loops=0, int_time=0, fp_time; bdp->error_str[0] = '\0'; host_info.clear_host_info(); retval = whetstone(host_info.p_fpops, fp_time, MIN_CPU_TIME); if (retval) { bdp->error = true; sprintf(bdp->error_str, "FP benchmark ran only %f sec; ignoring", fp_time); return 0; } #ifdef _WIN32 // Windows: do integer benchmark only on CPU zero. // There's a mysterious bug/problem that gives wildly // differing benchmarks on multi-CPU and multi-core machines, // if you use all the CPUs at once. // if (bdp->ordinal == 0) { #endif retval = dhrystone(vax_mips, int_loops, int_time, MIN_CPU_TIME); if (retval) { bdp->error = true; sprintf(bdp->error_str, "Integer benchmark ran only %f sec; ignoring", int_time); return 0; } host_info.p_iops = vax_mips*1e6; host_info.p_membw = 1e9; #ifdef _WIN32 } bdp->host_info = host_info; bdp->int_loops = int_loops; bdp->int_time = int_time; #else FILE* finfo; finfo = boinc_fopen(bdp->filename, "w"); if (!finfo) return ERR_FOPEN; host_info.write_cpu_benchmarks(finfo); fclose(finfo); #endif return 0; }
/* * User's entry point. */ int sc_main(int argc , char * argv[]) { /* * Initialize simulation */ scx::scx_initialize("Dhrystone"); /* * Components */ amba_pv::amba_pv_memory<64> memory("Memory", 0x34000100); scx_evs_Dhrystone dhrystone("Dhrystone"); /* * Number of instructions to run per quantum */ double quantum = parse_quantum(argc, argv); /* * Simulation configuration */ /* From command-line options */ scx::scx_parse_and_configure(argc, argv, help_quantum); /* Semi-hosting configuration */ bool v; if (scx::scx_get_parameter("Dhrystone.Core.cpu1.semihosting-enable", v)) { /* MP core */ scx::scx_set_parameter("*.Core.cpu1.semihosting-enable", true); scx::scx_set_parameter("*.Core.cpu1.semihosting-ARM_SVC", 0x123456); scx::scx_set_parameter("*.Core.cpu1.semihosting-Thumb_SVC", 0xAB); scx::scx_set_parameter("*.Core.cpu1.semihosting-heap_base", 0x32800000); scx::scx_set_parameter("*.Core.cpu1.semihosting-heap_limit", 0x0800000); scx::scx_set_parameter("*.Core.cpu1.semihosting-stack_base", 0x33800000); scx::scx_set_parameter("*.Core.cpu1.semihosting-stack_limit", 0x0800000); } if (scx::scx_get_parameter("Dhrystone.Core.cpu0.semihosting-enable", v)) { /* MP core */ scx::scx_set_parameter("*.Core.cpu0.semihosting-enable", true); scx::scx_set_parameter("*.Core.cpu0.semihosting-ARM_SVC", 0x123456); scx::scx_set_parameter("*.Core.cpu0.semihosting-Thumb_SVC", 0xAB); scx::scx_set_parameter("*.Core.cpu0.semihosting-heap_base", 0x32000000); scx::scx_set_parameter("*.Core.cpu0.semihosting-heap_limit", 0x0800000); scx::scx_set_parameter("*.Core.cpu0.semihosting-stack_base", 0x33000000); scx::scx_set_parameter("*.Core.cpu0.semihosting-stack_limit", 0x0800000); } else { /* UP core */ scx::scx_set_parameter("*.Core.semihosting-enable", true); scx::scx_set_parameter("*.Core.semihosting-ARM_SVC", 0x123456); scx::scx_set_parameter("*.Core.semihosting-Thumb_SVC", 0xAB); scx::scx_set_parameter("*.Core.semihosting-heap_base", 0x32000000); scx::scx_set_parameter("*.Core.semihosting-heap_limit", 0x0800000); scx::scx_set_parameter("*.Core.semihosting-stack_base", 0x33000000); scx::scx_set_parameter("*.Core.semihosting-stack_limit", 0x0800000); } /* Simulation quantum, i.e. seconds to run per quantum */ tlm::tlm_global_quantum::instance().set(sc_core::sc_time(quantum / 100000000, sc_core::SC_SEC)); /* * Bindings */ dhrystone.amba_pv_m(memory.amba_pv_s); /* * Start of simulation */ sc_core::sc_start(); return EXIT_SUCCESS; }