On Thu, 2015-09-10 at 11:44 -0700, Lydia Duncan wrote:
> Hi Russel,
> 
> To initialize the runtime for library Chapel (since you've been
> asking 
> about that recently :) ), you would want chpl_library_init, which
> will 
> handle setting up the runtime and the standard modules.  It can be
> found 
> in $CHPL_HOME/runtime/src/chpl-init.c. The comment at the top of the 
> function gives a psuedocode example of its use:

I should perhaps be explicit about what I am doing here so as to give
context!

I want to call Chapel code from Python code in the same way I can call
C++ or D code. I have two modes of use: 1. call into a shared object /
dynamic link library that exposes C linkage entry points using CFFI as
the bridge; and 2. create a fully compiled Python extension so as to
call in directly.

I believe, but haven't checked yet, that PyChapel can do 2 – I have to
admit I am not a fan of using comments to embed Chapel code into Python
code, very hard to edit and maintain the Chapel code. I know PuCUDA and
PyOpenCL support this model, I am not keen on it there either! Rather I
prefer to have Chapel and OpenCL code in separate files and have a more
explicit compilation and linking activity.

As my questions have hinted I am currently trying to do 1, from a
Chapel library with C linkage exports use CFFI to make calls from
Python.

This is all for my PyConUK 2016 session, 2015-09-18T16:30+01:00. I
shall "slag off" computation in pure Python, Cython, and possibly
Numba. I shall do something similar for NumPy. The idea then is to get
people more interested in being polyglot by showing C++ and D. D beats
C++ because it has proper support for concurrency and parallelism. Then
the idea what to get Chapel involved because it is PGAS.

The overall plot here is "Python for coordination, native code for
computation."

This may not go down well. It was something of a difficult "sell" at
PyData London 2015 earlier this year. Data science folk aren't really
interested in polyglot, it is one of Matlab, R,
Python/SciPy/Pandas/Matplotlib. Sadly whilst NumPy is a good thing
generally, it really isn't up to doing seriously hardcore parallel
computation.

> int main(int argc, char* argv) {
> chpl_library_init(...)

This implies I need a C proxy to initialize the Chapel runtime system
prior to running Chapel code. GIven I have C linkage Chapel entry
points, can the calls be in what is supposed to be Chapel code?

This initialization function doesn't seem to be included in the Chapel
compilation by default. I shall hunt out the document Brad referred to
and do more research…

I am hoping just to have Python and Chapel code without extra C code
over and above the CFFI stuff.

> chpl__init_MODULE_1(LINE, FILENAME)
>    ...
> chpl__init_MODULE_N(LINE, FILENAME)
> 
> call_chapel_function_from_MODULE_1()
>    ...
> call_chapel_function_from_MODULE_N()
> 
> chpl_library_finalize()
> }

I am guessing that solving chpl_library_init isue will solve this one :
-)

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:[email protected]
41 Buckmaster Road    m: +44 7770 465 077   xmpp: [email protected]
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

Attachment: signature.asc
Description: This is a digitally signed message part

------------------------------------------------------------------------------
_______________________________________________
Chapel-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-users

Reply via email to