Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
7ce58ea
Add cstdint header for fixed-width integer types
victor-cali Apr 29, 2025
f9d451d
Add missing variable declarations
victor-cali Apr 29, 2025
c134c3d
Implement matrix reading function from file
victor-cali Apr 29, 2025
c267361
Refactor matrix multiplication functions to use double precision
victor-cali Apr 29, 2025
57d6068
Implement naive matrix multiplication function
victor-cali Apr 29, 2025
fdaf117
Implement write_matrix function to save a matrix to files
victor-cali Apr 29, 2025
1761d27
Update file path handling with individual result file paths for every…
victor-cali Apr 29, 2025
9258770
Add code to write result matrices for each method
victor-cali Apr 29, 2025
53f21df
Implement result validation for matrix multiplication and update exit…
victor-cali Apr 29, 2025
44d904e
Fix result file naming for naive matrix multiplication and update rel…
victor-cali Apr 29, 2025
83d84d6
Implement blocked and parallel matrix multiplication algorithms with …
victor-cali May 3, 2025
b3edf5b
Fix executable source file name in CMakeLists.txt to use main.cpp
victor-cali May 3, 2025
6d5fef1
Add dimension check for matrix multiplication and update block size
victor-cali May 3, 2025
0e6f719
Add initial Makefile for build system configuration and target defini…
victor-cali May 3, 2025
0ce1c62
Add executable and results
victor-cali May 3, 2025
efac5fe
Add results section to README with performance metrics for matrix mul…
victor-cali May 3, 2025
aa0df19
armando-canales-lima: Implemented optimized matrix multiplication
victor-cali May 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if(APPLE)
endif()


add_executable(matmul main_ans.cpp)
add_executable(matmul main.cpp)


if(OpenMP_CXX_FOUND)
Expand Down
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,38 @@ git push origin student-name
- Validate each implementation against `output.raw` to ensure correctness before optimizing.
- Use small test cases to debug your blocked and parallel implementations.

Good luck, and enjoy optimizing your matrix multiplication!
Good luck, and enjoy optimizing your matrix multiplication!

---

# Results

**v. Armando Canales Lima**

| Test Case | Dimensions (m × n × p) | Naive Time (s) | Blocked Time (s) | Parallel Time (s) | Blocked Speedup | Parallel Speedup |
|-----------|------------------------|----------------|------------------|-------------------|-----------------|------------------|
| 0 | 64 × 64 × 64 | 0.0009391 | 0.0009271 | 0.0005915 | 1.0928× | 1.1568× |
| 1 | 128 × 64 × 128 | 0.0036451 | 0.0037321 | 0.0010113 | 1.2447× | 2.8033× |
| 2 | 100 × 128 × 56 | 0.0024653 | 0.0025529 | 0.0007842 | 1.1746× | 2.4285× |
| 3 | 128 × 64 × 128 | 0.0035558 | 0.0037061 | 0.0012246 | 1.1227× | 2.3024× |
| 4 | 32 × 128 × 32 | 0.0005984 | 0.0004421 | 0.0005571 | 1.0117× | 0.6669× |
| 5 | 200 × 100 × 256 | 0.0223089 | 0.0194391 | 0.0031179 | 1.1583× | 5.9628× |
| 6 | 256 × 256 × 256 | 0.0798916 | 0.0600181 | 0.0089990 | 2.0448× | 6.2599× |
| 7 | 256 × 300 × 256 | 0.0932562 | 0.0720682 | 0.0116580 | 1.3121× | 5.8579× |
| 8 | 64 × 128 × 64 | 0.0019189 | 0.0018024 | 0.0007125 | 1.0254× | 1.9984× |
| 9 | 256 × 256 × 257 | 0.1010160 | 0.0604076 | 0.0079931 | 0.9972× | 5.9855× |


Average blocked speedup by block size:

- 16: 0.96754x
- 32: 1.16235x
- 64: 1.21844x (Best)

Average parallel speedup by thread number:

- 4: 2.2152x
- 8: 3.5422x (Best)
- 16: 2.2268x

Table shows results for Best performing parameters (64 block size ad 8 threads)
181 changes: 181 additions & 0 deletions build/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.28

# Default target executed when no arguments are given to make.
default_target: all
.PHONY : default_target

# Allow only one "make -f Makefile2" at a time, but pass parallelism.
.NOTPARALLEL:

#=============================================================================
# Special targets provided by cmake.

# Disable implicit rules so canonical targets will work.
.SUFFIXES:

# Disable VCS-based implicit rules.
% : %,v

# Disable VCS-based implicit rules.
% : RCS/%

# Disable VCS-based implicit rules.
% : RCS/%,v

# Disable VCS-based implicit rules.
% : SCCS/s.%

# Disable VCS-based implicit rules.
% : s.%

.SUFFIXES: .hpux_make_needs_suffix_list

# Command-line flag to silence nested $(MAKE).
$(VERBOSE)MAKESILENT = -s

#Suppress display of executed commands.
$(VERBOSE).SILENT:

# A target that is always out of date.
cmake_force:
.PHONY : cmake_force

#=============================================================================
# Set environment variables for the build.

# The shell in which to execute make rules.
SHELL = /bin/sh

# The CMake executable.
CMAKE_COMMAND = /usr/bin/cmake

# The command to remove a file.
RM = /usr/bin/cmake -E rm -f

# Escaping for special characters.
EQUALS = =

# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /Dev/parallel-programming-homework-2

# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /Dev/parallel-programming-homework-2/build

#=============================================================================
# Targets provided globally by CMake.

# Special rule for the target edit_cache
edit_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "No interactive CMake dialog available..."
/usr/bin/cmake -E echo No\ interactive\ CMake\ dialog\ available.
.PHONY : edit_cache

# Special rule for the target edit_cache
edit_cache/fast: edit_cache
.PHONY : edit_cache/fast

# Special rule for the target rebuild_cache
rebuild_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Running CMake to regenerate build system..."
/usr/bin/cmake --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : rebuild_cache

# Special rule for the target rebuild_cache
rebuild_cache/fast: rebuild_cache
.PHONY : rebuild_cache/fast

# The main all target
all: cmake_check_build_system
$(CMAKE_COMMAND) -E cmake_progress_start /Dev/parallel-programming-homework-2/build/CMakeFiles /Dev/parallel-programming-homework-2/build//CMakeFiles/progress.marks
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 all
$(CMAKE_COMMAND) -E cmake_progress_start /Dev/parallel-programming-homework-2/build/CMakeFiles 0
.PHONY : all

# The main clean target
clean:
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 clean
.PHONY : clean

# The main clean target
clean/fast: clean
.PHONY : clean/fast

# Prepare targets for installation.
preinstall: all
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall

# Prepare targets for installation.
preinstall/fast:
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall/fast

# clear depends
depend:
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
.PHONY : depend

#=============================================================================
# Target rules for targets named matmul

# Build rule for target.
matmul: cmake_check_build_system
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 matmul
.PHONY : matmul

# fast build rule for target.
matmul/fast:
$(MAKE) $(MAKESILENT) -f CMakeFiles/matmul.dir/build.make CMakeFiles/matmul.dir/build
.PHONY : matmul/fast

main.o: main.cpp.o
.PHONY : main.o

# target to build an object file
main.cpp.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/matmul.dir/build.make CMakeFiles/matmul.dir/main.cpp.o
.PHONY : main.cpp.o

main.i: main.cpp.i
.PHONY : main.i

# target to preprocess a source file
main.cpp.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/matmul.dir/build.make CMakeFiles/matmul.dir/main.cpp.i
.PHONY : main.cpp.i

main.s: main.cpp.s
.PHONY : main.s

# target to generate assembly for a file
main.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/matmul.dir/build.make CMakeFiles/matmul.dir/main.cpp.s
.PHONY : main.cpp.s

# Help Target
help:
@echo "The following are some of the valid targets for this Makefile:"
@echo "... all (the default if no target is provided)"
@echo "... clean"
@echo "... depend"
@echo "... edit_cache"
@echo "... rebuild_cache"
@echo "... matmul"
@echo "... main.o"
@echo "... main.i"
@echo "... main.s"
.PHONY : help



#=============================================================================
# Special targets to cleanup operation of make.

# Special rule to run CMake to check the build system integrity.
# No rule that depends on this can have commands that come from listfiles
# because they might be regenerated.
cmake_check_build_system:
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
.PHONY : cmake_check_build_system

Binary file added build/matmul
Binary file not shown.
Loading