Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci performance #77

Merged
merged 9 commits into from
Oct 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions examples/SW/riscv_dhry/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# RISC-V Software Compilation for C++
# Dhrystone benchmark for evaluating RISC-V compilers' performance

This file contains ctr0, linker script, Makefile (originally from pulpino
project) for simple RISC-V software compilation using C++. For instructions and more details, see `../riscv/README.md`.
Header and modules present:

### RISC-V target software
dhry.h
dhry_1.c
dhry_2.c

The target software runs some basic C++ specific tests. Binary code and elf file will be located at `./build`.
See: https://github.com/Keith-S-Thompson/dhrystone/tree/master/v2.1

# Compilers whose performances are to be analyzed:

GCC, TCC and LLVM
27 changes: 1 addition & 26 deletions examples/bare_etiss_processor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#include "TracePrinter.h"
#include "etiss/SimpleMemSystem.h"
#include "etiss/ETISS.h"
void writeFileJson(float cpu_time, float simulation_time, float cpu_cycle, float mips, std::string valid_json_output_path);// Save the information in JSON format


int main(int argc, const char *argv[])
{
Expand Down Expand Up @@ -96,8 +96,6 @@ int main(int argc, const char *argv[])
std::cout << " Setting up CPUCore" << std::endl;
// create a cpu core named core0 with the or1k architecture
std::string CPUArchName = etiss::cfg().get<std::string>("arch.cpu", "");
std::string valid_json_output_path = etiss::cfg().get<std::string>("vp.stats_file_path", "");
bool output_json = etiss::cfg().isSet("vp.stats_file_path");
etiss::uint64 sa = etiss::cfg().get<uint64_t>("vp.entry_point", dsys.get_startaddr());
std::cout << " CPU start address: 0x" << std::hex << sa << std::dec << std::endl;
std::shared_ptr<etiss::CPUCore> cpu = etiss::CPUCore::create(CPUArchName, "core0");
Expand Down Expand Up @@ -142,21 +140,6 @@ int main(int argc, const char *argv[])
//float endTime = (float)clock() / CLOCKS_PER_SEC;
std::cout << "=== Simulation end ===" << std::endl << std::endl;

//calculations for json file output

ETISS_CPU *cpu_state = cpu->getState();

float cpu_time = cpu_state->cpuTime_ps / 1.0E12;
float simulation_time = cpu->endTime - cpu->startTime;
float cpu_cycle = cpu_state->cpuTime_ps / (float)cpu_state->cpuCycleTime_ps;
float mips = (cpu_state->cpuTime_ps / (float)cpu_state->cpuCycleTime_ps / simulation_time / 1.0E6);

//print out the simulation calculations via json file

if(output_json==true)
{
writeFileJson(cpu_time, simulation_time, cpu_cycle, mips, valid_json_output_path);
}

// print the exception code returned by the cpu core
std::cout << "CPU0 exited with exception: 0x" << std::hex << exception << std::dec << ": "
Expand Down Expand Up @@ -203,13 +186,5 @@ int main(int argc, const char *argv[])
break;
}
}
void writeFileJson(float cpu_time, float simulation_time, float cpu_cycle, float mips, std::string valid_json_output_path)// Save the information in JSON format
{

std::ofstream json_output(valid_json_output_path);
json_output << "{\"mips\": " << mips << ", \"Simulation_Time\": " << simulation_time << ", \"CPU_Time\": " << cpu_time << ", \"CPU_cycle\": " << cpu_cycle << "}" << std::endl;

}



37 changes: 31 additions & 6 deletions src/CPUCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

using namespace etiss;


void writeFileJson(float cpu_time, float simulation_time, float cpu_cycle, float mips, std::string valid_json_output_path);// Save the information in JSON format

/**
@see etiss/CPUArch.h
Expand Down Expand Up @@ -845,12 +845,27 @@ etiss::int32 CPUCore::execute(ETISS_System &_system)
cor_plugin->executionEnd(exception);
}

// print some statistics
std::cout << "CPU Time: " << (cpu_->cpuTime_ps / 1.0E12) << "s Simulation Time: " << (endTime - startTime) << "s"
// Defining the statistics of measurement and printing them
double cpu_time = cpu_->cpuTime_ps / 1.0E12;
double simulation_time = endTime - startTime;
double cpu_cycle = cpu_->cpuTime_ps / (float)cpu_->cpuCycleTime_ps;
double mips = cpu_->cpuTime_ps / (float)cpu_->cpuCycleTime_ps / simulation_time / 1.0E6;
std::cout << "CPU Time: " << (cpu_time) << "s Simulation Time: " << (simulation_time) << "s"
<< std::endl;
std::cout << "CPU Cycles (estimated): " << (cpu_->cpuTime_ps / (float)cpu_->cpuCycleTime_ps) << std::endl;
std::cout << "MIPS (estimated): "
<< (cpu_->cpuTime_ps / (float)cpu_->cpuCycleTime_ps / (endTime - startTime) / 1.0E6) << std::endl;
std::cout << "CPU Cycles (estimated): " << (cpu_cycle) << std::endl;
std::cout << "MIPS (estimated): " << (mips) << std::endl;


// declaring path of writing the json file contaiing performance metrics and the boolean which approves of writing the json output
std::string valid_json_output_path = etiss::cfg().get<std::string>("vp.stats_file_path", "");
bool output_json = etiss::cfg().isSet("vp.stats_file_path");

if(output_json==true)
{
writeFileJson(cpu_time, simulation_time, cpu_cycle, mips, valid_json_output_path);
}


etiss_uint64 max = 0;
for (int i = 0; i < ETISS_MAX_RESOURCES; i++)
{
Expand Down Expand Up @@ -923,3 +938,13 @@ etiss::int32 CPUCore::execute(ETISS_System &_system)
}


// Function to write the performance metrics of a run into a json file
void writeFileJson(float cpu_time, float simulation_time, float cpu_cycle, float mips, std::string valid_json_output_path)// Save the information in JSON format
{

std::ofstream json_output(valid_json_output_path);
json_output << "{\"mips\": " << mips << ", \"Simulation_Time\": " << simulation_time << ", \"CPU_Time\": " << cpu_time << ", \"CPU_cycle\": " << cpu_cycle << "}" << std::endl;

}