58
edits
Changes
→Reference
{{GPU621/DPS921 Index | 20207}}
[mailto:astinziani@myseneca.ca?subject=GPU621 Yuseok Won]
[mailto:astinziani@myseneca.ca?subject=GPU621 Minsu Kim]
=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.
[[File:what-is-java-5b4bda1cc9e77c0037171617.jpg|400px|left]]
Java is open source and Objectobject-oriented programming language developed by Sun Microsystems in 1995. The founder is James Gosling. In 2010, Oracle acquired Sun Microsystems and owned Java's copyright.
Java is simple programming language, easy to learn, clean and easy to understand. This is because syntax of Java is based on C++ that has removed many confusing and rarely used functionality by user (e.g. operator overloading, explicit pointer, automatic garbage collection manual memory management etc.)
Java is the platform independent language. Programs can run on several different types of computer as long as computer has a Java Runtime Environment(JRE) installed.
<br>
<br>
'''Parallelism and Concurrency'''
diagram cited by Pithikos in [https://stackoverflow.com/questions/1050222/what-is-the-difference-between-concurrency-and-parallelism Stack Overflow]
'''Implementation''' Go language focuses on concurrency and parallelism by implementing its own Goroutine instead of regular threading. Goroutines uses the built-in scheduler to conduct the threads in behind and hide many complexity of thread management from the user to specify which function to run and execute them with “Go” command. 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==
'''1.''' To Increase the accuracy, both Go & Java version 5program will run in terminal using .0 and later provides concurrency sh script <br>- To do this, you will need to simplify thread creation and processing. The enable "[https://docs.oracle.com/javase/tutorial/essential/concurrency/executors.html Executor]Root" that implement by java.util.concurrent provides APIs for creating and processing new threads using reusable threads.<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>- Environment/machine used for below experiment is:{| class===Implementation==="wikitable" margin-left: left;|-| Machine || Mac Book Pro 2019|-| Processor || 2.3GHz 8-core 16 threads Intel Core i9 |-| macOS || Big Sur 11.5.1|-| Memory || 16GB|-| Go Version || v1.16.6|-| Java Version || v15 2020-09-15 |}'''Installation of Go3.''' 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===
Go to [https://golang.org/dl/ https://golang.org/dl/] & Download Go accordingly to your OS.
package main
runtime.GC()
}
=== .sh Code to Run Go Program ===
''Above Go code will run in terminal using .sh script.''
#! /bin/sh
COUNTER=0
MAX=7
go build MatrixMultiGo.go > result.txt
echo "Running tests for no multithreading..."
echo "### No Multithreading" >> result.txt
while [ $COUNTER -lt $MAX ]
do
((COUNTER++))
echo "Running test #$COUNTER"
nice -n -20 ./MatrixMultiGo 4096.in 0 >> result.txt
done
COUNTER=0
echo "Running tests for 1 thread..."
echo "### Threading with 1 thread" >> result.txt
while [ $COUNTER -lt $MAX ]
do
((COUNTER++))
echo "Running test #$COUNTER"
nice -n -20 ./MatrixMultiGo 4096.in 1 >> result.txt
done
COUNTER=0
echo "Running tests for 2 threads..."
echo "### Multithreading with 2 threads" >> result.txt
while [ $COUNTER -lt $MAX ]
do
((COUNTER++))
echo "Running test #$COUNTER"
nice -n -20 ./MatrixMultiGo 4096.i 0>> result.txt
done
COUNTER=0
echo "Running tests for 4 threads..."
echo "### Multithreading with 4 threads" >> result.txt
while [ $COUNTER -lt $MAX ]
do
((COUNTER++))
echo "Running test #$COUNTER"
nice -n -20 ./MatrixMultiGo 4096.in 4 >> result.txt
done
COUNTER=0
echo "Running tests for 8 threads..."
echo "### Multithreading with 8 threads" >> result.txt
while [ $COUNTER -lt $MAX ]
do
((COUNTER++))
echo "Running test #$COUNTER"
nice -n -20 ./MatrixMultiGo 4096.in 8 >> result.txt
done
COUNTER=0
echo "Running tests for 16 threads..."
echo "### Multithreading with 16 threads" >> result.txt
while [ $COUNTER -lt $MAX ]
do
((COUNTER++))
echo "Running test #$COUNTER"
nice -n -20 ./MatrixMultiGo 4096.in 16 >> result.txt
done
echo "Done";
==Implementation for Java==
===Multi-Thread Program in Java===
import java.io.BufferedReader;
import java.io.FileReader;
}
}
===.sh Code to Run Go Program ===''Above Java code will run in terminal using .sh script.''''' .sh Code to Run Go Java Program '''
#! /bin/sh
COUNTER=0
MAX=7
echo "Running tests for no multithreading..."
echo "### No Multithreading" >> result.txt
while [ $COUNTER -lt $MAX ];
do
((COUNTER++))
echo "Running test #$COUNTER"
nice -n -20 ./MatrixMultiGo java -Xms8g -Xmx8g Java_Thread 4096.in 0 >> result.txt
done
COUNTER=0
echo "Running tests for 1 thread..."
echo "### Threading with 1 thread" >> result.txt
while [ $COUNTER -lt $MAX ];
do
((COUNTER++))
echo "Running test #$COUNTER"
nice -n -20 ./MatrixMultiGo java -Xms8g -Xmx8g Java_Thread 4096.in 1 >> result.txt
done
COUNTER=0
echo "Running tests for 2 threads..."
echo "### Multithreading with 2 threads" >> result.txt
while [ $COUNTER -lt $MAX ];
do
done
COUNTER=0
echo "Running tests for 4 threads..."
echo "### Multithreading with 4 threads" >> result.txt
while [ $COUNTER -lt $MAX ];
do
((COUNTER++))
echo "Running test #$COUNTER"
nice -n -20 ./MatrixMultiGo java -Xms8g -Xmx8g Java_Thread 4096.in 4 >> result.txt
done
COUNTER=0
echo "Running tests for 8 threads..."
echo "### Multithreading with 8 threads" >> result.txt
while [ $COUNTER -lt $MAX ];
do
((COUNTER++))
echo "Running test #$COUNTER"
nice -n -20 ./MatrixMultiGo java -Xms8g -Xmx8g Java_Thread 4096.in 8 >> result.txt
done
COUNTER=0
echo "Running tests for 16 threads..."
echo "### Multithreading with 16 threads" >> result.txt
while [ $COUNTER -lt $MAX ];
do
((COUNTER++))
echo "Running test #$COUNTER"
nice -n -20 ./MatrixMultiGo java -Xms8g -Xmx8g Java_Thread 4096.in 16 >> result.txt
done
echo "Done";
=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=Analysis===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