All Projects → greensoftwarelab → Energy Languages

greensoftwarelab / Energy Languages

Licence: mit
The complete set of tools for energy consumption analysis of programming languages, using Computer Language Benchmark Game

Programming Languages

c
50402 projects - #5 most used programming language
languages
34 projects

Projects that are alternatives of or similar to Energy Languages

Daily Coding Problem
Solutions for Daily Coding Problem.
Stars: ✭ 300 (-22.08%)
Mutual labels:  programming
Awesome Prolog
Curated list of Prolog packages and resources
Stars: ✭ 342 (-11.17%)
Mutual labels:  programming
Programming Music
A collective list of music to listen to while programming
Stars: ✭ 365 (-5.19%)
Mutual labels:  programming
Awesome Raspberry Pi
curated list of projects with raspberry pi
Stars: ✭ 309 (-19.74%)
Mutual labels:  energy
30 Seconds Of React
Short React code snippets for all your development needs
Stars: ✭ 3,991 (+936.62%)
Mutual labels:  programming
Sobre
Informações gerais sobre o Centro de Treinamento
Stars: ✭ 345 (-10.39%)
Mutual labels:  programming
Programmingdesignsystems.com
The book!
Stars: ✭ 288 (-25.19%)
Mutual labels:  programming
Ppt
PPT I collected
Stars: ✭ 380 (-1.3%)
Mutual labels:  programming
Pvsneslib
PVSnesLib : A small, open and free development kit for the Nintendo SNES
Stars: ✭ 330 (-14.29%)
Mutual labels:  programming
Aws Doc Sdk Examples
Welcome to the AWS Code Examples Repository. This repo contains code examples used in the AWS documentation, AWS SDK Developer Guides, and more. For more information, see the Readme.rst file below.
Stars: ✭ 4,575 (+1088.31%)
Mutual labels:  programming
Flutterdarttips
Useful Flutter and Dart Tips.
Stars: ✭ 321 (-16.62%)
Mutual labels:  programming
Awesome Russian It
📖 🎧 📺 📆 Список полезных русскоязычных ресурсов, связанных с ИТ
Stars: ✭ 323 (-16.1%)
Mutual labels:  programming
Awesome Devbook
📕 국내 개발 도서 리스트
Stars: ✭ 351 (-8.83%)
Mutual labels:  programming
Coderchef Kitchen
The official repository for our programming kitchen which consists of 50+ delicious programming recipes having all the interesting ingredients ranging from dynamic programming, graph theory, linked lists and much more. All the articles contain beautiful images and some gif/video at times to help clear important concepts.
Stars: ✭ 306 (-20.52%)
Mutual labels:  programming
Programming Books
A collection of Programming books 📖
Stars: ✭ 367 (-4.68%)
Mutual labels:  programming
Handong1587.github.io
handong1587.github.io
Stars: ✭ 3,110 (+707.79%)
Mutual labels:  programming
Observable
The easiest way to observe values in Swift.
Stars: ✭ 346 (-10.13%)
Mutual labels:  programming
Juliabasics
The open source version of book `Julia Programming Basics`
Stars: ✭ 387 (+0.52%)
Mutual labels:  programming
Yorlang
A programming language with yoruba language construct
Stars: ✭ 377 (-2.08%)
Mutual labels:  programming
Devops Roadmap
DevOps methodology & roadmap for a devops developer in 2019. Interesting books to learn new technologies.
Stars: ✭ 349 (-9.35%)
Mutual labels:  programming

Energy Efficiency in Programming Languages

Checking Energy Consumption in Programming Languages Using the Computer Language Benchmark Game as a case study.

What is this?

This repo contains the source code of 10 distinct benchmarks, implemented in 28 different languages (exactly as taken from the Computer Language Benchmark Game).

It also contains tools which provide support, for each benchmark of each language, to 4 operations: (1) compilation, (2) execution, (3) energy measuring and (4) memory peak detection.

How is it structured and hows does it work?

This framework follows a specific folder structure, which guarantees the correct workflow when the goal is to perform and operation for all benchmarks at once. Moreover, it must be defined, for each benchmark, how to perform the 4 operations considered.

Next, we explain the folder structure and how to specify, for each language benchmark, the execution of each operation.

The Structure

The main folder contains 32 elements:

  1. 28 sub-folders (one for each of the considered languages); each folder contains a sub-folder for each considered benchmark.
  2. A Python script compile_all.py, capable of building, running and measuring the energy and memory usage of every benchmark in all considered languages.
  3. A RAPL sub-folder, containing the code of the energy measurement framework.
  4. A Bash script gen-input.sh, used to generate the input files for 3 benchmarks: k-nucleotide, reverse-complement, and regex-redux.

