-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
159 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule wasm-micro-runtime
updated
6 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
void sgemm(int m, int n, int k, const float *__restrict__ A, const float *__restrict__ B, float *__restrict__ C) { | ||
int i, j, p; | ||
for (i = 0; i < m; i++) { | ||
for (j = 0; j < n; j++) { | ||
float cij = C[i * n + j]; | ||
for (p = 0; p < k; p++) { | ||
cij += A[i * k + p] * B[p * n + j]; | ||
} | ||
C[i * n + j] = cij; | ||
} | ||
} | ||
} | ||
|
||
void init(float *matrix, int row, int column) { | ||
for (int j = 0; j < column; j++) { | ||
for (int i = 0; i < row; i++) { | ||
matrix[j * row + i] = (double)(rand()); | ||
} | ||
} | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
int rowsA, colsB, common; | ||
int i; | ||
|
||
rowsA = 512; | ||
colsB = 512; | ||
common = 512; | ||
|
||
float *A = (float *)malloc(rowsA * common * sizeof(float)); | ||
float *B = (float *)malloc(common * colsB * sizeof(float)); | ||
float *C = (float *)malloc(rowsA * colsB * sizeof(float)); | ||
|
||
init(A, rowsA, common); | ||
init(B, common, colsB); | ||
for (i = 0; i < 10; i++) { | ||
sgemm(rowsA, colsB, common, A, B, C); | ||
} | ||
|
||
printf("%f\n", C[0]); | ||
free(A); | ||
free(B); | ||
free(C); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
|
||
#define N 1000000 | ||
|
||
void vector_add(const float* __restrict__ a, const float * __restrict__ b, float* __restrict__ c) { | ||
for (int i = 0; i < N; i++) { | ||
c[i] = a[i] + b[i]; | ||
} | ||
} | ||
|
||
int main() { | ||
float *a, *b, *c; | ||
a = (float*)malloc(N * sizeof(float)); | ||
b = (float*)malloc(N * sizeof(float)); | ||
c = (float*)malloc(N * sizeof(float)); | ||
|
||
for (int i = 0; i < 10; i++) { | ||
vector_add(a, b, c); | ||
} | ||
|
||
fprintf(stderr, "c[0] = %f\n", c[0]); | ||
|
||
free(a); | ||
free(b); | ||
free(c); | ||
return 0; | ||
} |