diff --git a/main.c b/main.c index 0c0f8f9..23466fc 100644 --- a/main.c +++ b/main.c @@ -3,41 +3,33 @@ #include #include #include -#include #include 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() { diff --git a/matrix.h b/matrix.h index 2666d32..a0e381a 100644 --- a/matrix.h +++ b/matrix.h @@ -3,8 +3,7 @@ #include -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