Basically, the directories tree will look something like this:

| ...
| <Language-1>
	| <benchmark-1>
		| <source>
		| Makefile
		| [input]
	| ...
	| <benchmark-i>
		| <source>
		| Makefile
		| [input]
| ...
| <Language-i>
	| <benchmark-1>
	| ...
	| <benchmark-i>
| RAPL
| compile_all.py
| gen-input.sh

Taking the C language as an example, this is how the folder for the binary-trees and k-nucleotide benchmarks would look like:

| ...
| C
	| binary-trees
		| binarytrees.gcc-3.c
		| Makefile
	| k-nucleotide
		| knucleotide.c
		| knucleotide-input25000000.txt
		| Makefile
	| ...
| ...

The Operations

Each benchmark sub-folder, included in a language folder, contains a Makefile. This is the file where is stated how to perform the 4 supported operations: (1) compilation, (2) execution, (3) energy measuring and (4) memory peak detection.

Basically, each Makefile must contains 4 rules, one for each operations:

Rule Description
compile This rule specifies how the benchmark should be compiled in the considered language; Interpreted languages don't need it, so it can be left blank in such cases.
run This rule specifies how the benchmark should be executed; It is used to test whether the benchmark runs with no errors, and the output is the expected.
measure This rule shows how to use the framework included in the RAPL folder to measure the energy of executing the task specified in the run rule.
mem Similar to measure, this rule executes the task specified in the run rule but with support for memory peak detection.

To better understand it, here's the Makefile for the binary-trees benchmark in the C language:

compile:
	/usr/bin/gcc -pipe -Wall -O3 -fomit-frame-pointer -march=native -fopenmp -D_FILE_OFFSET_BITS=64 -I/usr/include/apr-1.0 binarytrees.gcc-3.c -o binarytrees.gcc-3.gcc_run -lapr-1 -lgomp -lm
	
measure:
	sudo ../../RAPL/main "./binarytrees.gcc-3.gcc_run 21" C binary-trees

run:
	./binarytrees.gcc-3.gcc_run 21

mem:
	/usr/bin/time -v ./binarytrees.gcc-3.gcc_run 21

Running an example.

First things first: generate the input files, like this

./gen-input.sh

This will generate the necessary input files, and are valid for every language.

We included a main Python script, compile_all.py, that you can either call from the main folder or from inside a language folder, and it can be executed as follows:

python compile_all.py [rule]

You can provide a rule from the available 4 referenced before, and the script will perform it using every Makefile found in the same folder level and bellow.

The default rule is compile, which means that if you run it with no arguments provided (python compile_all.py) the script will try to compile all benchmarks.

The results of the energy measurements will be stored in files with the name <language>.csv, where <language> is the name of the running language. You will find such file inside of corresponding language folder.

Each .csv will contain a line with the following:

benchmark-name ; PKG (Joules) ; CPU (J) ; GPU (J) ; DRAM (J) ; Time (ms)

Do note that the availability of GPU/DRAM measurements depend on your machine's architecture. These are requirements from RAPL itself.

Add your own example!

Wanna know your own code's energy behavior? We help you!

Follow this steps:

1. Create a folder with the name of you benchmark, such as test-benchmark, inside the language you implemented it.
2. Follow the instructions presented in the Operations section, and fill the Makefile.
3. Use the compile_all.py script to compile, run, and/or measure what you want! Or run it yourself using the make command.

Further Reading

Wanna know more? Check this website!

There you can find the results of a successful experimental setup using the contents of this repo, and the used machine and compilers specifications.

You can also find there the paper which include such results and our discussion on them:

"Energy Efficiency across Programming Languages: How does Energy, Time and Memory Relate?", Rui Pereira, Marco Couto, Francisco Ribeiro, Rui Rua, Jácome Cunha, João Paulo Fernandes, and João Saraiva. In Proceedings of the 10th International Conference on Software Language Engineering (SLE '17)

IMPORTANT NOTE:

The Makefiles have specified, for some cases, the path for the language's compiler/runner. It is most likely that you will not have them in the same path of your machine. If you would like to properly test every benchmark of every language, please make sure you have all compilers/runners installed, and adapt the Makefiles accordingly.

Contacts and References

Green Software Lab

Main contributors: @Marco Couto and @Rui Pereira

The Computer Language Benchmark Game

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].