formatting

This commit is contained in:
AustrianToast 2024-10-14 14:07:59 +02:00
parent 2b2ffe9649
commit c41d130a45
Signed by: AustrianToast
GPG Key ID: 1B4D0AAF6E558816
2 changed files with 16 additions and 29 deletions

26
main.c
View File

@ -3,41 +3,33 @@
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void benchmark_gemm() {
const uint64_t vertex_count1 = 1024;
uint64_t (*matrix1)[vertex_count1] = malloc(vertex_count1 * vertex_count1 * sizeof(uint64_t));
const uint64_t vertex_count2 = 1024;
uint64_t (*matrix2)[vertex_count2] = malloc(vertex_count2 * vertex_count2 * sizeof(uint64_t));
uint64_t (*new_matrix)[vertex_count2] = malloc(vertex_count1 * vertex_count2 * sizeof(uint64_t));
const uint64_t vertex_count = 100;
uint64_t adjacency_matrix1[vertex_count][vertex_count];
uint64_t adjacency_matrix2[vertex_count][vertex_count];
uint64_t dot_product[vertex_count][vertex_count];
double elapsed_time = 0.0;
const uint64_t iterations = 10;
clock_t start_time;
for (uint64_t i = 0; i < iterations; i++) {
random_adjacency(vertex_count1, matrix1);
random_adjacency(vertex_count2, matrix2);
random_adjacency(vertex_count, adjacency_matrix1);
random_adjacency(vertex_count, adjacency_matrix2);
start_time = clock();
gemm_basic(vertex_count1, vertex_count1, matrix1,
vertex_count2, vertex_count2, matrix2,
new_matrix);
gemm_basic(vertex_count, vertex_count, adjacency_matrix1,
vertex_count, vertex_count, adjacency_matrix2,
dot_product);
elapsed_time += (double)(clock() - start_time) / CLOCKS_PER_SEC;
}
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);
free(new_matrix);
}
void benchmark_find_components() {

View File

@ -3,8 +3,7 @@
#include <stdint.h>
void print_matrix(const uint64_t row_length,
const uint64_t column_length,
void print_matrix(const uint64_t row_length, const uint64_t column_length,
const uint64_t matrix[row_length][column_length]);
/*
@ -12,17 +11,13 @@ void print_matrix(const uint64_t row_length,
restult will be written to output_matrix.
Matrix size requirements are as specified in the parameters.
*/
void 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]);
void 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]);
int read_csv(char *file_name,
uint64_t row_length,
uint64_t column_length,
int read_csv(char *file_name, uint64_t row_length, uint64_t column_length,
uint64_t output_matrix[row_length][column_length]);
#endif