Skip to content

adrienharnay/java-concurrent-multiply-matrices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prerequisites:

  • Java JDK 1.8

Dependencies:

Description

This program computes the product of 2 matrices, using two different algorithms (SimpleMatrixMultiply, a naïve algorithm, and AdvancedMatrixMultiply, implementing the Strassen algorithm).

It takes the path to a JSON file containing 5 properties:

  • height1 (height of the first matrix),
  • width1 (width of the first matrix),
  • height2 (height of the second matrix),
  • width2 (width of the second matrix),
  • seed (seed used to generate random numbers).

Then generates two matrices, fills them with random number using the provided seed, with bounds [-1000000;1000000], and finally computes the product of the two matrices in both ways (if possible).

Usage:

  • Windows
javac -cp "src;libs/*" -d "out" src/*.java
java -Xmx8192m  -cp "out;libs/*" SimpleMatrixMultiply resources/matrices-4096-4095-4095-4096.json
java -Xmx8192m -cp "out;libs/*" AdvancedMatrixMultiply resources/matrices-4096-4095-4095-4096.json
  • Linux
javac -cp "src:libs/*" -d "out" src/*.java
java -Xmx8192m  -cp "out:libs/*" SimpleMatrixMultiply resources/matrices-4096-4095-4095-4096.json
java -Xmx8192m -cp "out:libs/*" AdvancedMatrixMultiply resources/matrices-4096-4095-4095-4096.json

Note: all tests have been executed using -Xmx8192m (or -Xmx8192m for computers that don't have 8Go of RAM), allocating 8Go of heap size to the JVM.

Note on AdvancedMatrixMultiply: computing matrices with a side size of more than 4096 requires more than 8Go of RAM, in order not to exceed the JVM heap size.


List of files to test on (in resources/):

  • matrices-1-1-1-1.json
  • matrices-5-2-20-5.json
  • matrices-9-9-9-9.json
  • matrices-15-10-10-5.json
  • matrices-2000-3000-3000-2000.json
  • matrices-3001-2001-2001-3001.json
  • matrices-4000-4000-4000-4000.json
  • matrices-4096-4095-4095-4096.json

Running the program with -v displays the 2 generated matrices and the 2 results m1 * m2 and m2 * m1

Results can be checked on (easier using the 4 first JSON files): http://wims.unice.fr/wims/wims.cgi?session=3ICB518C69.3&+lang=en&+module=tool%2Flinear%2Fmatmult

License

This software is under the MIT License (Copyright 2017, Adrien HARNAY).

About

CA670 Concurrent Programming project at DCU

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages