From 16274d2a9887a3982a932cea7aa502c4048fbc31 Mon Sep 17 00:00:00 2001 From: AustrianToast Date: Tue, 8 Oct 2024 23:29:02 +0200 Subject: [PATCH] rename matrix_multiply_basic to gemm_basic --- graph.c | 2 +- main.c | 15 ++++++--------- matrix.c | 2 +- matrix.h | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/graph.c b/graph.c index 589b4da..1ca2328 100644 --- a/graph.c +++ b/graph.c @@ -37,7 +37,7 @@ void calculate_distance_matrix(const uint64_t vertex_count, const uint64_t adjac for(uint64_t k = 2; k <= vertex_count; k++) { copy(vertex_count, vertex_count, power_matrix, temp_power_matrix); - matrix_multiply_basic(vertex_count, vertex_count, adjacency_matrix, vertex_count, vertex_count, temp_power_matrix, power_matrix); + gemm_basic(vertex_count, vertex_count, adjacency_matrix, vertex_count, vertex_count, temp_power_matrix, power_matrix); for (uint64_t row_index = 0; row_index < vertex_count; row_index++) { for (uint64_t column_index = 0; column_index < vertex_count; column_index++) { diff --git a/main.c b/main.c index 4074abe..8e1e37e 100644 --- a/main.c +++ b/main.c @@ -7,9 +7,6 @@ void benchmark() { const uint64_t vertex_count1 = 1024; - // printf("vertex_count1 * vertex_count1 * sizeof(uint64_t) = %lu bytes\n", vertex_count1 * vertex_count1 * sizeof(uint64_t)); - // printf("sizeof(uint64_t[vertex_count1][vertex_count1] = %lu bytes\n", sizeof(uint64_t[vertex_count1][vertex_count1])); - // return; uint64_t (*matrix1)[vertex_count1] = malloc(vertex_count1 * vertex_count1 * sizeof(uint64_t)); const uint64_t vertex_count2 = 1024; @@ -18,7 +15,7 @@ void benchmark() { uint64_t (*new_matrix)[vertex_count2] = malloc(vertex_count1 * vertex_count2 * sizeof(uint64_t)); double elapsed_time = 0.0; - const uint64_t iterations = 1; + const uint64_t iterations = 10; clock_t start_time; for (uint64_t i = 0; i < iterations; i++) { @@ -27,15 +24,15 @@ void benchmark() { start_time = clock(); - matrix_multiply_basic(vertex_count1, vertex_count1, matrix1, + gemm_basic(vertex_count1, vertex_count1, matrix1, vertex_count2, vertex_count2, matrix2, new_matrix); elapsed_time += (double)(clock() - start_time) / CLOCKS_PER_SEC; } - printf("%lu iterations of matrix_multiply_basic took roughly %f seconds\n", iterations, elapsed_time); - printf("An iteration of matrix_multiply_basic took on average roughly %f seconds\n", elapsed_time/iterations); + printf("%lu iterations of gemm_basic took roughly %f seconds\n", iterations, elapsed_time); + printf("An iteration of gemm_basic took on average roughly %f seconds\n", elapsed_time/iterations); free(matrix1); free(matrix2); @@ -62,6 +59,6 @@ void test() { } int main(void) { - test(); - // benchmark(); + // test(); + benchmark(); } diff --git a/matrix.c b/matrix.c index 408e1b8..6d41139 100644 --- a/matrix.c +++ b/matrix.c @@ -14,7 +14,7 @@ void print_matrix(const uint64_t row_length, const uint64_t column_length, const } } -int matrix_multiply_basic(const uint64_t row_length1, const uint64_t column_length1, const uint64_t matrix1[row_length1][column_length1], +int gemm_basic(const uint64_t row_length1, const uint64_t column_length1, const uint64_t matrix1[row_length1][column_length1], const uint64_t row_length2, const uint64_t column_length2, const uint64_t matrix2[row_length2][column_length2], uint64_t output_matrix[row_length1][column_length2]) { diff --git a/matrix.h b/matrix.h index 423af4c..9f238f9 100644 --- a/matrix.h +++ b/matrix.h @@ -13,7 +13,7 @@ void print_matrix(const uint64_t row_length, Matrix requirements are as specified in the parameters. Function return 0 on success and 1 on failure. */ -int matrix_multiply_basic(const uint64_t row_length1, +int gemm_basic(const uint64_t row_length1, const uint64_t column_length1, const uint64_t matrix1[row_length1][column_length1], const uint64_t row_length2,