Previous Peformances tests |
Parent Peformances tests |
Outline | Next Reduction with our intrinsics implementation |
Now, let's write the reductionNumpyPython.py file :
We need also to import several packages :
1 2 3 |
import sys import numpy as np import astericshpc |
1 2 3 4 5 6 7 8 9 10 11 12 |
def getTimeFunctionSize(nbRepetition, nbElement): tabX = np.asarray(np.random.random(nbElement), dtype=np.float32) timeBegin = astericshpc.rdtsc() for i in range(0, nbRepetition): res = tabX.sum() timeEnd = astericshpc.rdtsc() elapsedTime = float(timeEnd - timeBegin)/float(nbRepetition) elapsedTimePerElement = elapsedTime/float(nbElement) print("nbElement =",nbElement,", elapsedTimePerElement =",elapsedTimePerElement,"cy/el",", elapsedTime =",elapsedTime,"cy") print(str(nbElement) + "\t" + str(elapsedTimePerElement) + "\t" + str(elapsedTime),file=sys.stderr) |
1 2 3 |
def makeElapsedTimeValue(listSize, nbRepetition): for val in listSize: getTimeFunctionSize(nbRepetition, val) |
1 2 3 4 5 6 7 |
if __name__ == "__main__": listSize = [ 1024, 2048, 3072, 4992, 10048] makeElapsedTimeValue(listSize, 1000000) |
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 |
''' Auteur : Pierre Aubert Mail : aubertp7@gmail.com Licence : CeCILL-C ''' import sys import numpy as np import astericshpc def getTimeFunctionSize(nbRepetition, nbElement): tabX = np.asarray(np.random.random(nbElement), dtype=np.float32) timeBegin = astericshpc.rdtsc() for i in range(0, nbRepetition): res = tabX.sum() timeEnd = astericshpc.rdtsc() elapsedTime = float(timeEnd - timeBegin)/float(nbRepetition) elapsedTimePerElement = elapsedTime/float(nbElement) print("nbElement =",nbElement,", elapsedTimePerElement =",elapsedTimePerElement,"cy/el",", elapsedTime =",elapsedTime,"cy") print(str(nbElement) + "\t" + str(elapsedTimePerElement) + "\t" + str(elapsedTime),file=sys.stderr) def makeElapsedTimeValue(listSize, nbRepetition): for val in listSize: getTimeFunctionSize(nbRepetition, val) if __name__ == "__main__": listSize = [ 1024, 2048, 3072, 4992, 10048] makeElapsedTimeValue(listSize, 1000000) |
Previous Peformances tests |
Parent Peformances tests |
Outline | Next Reduction with our intrinsics implementation |