rename matrix_multiply_basic to gemm_basic
This commit is contained in:
parent
d8c3a75d50
commit
16274d2a98
2
graph.c
2
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++) {
|
for(uint64_t k = 2; k <= vertex_count; k++) {
|
||||||
copy(vertex_count, vertex_count, power_matrix, temp_power_matrix);
|
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 row_index = 0; row_index < vertex_count; row_index++) {
|
||||||
for (uint64_t column_index = 0; column_index < vertex_count; column_index++) {
|
for (uint64_t column_index = 0; column_index < vertex_count; column_index++) {
|
||||||
|
15
main.c
15
main.c
@ -7,9 +7,6 @@
|
|||||||
|
|
||||||
void benchmark() {
|
void benchmark() {
|
||||||
const uint64_t vertex_count1 = 1024;
|
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));
|
uint64_t (*matrix1)[vertex_count1] = malloc(vertex_count1 * vertex_count1 * sizeof(uint64_t));
|
||||||
|
|
||||||
const uint64_t vertex_count2 = 1024;
|
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));
|
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 = 1;
|
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++) {
|
||||||
@ -27,15 +24,15 @@ void benchmark() {
|
|||||||
|
|
||||||
start_time = clock();
|
start_time = clock();
|
||||||
|
|
||||||
matrix_multiply_basic(vertex_count1, vertex_count1, matrix1,
|
gemm_basic(vertex_count1, vertex_count1, matrix1,
|
||||||
vertex_count2, vertex_count2, matrix2,
|
vertex_count2, vertex_count2, matrix2,
|
||||||
new_matrix);
|
new_matrix);
|
||||||
|
|
||||||
elapsed_time += (double)(clock() - start_time) / CLOCKS_PER_SEC;
|
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("%lu iterations of gemm_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("An iteration of gemm_basic took on average roughly %f seconds\n", elapsed_time/iterations);
|
||||||
|
|
||||||
free(matrix1);
|
free(matrix1);
|
||||||
free(matrix2);
|
free(matrix2);
|
||||||
@ -62,6 +59,6 @@ void test() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
test();
|
// test();
|
||||||
// benchmark();
|
benchmark();
|
||||||
}
|
}
|
||||||
|
2
matrix.c
2
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],
|
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]) {
|
uint64_t output_matrix[row_length1][column_length2]) {
|
||||||
|
|
||||||
|
2
matrix.h
2
matrix.h
@ -13,7 +13,7 @@ void print_matrix(const uint64_t row_length,
|
|||||||
Matrix requirements are as specified in the parameters.
|
Matrix requirements are as specified in the parameters.
|
||||||
Function return 0 on success and 1 on failure.
|
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 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 row_length2,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user