formatting
This commit is contained in:
parent
2b2ffe9649
commit
c41d130a45
26
main.c
26
main.c
@ -3,41 +3,33 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
void benchmark_gemm() {
|
void benchmark_gemm() {
|
||||||
const uint64_t vertex_count1 = 1024;
|
const uint64_t vertex_count = 100;
|
||||||
uint64_t (*matrix1)[vertex_count1] = malloc(vertex_count1 * vertex_count1 * sizeof(uint64_t));
|
uint64_t adjacency_matrix1[vertex_count][vertex_count];
|
||||||
|
uint64_t adjacency_matrix2[vertex_count][vertex_count];
|
||||||
const uint64_t vertex_count2 = 1024;
|
uint64_t dot_product[vertex_count][vertex_count];
|
||||||
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));
|
|
||||||
|
|
||||||
double elapsed_time = 0.0;
|
double elapsed_time = 0.0;
|
||||||
const uint64_t iterations = 10;
|
const uint64_t iterations = 10;
|
||||||
clock_t start_time;
|
clock_t start_time;
|
||||||
|
|
||||||
for (uint64_t i = 0; i < iterations; i++) {
|
for (uint64_t i = 0; i < iterations; i++) {
|
||||||
random_adjacency(vertex_count1, matrix1);
|
random_adjacency(vertex_count, adjacency_matrix1);
|
||||||
random_adjacency(vertex_count2, matrix2);
|
random_adjacency(vertex_count, adjacency_matrix2);
|
||||||
|
|
||||||
start_time = clock();
|
start_time = clock();
|
||||||
|
|
||||||
gemm_basic(vertex_count1, vertex_count1, matrix1,
|
gemm_basic(vertex_count, vertex_count, adjacency_matrix1,
|
||||||
vertex_count2, vertex_count2, matrix2,
|
vertex_count, vertex_count, adjacency_matrix2,
|
||||||
new_matrix);
|
dot_product);
|
||||||
|
|
||||||
elapsed_time += (double)(clock() - start_time) / CLOCKS_PER_SEC;
|
elapsed_time += (double)(clock() - start_time) / CLOCKS_PER_SEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%lu iterations of gemm_basic took roughly %f seconds\n", iterations, elapsed_time);
|
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);
|
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() {
|
void benchmark_find_components() {
|
||||||
|
19
matrix.h
19
matrix.h
@ -3,8 +3,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
void print_matrix(const uint64_t row_length,
|
void print_matrix(const uint64_t row_length, const uint64_t column_length,
|
||||||
const uint64_t column_length,
|
|
||||||
const uint64_t matrix[row_length][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.
|
restult will be written to output_matrix.
|
||||||
Matrix size requirements are as specified in the parameters.
|
Matrix size requirements are as specified in the parameters.
|
||||||
*/
|
*/
|
||||||
void gemm_basic(const uint64_t row_length1,
|
void gemm_basic(const uint64_t row_length1, const uint64_t column_length1,
|
||||||
const uint64_t column_length1,
|
const uint64_t matrix1[row_length1][column_length1],
|
||||||
const uint64_t matrix1[row_length1][column_length1],
|
const uint64_t row_length2, const uint64_t column_length2,
|
||||||
const uint64_t row_length2,
|
const uint64_t matrix2[row_length2][column_length2],
|
||||||
const uint64_t column_length2,
|
uint64_t output_matrix[row_length1][column_length2]);
|
||||||
const uint64_t matrix2[row_length2][column_length2],
|
|
||||||
uint64_t output_matrix[row_length1][column_length2]);
|
|
||||||
|
|
||||||
int read_csv(char *file_name,
|
int read_csv(char *file_name, uint64_t row_length, uint64_t column_length,
|
||||||
uint64_t row_length,
|
|
||||||
uint64_t column_length,
|
|
||||||
uint64_t output_matrix[row_length][column_length]);
|
uint64_t output_matrix[row_length][column_length]);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user