RRZE-HPC / stempel

Stencil TEMPlate Engineering Library
GNU Affero General Public License v3.0
6 stars 2 forks source link

How to run in bench mode? #22

Closed cod3monk closed 7 years ago

cod3monk commented 7 years ago

I tried to run stempe.pyl bench according to README with the code generated from python stempel.py gen -D 3 -r 2 -s -i, but it fails parsing(?):

$ python stempel.py bench code.c  -m ../../kerncraft/examples/machine-files/SandyBridgeEP_E5-2680.yml
WARNING: yacc table file version is out of date
Traceback (most recent call last):
  File "stempel.py", line 457, in <module>
    main()
  File "stempel.py", line 454, in main
    args.func(args, parser)
  File "stempel.py", line 421, in run_bench
    c_code = kernel.as_code()
  File "/Users/codemonk/Development/stempel/stempel/benchkernel.py", line 784, in as_code
    mystring = str("size: %d    time: %lf    iter: %d    MLUP/s: %lf\n").encode('string_escape')
LookupError: unknown encoding: string_escape
$

Here is the code.c file I generated:

$ cat code.c
double a[M][N][P];
double b[M][N][P];
double c0;
double c1;
double c2;

for(int k=2; k < M-2; k++)
for(int j=2; j < N-2; j++)
for(int i=2; i < P-2; i++)
b[k][j][i] = c0 * a[k][j][i]
+ c1 * ((a[k][j][i-1] + a[k][j][i+1]) + (a[k-1][j][i] + a[k+1][j][i]) + (a[k][j-1][i] + a[k][j+1][i]))
+ c2 * ((a[k][j][i-2] + a[k][j][i+2]) + (a[k-2][j][i] + a[k+2][j][i]) + (a[k][j-2][i] + a[k][j+2][i]))
;
$
sguera commented 7 years ago

Hi, I added the machine file as a parameter and forgot to update the example line. Something like this should work: python stempel.py bench 2d-5pt-iso-sym-var.c -m BroadwellEP_E5-2697_CoD.yml

The reason I did that is that I wanted some info from the machine file in case we need to compile directly the code. I am not sure if it is really needed so far, anyway it is like that now. What I realized is that I get an error while using a piece of code taken by kerncraft: compiler_args = self._machine.get_compiler() resulting in an AttributeError: 'MachineModel' object has no attribute 'get_compiler' but MachineModel is imported from kerncraft. Any idea?

cod3monk commented 7 years ago

I already had the machine file in the arguments. I now tried with your Broadwell example, but the same problem persists:

$ python stempel.py bench code.c -m BroadwellEP_E5-2697_CoD.yml
WARNING: yacc table file version is out of date
Traceback (most recent call last):
  File "stempel.py", line 458, in <module>
    main()
  File "stempel.py", line 455, in main
    args.func(args, parser)
  File "stempel.py", line 422, in run_bench
    c_code = kernel.as_code()
  File "/Users/codemonk/Development/stempel/stempel/benchkernel.py", line 784, in as_code
    mystring = str("size: %d    time: %lf    iter: %d    MLUP/s: %lf\n").encode('string_escape')
LookupError: unknown encoding: string_escape
$

Are you using an a Kerncraft version prior to v0.5.0? That feature was introduced by RRZE-HPC/kerncraft@a1d32ea2642f05365e58778a1975e5a8a704fdef

cod3monk commented 7 years ago

By replacing string_escape (which is no longer supported in python3) with unicode_escape, a code is printed.

sguera commented 7 years ago

I misread your error. You get it because of the ".encode('string_escape')" that I use, which works for python 2.7. I guess you use Python 3 where the string_escape encoding is called unicode_escape.

sguera commented 7 years ago

Ok, using unicode_escape works also for Python 2.7.

I'll change it to unicode_escape, which fixes the issue.

Thanks

sguera commented 7 years ago

Fixed in https://github.com/RRZE-HPC/stempel/commit/d2630a47db4b326c51e351bd0db7f7b57cfa3198

cod3monk commented 7 years ago

Issue persists:


$ python stempel.py bench code.c -m BroadwellEP_E5-2697_CoD.yml -b 32
WARNING: yacc table file version is out of date
foo
Traceback (most recent call last):
  File "stempel.py", line 457, in <module>
    main()
  File "stempel.py", line 454, in main
    args.func(args, parser)
  File "stempel.py", line 421, in run_bench
    c_code = kernel.as_code()
  File "/Users/codemonk/Development/stempel/stempel/benchkernel.py", line 799, in as_code
    mystring = mystring.encode('string_escape')
LookupError: unknown encoding: string_escape
$
sguera commented 7 years ago

sorry, there was another place where string_escape was called. Changed it to unicode_escape. Should be fine now

sguera commented 7 years ago

Going back to the other issue, once downloaded the new version of kerncraft, the call to machine.get_compiler() fails due to:

compiler, compiler_args = self._machine.get_compiler() File "/Applications/anaconda/lib/python2.7/site-packages/kerncraft/machinemodel.py", line 140, in get_compiler for c in self['compiler'].keys(): AttributeError: 'str' object has no attribute 'keys'

sguera commented 7 years ago

It worked now, so the issue is somehow solved

cod3monk commented 7 years ago

The second problem was due to the old machine description format, which changed along side with the introduction of get_compiler()