Skip to content

lucios-ufm/OSPoolThreads

Repository files navigation

cpu
🚀 OSPoolThreads


matrix multiplication using a thread pool to multiprocess the arithmetic operations

Vist Troubleshooting to find more.

Solution

  • Read the CSV files and convert them into matrix.
  • A csv_manager was implemented (read and write files with static methods).
  • We created a class to implement the solution, it is called mat_mult.py
  • This class has several methods that help with the implementation: verify the dimention of the matrix, run the actual code and managing the atributes.
  • We used a time package from the python library to keep track of the total amount used for the algorithm.
  • The class mat mult has a main method: run() and it implements a list o threads (pool), in which we store each pool.
  • We created different partitions of the matrix according to the pool size.
  • A part of the matrix is assigned to each thread for it to operate.
  • At the end, we iterate through the list of threads and join them all to the main thread.
  • All operations are storaged in an atribute in the class instance, so we print it into a csv.

Final time result for a 500x500 operation: 284.63789 seconds

cpu

💡 Warning: It can take some time and % of the CPU.

Requirements

To work correctly, you will first need:

Then run this command in order to install all the aditional dependencies from pip

pip install -r requirements.txt

Installing and running the app

Now that the requirements are satisfied, you can install and run the Mat Mult. First download or clone the repository and:

[Production]

python main.py {file A} {file B} {pool size} {output file}

Example:

python main.py m1A.csv m1B.csv 4 output.csv

Done. This command should run the code.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

About

thread pool to mat mult, built in python rip

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages