Jack and Michael --- Thanks for your comments. I would like to first point out that our interest in Elemental stems from a DARPA project that is required to be open-sourced; so, anything we do/discuss would benefit the community at-large. Here are my thoughts:
(1) Like Elemental, our library --- skylark --- is implemented using templated C++. We provide a comprehensive python interface using boost::python. We would like to have the ability to talk to the same Elemental data structures in *both* the python and the C++ layers seamlessly. To give you an example of what I mean by this, consider an operator skylark::foo_t that is templated on a MatrixType.
namespace skylark {
// Fully generic implementation
template <typename MatrixType>
struct foo_t {
typedef MatrixType matrix_type;
void bar(const matrix_type& A) { ... }
};
// Specialization for elem::DistMatrix<double, VR, STAR>
template <>
struct foo_t <elem::DistMatrix<double, VR, STAR> > {
typedef elem::DistMatrix<double, VR, STAR> matrix_type;
void bar(const matrix_type& A) { ... }
};
}
We now expose the specialization in python using using boost::python, which looks somewhat like this:
// add boiler-plate code
typedef skylark::foo_t<elem::DistMatrix<double, VR, STAR> > foo_DistMatrix_VR_STAR_t;
boost::python::class_<foo_DistMatrix_VR_STAR_t>("foo_DistMatrix_VR_STAR", init<...>())
.def ("bar", &foo_DistMatrix_VR_STAR_t::bar, ...);
Now, the skylark python type "foo_DistMatrix_VR_STAR" can be instantiated in python. To call "foo_DistMatrix_VR_STAR.bar()" in python, the user would have to create a "elem::DistMatrix_VR_STAR" *python* object and then pass object as the argument to "foo_DistMatrix_VR_STAR.bar()". However, for this scheme to work, the "elem::DistMatrix_VR_STAR" python interface should be type preserving. IMHO, this is not possible if the Elemental's python interface is facilitated by ctypes (we have tried it). I might be completely wrong about this; so please correct me if I am wrong. I think that researchers would benefit greatly from having access to Elemental's full functionality in a first-class manner. I suspect that we are not the only C++-based python library that wants to consume Elemental objects in python, then pass them through to our C++ backend and expect to have some type information. Although I am not advocating that everyone switch to using boost::python, I am hoping that any reasonable approach for proving a python interface to a C++ library will preserve types. In fact, we are open to suggestions ourselves.
(2) We decided to use boost::python for many reasons --- I'll try to remember a few here: (a) the boost community has an excellent track-record of providing high-quality implementations; of these, boost::python is one of the premier libraries, (b) as boost::python is completely based in C++, it will always support advanced generic programming paradigms; I have been made aware of shortcomings of python based approaches such as SWIG w.r.t handling templates (which scares me immensely), and (c) creating boost::python interfaces to skylark was *very* trivial; once we put down some boiler-plate code, it was a matter of mostly cutting and pasting and changing variable names here and there (especially if you can manage to write some basic preprocessor macros).
(3) Michael mentions a very important point about having a python-native interface. I agree with him in that a boost::python-based one-to-one mapping to python of a C++ library is *not* going to attract many python users. Our solution to this is exactly what he suggested in his email! (a) We have a boost::python layer that is excellent at supporting all the programming paradigms we use and provides a one-to-one mapping of the C++-library's functionality in python and (b) A thin *python* interface layer that sits on top of our boost::python layer that makes our library more consumable to python users. An additional benefit of this approach would be that the python interface is resistant to changes in the C++ backend. Also, typically, people like me who are developing (a) are *not* be experts in python, so as long as (b) is independent of (a), we're happy :-).
My personal knowledge of python is both bare minimal and very recently acquired. I would like to hear others' thoughts on how to go about doing this. Yves --- who is copied in this mail --- pointed out today that there *might* be a way to use boost::python with ctypes. I am pasting his email here:
"It seems the only way is to use boost python to import the ctypes module (boost::python::import("ctypes")) and then do all the type conversations. If I understand boost python correctly boost::python::to_python_converter does something similar. This is not a very elegant solution ...".
As Jack mentioned, we want to have a solution that not just works for Elemental + skylark, but potentially with any library that has the same structure as Elemental/skylark. I apologize if I repeated some of the things that Jack and Michael mentioned earlier in their mails.
I usually advise people to stay away from any large library they don't need, elemental currently has no dependency on boost...
This is a very good point. Skylark has bought into boost, but Elemental has no dependency (yet). The way I look at it, we have to add a dependency one way or the other. What would be really nice is if --- regardless of the choice of cython or boost::python --- our python and C++ layers could interact like I pointed out in my first email. While it would be nice to agree to a common solution, we shouldn't have to enforce any single solution. Of course, I am still partial to boost::python as I am apprehensive about cython supporting modern C++ features both as of today and moving forward :-). Any thoughts?
- Anju
--------------------------------------------
Prabhanjan Kambadur
Research Staff Member
Business Analytics and Mathematical Sciences
IBM TJ Watson Research Center
Room 30-229 A
Andy Ray Terrel ---03/29/2013 08:51:42 AM---Hey guys, At the very least can we include Jack on the non mailing list version of
| Andy Ray Terrel <andy....@gmail.com> |
| ANJU KAMBADUR/Watson/IBM@IBMUS, Jack Poulson <jack.p...@gmail.com> |
| Aron Ahmadia <aron.a...@gmail.com>, "barry...@gtri.gatech.edu" <barry...@gtri.gatech.edu>, Dag Sverre Seljebotn <d.s.se...@astro.uio.no>, "Michael C. Grant" <m...@cvxr.com>, "richar...@gtri.gatech.edu Boyd" <richar...@gtri.gatech.edu>, Travis Oliphant <tra...@continuum.io>, Vikas Sindhwani/Watson/IBM@IBMUS, Yves Ineichen1 <ZRL...@ch.ibm.com> |
| 03/29/2013 08:51 AM |
| Re: Python interface to Elemental |
- Anju
--------------------------------------------
Prabhanjan Kambadur
Research Staff Member
Business Analytics and Mathematical Sciences
IBM TJ Watson Research Center
Room 30-229 A
Andy Ray Terrel ---03/29/2013 07:16:05 AM---On Fri, Mar 29, 2013 at 8:55 AM, Michael C. Grant <m...@cvxr.com> wrote: > Andy,
| Andy Ray Terrel <andy....@gmail.com> |
| "Michael C. Grant" <m...@cvxr.com> |
| Vikas Sindhwani/Watson/IBM@IBMUS, ANJU KAMBADUR/Watson/IBM@IBMUS, Aron Ahmadia <aron.a...@gmail.com>, "barry...@gtri.gatech.edu" <barry...@gtri.gatech.edu>, Dag Sverre Seljebotn <d.s.se...@astro.uio.no>, "richar...@gtri.gatech.edu Boyd" <richar...@gtri.gatech.edu>, Yves Ineichen1 <ZRL...@ch.ibm.com>, Travis Oliphant <tra...@continuum.io> |
| 03/29/2013 07:16 AM |
| Re: Python interface to Elemental |
-- Andy
>
> On Mar 29, 2013, at 8:42 AM, Andy Ray Terrel <andy....@gmail.com>
> wrote:
>> On Fri, Mar 29, 2013 at 8:11 AM, Michael C. Grant <m...@cvxr.com> wrote:
>>> Good idea. Andy Terrel is affiliated with Continuum, so he might already be
>>> aware ;) But I will let him know.
>>>
>>> On Mar 29, 2013, at 8:00 AM, "Vikas Sindhwani" <vsi...@us.ibm.com> wrote:
>>>
>>> Michael:
>>>
>>> Since Travis Oliphant (Continuum Analytics) is also working on XDATA, it
>>> would really make sense to alert them of this thread. I am sure they must
>>> have given these general issues a lot of thought and it would be great to
>>> see what they have to say, and where they intend to take numpy/scipy in
>>> terms of distributed computing and interfacing with C/C++ libraries.
>>>
>>> best,
>>> Vikas
>>>
>>> -----"Michael C. Grant" <m...@cvxr.com> wrote: -----
>>> To: ANJU KAMBADUR/Watson/IBM@IBMUS
>>> From: "Michael C. Grant" <m...@cvxr.com>
>>> Date: 03/29/2013 08:52AM
>>> Cc: Andy Terrel <andy....@gmail.com>, Aron Ahmadia
>>> <aron.a...@gmail.com>, "barry...@gtri.gatech.edu"
>>> <barry...@gtri.gatech.edu>, Dag Sverre Seljebotn
>>> <d.s.se...@astro.uio.no>, "richar...@gtri.gatech.edu Boyd"
>>> <richar...@gtri.gatech.edu>, Vikas Sindhwani/Watson/IBM@IBMUS, "Yves
>>> Ineichen1" <ZRL...@ch.ibm.com>
>>> Subject: Re: Python interface to Elemental
>>>
>>> Anju, Thanks for the comments. I don't think I'll respond yet because 1) I
>>> really have nothing to disagree with and 2) I want to hear from folks who
>>> might have experience with other C++/Python interfaces.
>>>
>>> For everyone: may I suggest that if you intend to offer comments, *please
>>> join the elemental-dev Google Group first*. That way, your reply will be
>>> distributed to the rest of the group and archived. Anju's post seems not to
>>> have been posted there, and I think that's the reason why.
>>>
>>> I purposefully left elemental-dev off of this email, so please DO NOT REPLY
>>> to this one to add your points about Elemental & Python. Thanks!
>>>
>>> Michael
>
Hey Michael ---
You bring out excellent points; I think the purpose of this discussion is mostly to give Jack additional information so that he can take a decision (hopefully soon) about what he wants to support. Once Jack fixes what the *official* support for python bindings is going to be, we can either decide to contribute to that effort or decide to maintain a separate set of bindings outside the trunk. Given most of our time constraints and that Elemental is itself in flux, it makes sense to contribute to the *official* effort, which is my personal opinion.
Regarding SWIG:
There are several internet forums dealing with the "SWIG vs boost::python", "Cython vs boost::python", etc debates. There is no hard and fast rule about which one approach to pick. I've already stated the reasons why I think boost::python might be a better choice. I am willing to contribute a small "first-cut" prototype of the boost::python-based bindings for Elemental in the next few days if people are interested in seeing how this might look like. A similar effort by the SWIG-lovers might help Jack (and us) make up our minds.
Regarding making approaches independent:
(Repeated) There is another parallel issue at stake here. Let's say Elemental decides to use SWIG (noooooo :)); this might force budding libraries --- like ours --- to move over to SWIG as well. Now say that there is a rogue C++ library --- Satan --- that refuses to switch to SWIG and insists on using boost::python (or something else for that matter). But Satan is a very powerful library and it would be nice to not antagonize it. There should theoretically be a way for Satan's python bindings to interact freely with Elemental's python and C++ bindings.
- Anju
--------------------------------------------
Prabhanjan Kambadur
Research Staff Member
Business Analytics and Mathematical Sciences
IBM TJ Watson Research Center
Room 30-229 A
"Michael C. Grant" ---03/29/2013 10:01:03 AM---I think there are a couple issues here that might be worth separating---or at least talking about se
|
"Michael C. Grant" <m...@cvxr.com> |
| ANJU KAMBADUR/Watson/IBM@IBMUS |
| Andy Ray Terrel <andy....@gmail.com>, Aron Ahmadia <aron.a...@gmail.com>, "barry...@gtri.gatech.edu" <barry...@gtri.gatech.edu>, Dag Sverre Seljebotn <d.s.se...@astro.uio.no>, Jack Poulson <jack.p...@gmail.com>, "richar...@gtri.gatech.edu Boyd" <richar...@gtri.gatech.edu>, "Travis Oliphant" <tra...@continuum.io>, Vikas Sindhwani/Watson/IBM@IBMUS, "Yves Ineichen1" <ZRL...@ch.ibm.com>, "<elemen...@googlegroups.com>" <elemen...@googlegroups.com> |
| 03/29/2013 10:01 AM |
| [elemental] Re: Python interface to Elemental |
| elemen...@googlegroups.com |
) does it. It seems to be quite a comfortable arrangement to have a separate Python package.
--
You received this message because you are subscribed to the Google Groups "elemental-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elemental-de...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Just for the record, I have no qualms with there being several different Python interfaces in the official repo, I just think that it isn't the best use of everyone's time.If anyone sends a patch with a reasonably useful implementation, I will happily accept it. All that I ask is that, if there is an added dependency (e.g., boost or Cython), that the patch also include the necessary CMake code to make sure the module is only built if the dependency is met.
Jack
Hey Michael ---
You bring out excellent points; I think the purpose of this discussion is mostly to give Jack additional information so that he can take a decision (hopefully soon) about what he wants to support. Once Jack fixes what the *official* support for python bindings is going to be, we can either decide to contribute to that effort or decide to maintain a separate set of bindings outside the trunk. Given most of our time constraints and that Elemental is itself in flux, it makes sense to contribute to the *official* effort, which is my personal opinion.
Regarding SWIG:
There are several internet forums dealing with the "SWIG vs boost::python", "Cython vs boost::python", etc debates. There is no hard and fast rule about which one approach to pick. I've already stated the reasons why I think boost::python might be a better choice. I am willing to contribute a small "first-cut" prototype of the boost::python-based bindings for Elemental in the next few days if people are interested in seeing how this might look like. A similar effort by the SWIG-lovers might help Jack (and us) make up our minds.
Regarding making approaches independent:
(Repeated) There is another parallel issue at stake here. Let's say Elemental decides to use SWIG (noooooo :)); this might force budding libraries --- like ours --- to move over to SWIG as well. Now say that there is a rogue C++ library --- Satan --- that refuses to switch to SWIG and insists on using boost::python (or something else for that matter). But Satan is a very powerful library and it would be nice to not antagonize it. There should theoretically be a way for Satan's python bindings to interact freely with Elemental's python and C++ bindings.
- Anju
--------------------------------------------
Prabhanjan Kambadur
Research Staff Member
Business Analytics and Mathematical Sciences
IBM TJ Watson Research Center
Room 30-229 A
<graycol.gif>"Michael C. Grant" ---03/29/2013 10:01:03 AM---I think there are a couple issues here that might be worth separating---or at least talking about se
<ecblank.gif>
From:
<ecblank.gif>
"Michael C. Grant" <m...@cvxr.com><ecblank.gif>
To:
<ecblank.gif>
ANJU KAMBADUR/Watson/IBM@IBMUS<ecblank.gif>
Cc:
<ecblank.gif>
Andy Ray Terrel <andy....@gmail.com>, Aron Ahmadia <aron.a...@gmail.com>, "barry...@gtri.gatech.edu" <barry...@gtri.gatech.edu>, Dag Sverre Seljebotn <d.s.se...@astro.uio.no>, Jack Poulson <jack.p...@gmail.com>, "richar...@gtri.gatech.edu Boyd" <richar...@gtri.gatech.edu>, "Travis Oliphant" <tra...@continuum.io>, Vikas Sindhwani/Watson/IBM@IBMUS, "Yves Ineichen1" <ZRL...@ch.ibm.com>, "<elemen...@googlegroups.com>" <elemen...@googlegroups.com>
<ecblank.gif>
Date:
<ecblank.gif>
03/29/2013 10:01 AM<ecblank.gif>
Subject:
<ecblank.gif>
[elemental] Re: Python interface to Elemental
<ecblank.gif>
Sent by:
<ecblank.gif>
elemen...@googlegroups.com
) does it. It seems to be quite a comfortable arrangement to have a separate Python package.
I think there are a couple issues here that might be worth separating---or at least talking about separately.
POINT 1: What interfaces should *Elemental* support? Put another way, which interfaces should be contained within the main Elemental repository? At least initially, it seems to me that the right answer might be C++, C, and perhaps SWIG. This seems like the quickest and easiest-to-maintain way to provide multi-language support for Elemental. Given that Jack is likely to remain the primary developer for some time, I would say that limiting the scope of what he would be directly involved in is worthwhile.
I know that those of us who want a first-class Python interface to start with might not prefer SWIG. But C/C++/SWIG immediately covers not just Python but Fortran, Java, Scala, C#, R, Octave... (HPC in Tcl, anyone?) While I suspect that in many of these languages, there will be a benefit to having a higher-level layer that provides native language abstractions, at least it will *work*.
POINT 2: Building on Andy's last point. Does a decision like the above mean we can't build a boost::python or Cython interface to Elemental? Of course not! Before I began toying with Cython for Elemental, I looked at how petsc4py (http://code.google.com/p/petsc4py/
So if some of us want work on a Python interface outside of Elemental, great! If it ends up working very well, it could eventually be merged into the Elemental tree alongside SWIG, in glorious redundancy. But in all likelihood, it would simply continue to flourish as its own project.
I think accepting this "fork" frees everyone up to to be flexible. Those of us who are ready to dive into a higher-level Python interface can do so without feeling like we're stepping on the toes of Jack or anyone else with interests in other language interfaces.
--https://groups.google.com/groups/opt_out.
You received this message because you are subscribed to the Google Groups "elemental-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elemental-de...@googlegroups.com.
For more options, visit
--
You received this message because you are subscribed to the Google Groups "elemental-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elemental-de...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to a topic in the Google Groups "elemental-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elemental-dev/J7Q31ZRHf50/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to elemental-de...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "elemental-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elemental-de...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
I'm thoroughly confused :).
(1) Jack, is there going to be an *official* set of python bindings for Elemental? Would the current ctypes interface be the only one available in the near future? Who is going to maintain the python bindings?
(2) I am willing to write a prototype in boost::python only if the choice of boost::python is still open. Python user base is an important one and I defer to the opinion of Andy et al. about the unpopularity of Boost in the python community. We have zero interest in having our own version of Elemental's python bindings, so is there any point in spending time on a prototype?
Looks like most everyone has joined the elemental-dev mailing list. Should we remove the CC from the next mail onwards?
- Anju
--------------------------------------------
Prabhanjan Kambadur
Research Staff Member
Business Analytics and Mathematical Sciences
IBM TJ Watson Research Center
Room 30-229 A
Dag Sverre Seljebotn ---03/29/2013 12:38:51 PM---Hi, (I'm answering Jack first and then moved Michael's reponse down bottom
| Dag Sverre Seljebotn <d.s.se...@astro.uio.no> |
| Michael Grant <m...@cvxr.com> |
| <elemen...@googlegroups.com>, ANJU KAMBADUR/Watson/IBM@IBMUS, Vikas Sindhwani/Watson/IBM@IBMUS, Yves Ineichen1 <ZRL...@ch.ibm.com>, <richar...@gtri.gatech.edu>, Dag Sverre Seljebotn <d.s.se...@astro.uio.no>, <barry...@gtri.gatech.edu>, Andy Terrel <andy....@gmail.com>, Aron Ahmadia <aron.a...@gmail.com> |
| 03/29/2013 12:38 PM |
|
Re: Python interface to Elemental |
I'm thoroughly confused :).
(1) Jack, is there going to be an *official* set of python bindings for Elemental? Would the current ctypes interface be the only one available in the near future? Who is going to maintain the python bindings?
(2) I am willing to write a prototype in boost::python only if the choice of boost::python is still open. Python user base is an important one and I defer to the opinion of Andy et al. about the unpopularity of Boost in the python community. We have zero interest in having our own version of Elemental's python bindings, so is there any point in spending time on a prototype?
Looks like most everyone has joined the elemental-dev mailing list. Should we remove the CC from the next mail onwards?
Thanks for your answers! I guess this is decision time. Should we all briefly list our preferences and what we are willing contribute?
- Anju
--------------------------------------------
Prabhanjan Kambadur
Research Staff Member
Business Analytics and Mathematical Sciences
IBM TJ Watson Research Center
Room 30-229 A
Jack Poulson ---03/29/2013 01:20:48 PM---On Fri, Mar 29, 2013 at 1:08 PM, ANJU KAMBADUR <pkam...@us.ibm.com> wrote: > I'm thoroughly confuse
| Jack Poulson <jack.p...@gmail.com> |
| "elemen...@googlegroups.com" <elemen...@googlegroups.com> |
| Dag Sverre Seljebotn <d.s.se...@astro.uio.no>, Andy Terrel <andy....@gmail.com>, Aron Ahmadia <aron.a...@gmail.com>, "barry...@gtri.gatech.edu" <barry...@gtri.gatech.edu>, Michael Grant <m...@cvxr.com>, "richar...@gtri.gatech.edu" <richar...@gtri.gatech.edu>, Vikas Sindhwani/Watson/IBM@IBMUS, Yves Ineichen1 <ZRL...@ch.ibm.com> |
| 03/29/2013 01:20 PM |
| Re: [elemental] Re: Python interface to Elemental |
| elemen...@googlegroups.com |
--
You received this message because you are subscribed to the Google Groups "elemental-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elemental-de...@googlegroups.com.
For more options, visit
--
You received this message because you are subscribed to a topic in the Google Groups "elemental-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elemental-dev/J7Q31ZRHf50/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to elemental-de...@googlegroups.com.
Thanks Michael!
On my part, I will try to run toy experiments to see how such an arrangement can work when using SWIG. I don't know if it makes much sense for me to butt in this early, but if you want to --- you and I could figure out that SWIG looks promising w.r.t our intended use case, I would be happy to help or comment with this (private git branch on XDATA repository?). In particular, I can see if I adopted SWIG as well, we could interface with Elemental. To repeat --- the intended use case is the ability to communicate with Elemental's C++ and python bindings harmoniously. I am pasting the example I sent here for everyone's benefit:
namespace skylark {
// Fully generic implementation
template <typename MatrixType>
struct foo_t {
typedef MatrixType matrix_type;
void bar(const matrix_type& A) { ... }
};
// Specialization for elem::DistMatrix<double, VR, STAR>
template <>
struct foo_t <elem::DistMatrix<double, VR, STAR> > {
typedef elem::DistMatrix<double, VR, STAR> matrix_type;
void bar(const matrix_type& A) { ... }
};
}
Suppose skylark::foo_t<elem::DistMatrix<double, VR, STAR> were exposed in python, we should be able to instantiate a elem::DistMatrix<double, VR, STAR> python object (it might be called something else in python) and use it in the call to bar().
- Anju
--------------------------------------------
Prabhanjan Kambadur
Research Staff Member
Business Analytics and Mathematical Sciences
IBM TJ Watson Research Center
Room 30-229 A
"Michael C. Grant" ---03/29/2013 02:22:47 PM---I will be happy to share as soon as I can! On Mar 29, 2013, at 4:20 PM, "Vikas Sindhwani" <vikas.sin
| "Michael C. Grant" <m...@cvxr.com> |
| 03/29/2013 02:22 PM |
| Re: [elemental] Re: Python interface to Elemental |
| elemen...@googlegroups.com |
--
You received this message because you are subscribed to the Google Groups "elemental-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elemental-de...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Jack, if another candidate official version comes along, would you still intend to keep the C/ctypes interface intact and maintained?