-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathkblas-test-l3-parallel.py
executable file
·157 lines (132 loc) · 4.22 KB
/
kblas-test-l3-parallel.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import os, sys, getopt
import csv
import time
import commands
import threading
# create output log folder
KBLAS_HOME='.'
TEST_LOGS_PATH='kblas-test-log'
cmd = ('cd '+KBLAS_HOME+'; mkdir -p '+TEST_LOGS_PATH)
print cmd
sys.stdout.flush()
os.system(cmd)
BIN_PATH='./testing/bin/'
if (not os.path.isdir(BIN_PATH)):
print 'Unable to find executables folder! Exiting'
exit()
#detect GPU devices
NGPUS=0
# first check using environment variable
if ( "CUDA_VISIBLE_DEVICES" in os.environ ):
aux=os.environ["CUDA_VISIBLE_DEVICES"].strip(',')
if ( len(aux) > 0):
NGPUS=int( aux.count(',') ) + 1
if ( NGPUS == 0 ):
# check using system
cmd=('nvidia-smi -L | wc -l')
NGPUS = int(commands.getstatusoutput(cmd)[1])
if (NGPUS < 1):
print 'Unable to detect an NVIDIA GPU device to test on! Exiting'
exit()
#set options
#check = ''
check = '-c'
TRMM = 1
TRSM = 1
ranges = ['--range 128:1024:128', #square matrices
'--range 2048:15360:1024 ', #square matrices
#'--mrange 512:15360:512 -n 512 ', #tall & skinny matrices
#'--nrange 512:15360:512 -m 512 ' #thin & wide matrices
]
#--------------------------------
def task1(pVariants, pRanges, pExec, pCheck, pDev, pOutfile):
print 'running: '+pExec+' ... '
os.system('echo running: '+pExec+' > '+pOutfile)
for v in pVariants:
for r in pRanges:
cmd = (pExec+' '+r+' -w --nb 128 --db 256 -t '+pCheck+' --dev '+str(pDev)+' '+v)
os.system('echo >> '+pOutfile)
os.system('echo '+cmd+' >> '+pOutfile)
sys.stdout.flush()
os.system(cmd+' >> '+pOutfile)
time.sleep(1)
print pExec+' done'
#--------------------------------
def launchQueue(*taskQueue):
for t in taskQueue:
t.start()
t.join()
############### TRMM
if (TRMM == 1):
variants = ['-SL -L -NN',
'-SL -L -TN',
'-SL -U -NN',
'-SL -U -TN',
'-SR -L -NN',
'-SR -L -TN',
'-SR -U -NN',
'-SR -U -TN'
]
programs = ['test_strmm', 'test_dtrmm', 'test_ctrmm', 'test_ztrmm', 'test_strmm_cpu', 'test_dtrmm_cpu', 'test_ctrmm_cpu', 'test_ztrmm_cpu']
deviceQueue = [[] for _ in xrange(NGPUS)]
deviceThread = []
dev = 0
for p in programs:
pp = BIN_PATH+p
if (not os.path.isfile(pp)):
print 'Unable to find '+pp+' executable! Skipping...'
else:
logFile = TEST_LOGS_PATH+'/'+p+'.txt'
deviceQueue[dev].append( threading.Thread(target=task1, args=(variants, ranges, pp, check, dev, logFile)) )
dev = (dev+1)%NGPUS
dev = 0
while dev < NGPUS:
q = deviceQueue[dev]
#print q
tq = threading.Thread( target=launchQueue, args=(q) )
deviceThread.append(tq)
tq.start()
dev = dev + 1
dev = 0
while dev < NGPUS:
tq = deviceThread[dev]
tq.join()
dev = dev + 1
############### TRSM
if (TRSM == 1):
variants = ['-SL -L -NN',
'-SL -L -TN',
'-SL -U -NN',
'-SL -U -TN',
'-SR -L -NN',
'-SR -L -TN',
'-SR -U -NN',
'-SR -U -TN'
]
programs = ['test_strsm', 'test_dtrsm', 'test_ctrsm', 'test_ztrsm', 'test_strsm_cpu', 'test_dtrsm_cpu', 'test_ctrsm_cpu', 'test_ztrsm_cpu']
deviceQueue = [[] for _ in xrange(NGPUS)]
deviceThread = []
dev = 0
for p in programs:
pp = BIN_PATH+p
if (not os.path.isfile(pp)):
print 'Unable to find '+pp+' executable! Skipping...'
else:
logFile = TEST_LOGS_PATH+'/'+p+'.txt'
deviceQueue[dev].append( threading.Thread(target=task1, args=(variants, ranges, pp, check, dev, logFile)) )
dev = (dev+1)%NGPUS
dev = 0
while dev < NGPUS:
q = deviceQueue[dev]
#print q
tq = threading.Thread( target=launchQueue, args=(q) )
deviceThread.append(tq)
tq.start()
dev = dev + 1
dev = 0
while dev < NGPUS:
tq = deviceThread[dev]
tq.join()
dev = dev + 1