Skip to content

Conversation

@simonius
Copy link

@simonius simonius commented Oct 5, 2018

This is a alpha of the Python backend. It uses PyOpenCl as OpenCL interface and should work like the normal MatLab backend, but with a device selection menu. Only the SSPRK33 timeintegrator is ready and all extras like divergence cleaning and artificial dissipation are missing. I plan to split InductionEq.py into several Files as a next assignment.

@ranocha
Copy link
Member

ranocha commented Oct 9, 2018

I will have a look at this in this week.

if I_Tech['REAL'] == 'float':
field_u_init = np.zeros((4, I_Tech['num_nodes_pad']), dtype=np.float32)
field_b_init = np.zeros((4, I_Tech['num_nodes_pad']), dtype=np.float32)
field_rho_init = np.zeros((1, I_Tech['num_nodes_pad']), dtype=np.float32)+1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np.ones

Copy link
Member

@ranocha ranocha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use either spaces (preferred) or tabs.

I_Mesh['DX'] = DX; I_Mesh['DY'] = DY; I_Mesh['DZ'] = DZ;
num_nodes = I_Mesh['NODES_X']*I_Mesh['NODES_Y']*I_Mesh['NODES_Z'];

# later ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

'L2error_B': L2error_B, \
'L2error_divB': L2error_divB}
else:
print('Wrong value of time_integrator_num_fields =' + str( time_integrator_num_fields))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should throw an exception.

python/cl.py Outdated
global program, ctx
src = ' '
for entry in src_path:
file = open(entry, 'r')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to use something along the lines of

with open( entry, 'r') as io:
  src = src + io.read()

#variables, e.g. stepsize, timestep, local work group size, etc...
(field_b_init, field_u_init, field_rho_init) = induction_eq.initialize();

print('Testcase: ' + I_RunOps['testcase'] +'\n')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since python3 adds a newline for every print, the \n is not necessary.

@ranocha
Copy link
Member

ranocha commented Oct 9, 2018

You seem to use python3 (python2 does not work for me). This should be indicated somehow, e.g. by throwing an exception if python2 is used.

@ranocha
Copy link
Member

ranocha commented Oct 9, 2018

The temporary python files should be added to .gitignore.

@ranocha
Copy link
Member

ranocha commented Oct 9, 2018

The comments above are just some random thoughts I had while reading the code.

@ranocha
Copy link
Member

ranocha commented Oct 9, 2018

The semicolons are superflous and ugly (at least for me).

@ranocha
Copy link
Member

ranocha commented Oct 9, 2018

During some simple tests, there are no segfaults for me on an NVidia GPU but on an Intel CPU:

double free or corruption (!prev)
Aborted (core dumped)

This seems to be due to up to now hardcoded choice of some parameters.

@ranocha
Copy link
Member

ranocha commented Oct 9, 2018

There are also some differences in the results (divergence norm, total energy, relative error) of the python version and the matlab version (starting at the first or second significant digit). This is a bit strange since we didn't experience such differences with various hardware and software configurations before, both for matlab and julia.

@ranocha ranocha requested a review from Kostaszki October 9, 2018 17:33
…ts#33. Added the timer and OpenCl device querry from the matlab version. found a bug from Fortran vs C array indexing
@simonius
Copy link
Author

I changed most things, but the Python2 exception doesn't work because the interpreter crashes too early. I think i found the bug which changed the results. The calculation of DT gave different results on different machines because i didn't know that Matlab uses Fortran and one based indexing

@ranocha
Copy link
Member

ranocha commented Oct 11, 2018

I changed most things, but the Python2 exception doesn't work because the interpreter crashes too early. I think i found the bug which changed the results. The calculation of DT gave different results on different machines because i didn't know that Matlab uses Fortran and one based indexing

This sounds good. I will test it later. Since this PR is mainly used by you, you can simply stick to python3 and everything is fine.

@ranocha
Copy link
Member

ranocha commented Oct 11, 2018

The errors seem to fit now (only the last ~5 digits are different).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants