2525# THE POSSIBILITY OF SUCH DAMAGE.
2626# *****************************************************************************
2727
28- """Example 1 .
28+ """Example 7 .
2929
3030This example shows simple usage of the DPNP
3131to calculate square matrix multiplication
3535
3636"""
3737
38-
39- try :
40- import dpnp
41- except ImportError :
42- import os
43- import sys
44-
45- root_dir = os .path .join (os .path .dirname (__file__ ), os .pardir )
46- sys .path .append (root_dir )
47-
48- import dpnp
49-
5038import time
5139
40+ import dpctl
5241import numpy
5342
43+ import dpnp
44+
5445
5546def run_function (executor , name , size , test_type , repetition ):
5647 x = executor .reshape (
@@ -69,15 +60,23 @@ def run_function(executor, name, size, test_type, repetition):
6960 return execution_time , result
7061
7162
63+ def get_dtypes ():
64+ _dtypes_list = [numpy .int32 , numpy .int64 , numpy .float32 ]
65+ device = dpctl .select_default_device ()
66+ if device .has_aspect_fp64 :
67+ _dtypes_list .append (numpy .float64 )
68+ return _dtypes_list
69+
70+
7271if __name__ == "__main__" :
7372 test_repetition = 5
74- for test_type in [ numpy . float64 , numpy . float32 , numpy . int64 , numpy . int32 ] :
73+ for test_type in get_dtypes () :
7574 type_name = numpy .dtype (test_type ).name
7675 print (
7776 f"...Test data type is { test_type } , each test repetitions { test_repetition } "
7877 )
7978
80- for size in [16 , 32 , 64 , 128 , 256 , 512 , 1024 , 2048 , 4096 ]:
79+ for size in [256 , 512 , 1024 , 2048 , 4096 , 8192 ]:
8180 time_python , result_python = run_function (
8281 numpy , "<NumPy>" , size , test_type , test_repetition
8382 )
@@ -90,6 +89,6 @@ def run_function(executor, name, size, test_type, repetition):
9089 else :
9190 verification = f"({ result_mkl } != { result_python } )"
9291
93- msg = f"type:{ type_name } :N:{ size :4} :NumPy:{ time_python :.3e} :SYCL :{ time_mkl :.3e} "
92+ msg = f"type:{ type_name } :N:{ size :4} :NumPy:{ time_python :.3e} :DPNP :{ time_mkl :.3e} "
9493 msg += f":ratio:{ time_python / time_mkl :6.2f} :verification:{ verification } "
9594 print (msg )
0 commit comments