PLASMA  2.4.5
PLASMA - Parallel Linear Algebra for Scalable Multi-core Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
plasma_testing.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 
5 ###############################################################################
6 # plasma_testing.py [nbcores]
7 # nbcores is a optional argument to give the number of cores to run the testing
8 # Example:
9 # ./plasma_testing.py
10 # No argument, so will run on half of the core if the machine has more than 2 cores
11 # ./plama_testing.py nbcores
12 # Will run on nbcores
13 ###############################################################################
14 
15 from subprocess import Popen, STDOUT, PIPE
16 import os, sys, math
17 import getopt
18 
19 # Linux Unix and MacOS:
20 if hasattr(os, "sysconf"):
21  if os.sysconf_names.has_key("SC_NPROCESSORS_ONLN"):
22  ncpus_av = os.sysconf("SC_NPROCESSORS_ONLN")
23 # Windows:
24 if os.environ.has_key("NUMBER_OF_PROCESSORS"):
25  ncpus_av = int(os.environ["NUMBER_OF_PROCESSORS"]);
26 
27 # we are going to run on half of the cores by default if we have more than 2 cores
28 if (ncpus_av > 2):
29  ncpus=int(math.floor(ncpus_av/2))
30 else:
31  ncpus=ncpus_av
32 
33 try:
34  opts, args = getopt.getopt(sys.argv[1:], "hnc:s:",
35  ["help", "cores=", "sched="])
36 
37 except getopt.error, msg:
38  print msg
39  print "for help use --help"
40  sys.exit(2)
41 
42 # process options
43 sched=0;
44 execution=1;
45 
46 for o, a in opts:
47  if o in ("-h", "--help"):
48  print sys.argv[0]+" [-h|--help] [-c n|--cores=n] [-s s|--sched=s]"
49  print " -c Fix the number of cores"
50  print " -s Specify the scheduling mode: 0 for static, 1 for dynamic"
51  print " -n Print the commands only"
52  sys.exit(0)
53  else:
54  if o in ( '-c', '--ncores' ):
55  ncpus = a
56  elif o in ( '-s' , '--sched' ):
57  if a == "0" :
58  sched = 0
59  else:
60  sched = 1
61  elif o in ( '-n' , '--noexec' ):
62  execution=0
63 
64 # Add current directory to the path for subshells of this shell
65 # Allows the popen to find local files in both windows and unixes
66 os.environ["PATH"] = os.environ["PATH"]+":."
67 
68 # Define a function to open the executable (different filenames on unix and Windows)
69 def local_popen( f, cmdline ):
70  if os.name != 'nt':
71  cmdline="./" + cmdline
72 
73  if execution==0:
74  print cmdline
75  else:
76  p=Popen( cmdline, shell=True, stdout=PIPE, stderr=STDOUT )
77 
78  r=p.poll()
79  while r == None:
80  r=p.poll()
81  pipe=p.stdout
82 
83  if r != 0:
84  print "---- TESTING " + cmdline.split()[3] + "... FAILED(" + str(p.returncode) +") !"
85  for line in pipe.readlines():
86  f.write(str(line))
87  else:
88  found=0
89  for line in pipe.readlines():
90  f.write(str(line))
91  if "TESTING" in line :
92  found = 1
93  print line,
94  if found == 0:
95  print cmdline.split()[0] + " " + cmdline.split()[3] + ": FAILED(Unexpected error)"
96 
97  f.flush();
98  return 0
99 
100 
101 # If filename cannot be opened, send output to sys.stderr
102 filename = "testing_results.txt"
103 try:
104  f = open(filename, 'w')
105 except IOError:
106  f = sys.stdout
107 
108 print " "
109 print "---------------- Testing PLASMA Routines ----------------"
110 print " "
111 print "-- Number of cores available =", ncpus_av
112 print "-- Number of cores used for testing =", ncpus
113 print "-- Detailed results are stored in", filename
114 print "-- Scheduling mode: ",
115 if (sched == 0):
116  print "Static"
117 else:
118  print "Dynamic"
119 
120 dtypes = (
121 ("s", "d", "c", "z"),
122 ("Single", "Double", "Complex", "Double Complex"),
123 )
124 
125 for dtype in range(4):
126  letter = dtypes[0][dtype]
127  name = dtypes[1][dtype]
128 
129  print " "
130  print "--------------------- In Place Transformation -------------------"
131  print " "
132  sys.stdout.flush()
133 
134  cmdbase="%stesting " % letter + str(ncpus) + " " + str(sched)
135 
136  test01=local_popen(f, cmdbase + " GECFI" + " 623 531 123 145 136 134")
137  test02=local_popen(f, cmdbase + " GETMI" + " 623 531 123 145")
138 
139  print " "
140  print "------------------------- %s ------------------------" % name
141  print " "
142  sys.stdout.flush()
143 
144  test0 = local_popen(f, cmdbase + " LANGE" + " 914 510 950")
145  test1 = local_popen(f, cmdbase + " GEMM" + " 1.0 -2.0 600 500 550 650 625 700")
146  test2 = local_popen(f, cmdbase + " TRSM" + " -2.0 600 500 650 625")
147  test3 = local_popen(f, cmdbase + " TRMM" + " -2.0 600 500 650 625")
148  test4 = local_popen(f, cmdbase + " SYMM" + " 1.0 -2.0 600 500 650 625 700")
149  test5 = local_popen(f, cmdbase + " SYRK" + " 1.0 -2.0 600 500 650 625")
150 
151  if letter in ( "c", "z" ) :
152  test101 = local_popen(f, "%stesting " % letter + str(ncpus) + " " + str(sched) + " HEMM" + " 1.0 -2.0 600 500 650 625 600")
153  test102 = local_popen(f, "%stesting " % letter + str(ncpus) + " " + str(sched) + " HERK" + " 1.0 -2.0 600 500 650 625")
154 
155  test20 = local_popen(f, cmdbase + " POSV" + " 500 600 25 700")
156  test21 = local_popen(f, cmdbase + " POTRI" + " 500 600")
157  test22 = local_popen(f, cmdbase + " GELS" + " 0 800 400 825 25 810")
158  test23 = local_popen(f, cmdbase + " GELS" + " 1 800 400 825 25 810 4")
159  test24 = local_popen(f, cmdbase + " GELS" + " 0 400 800 825 25 810")
160  test25 = local_popen(f, cmdbase + " GELS" + " 1 400 800 825 25 810 4")
161  test26 = local_popen(f, cmdbase + " GESV" + " 800 825 25 810")
162  test27 = local_popen(f, cmdbase + " GETRI" + " 800 825")
163  test28 = local_popen(f, cmdbase + " GESVD" + " 0 825 800 855")
164  test29 = local_popen(f, cmdbase + " GESVD" + " 0 800 825 810")
165  test30 = local_popen(f, cmdbase + " HEGV" + " 800 825 810")
166  test31 = local_popen(f, cmdbase + " HEEV" + " 800 825")
167  test32 = local_popen(f, cmdbase + " HEGST" + " 800 825 810")
168  sys.stdout.flush()
169 
170 print " "
171 print "--------------------- Mixed Precision -------------------"
172 print " "
173 
174 for substr in ( ("z", "C"), ("d", "S") ):
175  cmdbase="%stesting " % substr[0] + str(ncpus) + " " + str(sched)
176 
177  test201 = local_popen(f, cmdbase + " %sGESV" % substr[1] + " 800 825 25 810")
178  test202 = local_popen(f, cmdbase + " %sUNGESV" % substr[1] + " 800 825 25 810")
179  test203 = local_popen(f, cmdbase + " %sPOSV" % substr[1] + " 800 825 25 810")
180  sys.stdout.flush()
181 
182 
183 
184 # This may close the sys.stdout stream, so make it the last statement
185 f.close()