Changes

Jump to: navigation, search

GPU621/Go Kimchi

704 bytes added, 12:13, 11 August 2021
Reference
{{GPU621/DPS921 Index | 20207}}
=Parallel Programming in Go & Java= == Group Members ==
[mailto:astinziani@myseneca.ca?subject=GPU621 Yuseok Won]
[mailto:astinziani@myseneca.ca?subject=GPU621 Minsu Kim]
== Project Description ==
This project will look at the performance difference between Go and Java for Parallel/Multithread program using the matrix multiplication algorithm.
The project will present parallel program code codes written in each language and will present .sh script to run the codes.
Graphical result of running the codes will be given to clearly show the performance difference between Go & Java.
It will also briefly cover key terms & concepts of parallel programming to help readers' understanding and the historical/fundamental difference of each language to determine what may have caused the performance difference.
=Programming Language Introduction=== What's GO Language? === ----
[[File:Golang.png|400px|left]] Go Language is a open source programming language that is designed at Google by [https://en.wikipedia.org/wiki/Robert_Griesemer Robert Griesemer], [https://en.wikipedia.org/wiki/Ken_Thompson Ken Thompson], and [https://en.wikipedia.org/wiki/Rob_Pike Rob Pike]. <br>
Go lang is a '''Fast''' and '''Pretty''' language.
=== What's Java Language? ===----
[[File:what-is-java-5b4bda1cc9e77c0037171617.jpg|400px|left]]
<br>
=== Parallel Programming in GO & Java ===----
'''Parallelism and Concurrency'''
Java language can implement thread in three different methods. The first method is to create a class which extends the "Thread" class that gives the user to have control of the lifecycle of the thread. But Java language only allows single inheritance which prevents the thread from extending other base class. The second method is using "Runnable" interface. This method allows to user to extend other base class while still being run as a new thread. However, this method does not give user to control lifecycle of thread. The third, Java version 5.0 and later provides "concurrency" to simplify thread creation and processing. The "[https://docs.oracle.com/javase/tutorial/essential/concurrency/executors.html Executor]" that implement by java.util.concurrent provides APIs for creating and processing new threads.
=Implementation===General Implementation Info===----
''Before diving into the code, here are some things to know.''
'''1.''' To Increase the accuracy, both Go & Java program will run in terminal using .sh script <br>
- To do this, you will need to enable "Root".<br>''Run below command to start root-user terminal'' sudo -s
'''2.''' To Increase the accuracy, both Go & Java program will run in the same environment/machine <br>
| Machine || Mac Book Pro 2019
|-
| Processor || 2.3GHz 8-core 16 threads Intel Core i9
|-
| macOS || Big Sur 11.5.1
|}
'''3.''' To run both program, 4096 * 4096 pre-generated Matrix with random values between 0 and 1000 will be used <br>
 
- Create & Download Matrix here [https://onlinenumbertools.com/random-number-matrix https://onlinenumbertools.com/random-number-matrix]
===Implementation for Go===----'''===Installation of Go''' <br>===
Go to [https://golang.org/dl/ https://golang.org/dl/] & Download Go accordingly to your OS.
'''===Multi-Thread Program in Go'''===
package main
runtime.GC()
}
''' === .sh Code to Run Go Program ''' <br>===
''Above Go code will run in terminal using .sh script.''
#! /bin/sh
echo "Done";
===Implementation for Java===----'''===Installation of Java''' <br>===
Go to [https://www.java.com/ko/download/manual.jsp https://www.java.com/ko/download/manual.jsp] & Download Java accordingly to your OS. <br>
'''===Multi-Thread Program in Java'''===
import java.io.BufferedReader;
import java.io.FileReader;
}
}
''' ===.sh Code to Run Go Program ''' <br>===
''Above Java code will run in terminal using .sh script.''
''' .sh Code to Run Java Program '''
echo "Done";
===Result===----
==Charts==
{| <!-- The nested table must be on a new line -->
| style="border: 2px" |
| 2 threads to 4 threads|| 51.90%
|-
| 4 threads to 8 threads|| 49.49%
|-
| 8 threads to 16 threads|| 8.79%
|}
 
| style="padding: 15px;" |
{| class="wikitable" margin-left: left;|+ Performance increase of difference for Go in comparsion to Java Thread
|-
! !! difference
|-
| Main Thread to 1 thread|| 1020.45%
|-
| 1 thread|| 101%|-| to 2 threadthreads|| 96127.9030%
|-
| 2 threads to 4 threadthreads|| 8193.8012%
|-
| 4 threads to 8 threadthreads|| 5568.27%
|-
| 8 threads to 16 threadthreads|| 12-20.65%
|}
|style="padding: 15px;"|
|}
===Analysis===----
The results of matrix multiplication implementation on Go language has remarkable superiority in main thread. However, the both language shows the tendency that execution time gradually decreases as the number of threads increase. The curve of execution time on the graph become flatten for both Go and Java when the number of threads become 8 and 16. We infer the Go has a reduction tendency when the number of threads reach 8 and 16 but Java shows the promotion tendency as number of threads reach 8 and 16. The best performance has been shown that the 8 threads for Go and 16 threads on Java. The percentage difference of implementation time between GO and Java shows minimum 12% when 16 threads being used and maximum 102% when main thread being used.
There is a few possible reason that Go and Java shows difference performance despite using same calculating matrix multiplication algorithm. First, the code for Go and Java is not exactly matched. second, Java uses JVM(Java Virtual Machine) to calculate the algorithm which may take more time to implement.
 
=Reference=
https://golang.org/doc/faq#goroutines <br>
https://docs.oracle.com/javase/tutorial/essential/concurrency/highlevel.html<br>
http://www.oracle.com/technetwork/java/javase/overview/javahistory-index-198355.html<br>
https://golang.org/doc/faq#Origins<br>
https://www.youtube.com/watch?v=oV9rvDllKEg<br>
https://stackoverflow.com/questions/1050222/what-is-the-difference-between-concurrency-and-parallelism<br>
https://onlinenumbertools.com/random-number-matrix<br>
https://golang.org/dl/<br>
https://www.java.com/ko/download/manual.jsp<br>
https://docs.oracle.com/javase/tutorial/essential/concurrency/executors.html
58
edits

Navigation menu