-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPyMatMul_C.py
More file actions
32 lines (27 loc) · 750 Bytes
/
PyMatMul_C.py
File metadata and controls
32 lines (27 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import numpy as np
import matmul
import pyextrae.mpi as pyextrae
print('MATRIX MULTIPLICATION (NxN) V0.2')
# Constants
N = 256
TaskMaster = 0
MPIT_MATRIX_A = 2
def wrap_matmul(A, B, chunk):
return matmul.matmul_omp(A, B, chunk)
#return matmul.matmul(A, B, chunk)
# Main
print('Creating matrix...')
A = np.random.randint(10, size=(N, N), dtype='int32')
B = np.random.randint(10, size=(N, N), dtype='int32')
# Matrix Multiplication
print('Multiplying...')
C = wrap_matmul(A, B, A.shape[0])
# Master checks the result
R = np.matmul(A, B)
print('MASTER: Verifying...')
for i in range(N):
for j in range(N):
if (C[i][j] != R[i][j]):
print('WRONG multiplication!')
exit(-1)
print('CORRECT multiplication!')