rename matrix_multiply_basic to gemm_basic

This commit is contained in:
AustrianToast 2024-10-08 23:29:02 +02:00
parent d8c3a75d50
commit 16274d2a98
Signed by: AustrianToast
GPG Key ID: 1B4D0AAF6E558816
4 changed files with 9 additions and 12 deletions

View File

@ -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++) {

15
main.c
View File

@ -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();
}

View File

@ -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]) {

View File

@ -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,