On Wed, Jun 29, 2011 at 3:52 PM, David E Hudak <dhu...@osc.edu> wrote:
>
> On Jun 25, 2011, at 6:49 PM, David E Hudak wrote:
>
>>
>> On Jun 24, 2011, at 9:08 PM, David P Grove wrote:
>>
>>>
>>>
>>>
>>> David E Hudak <dhu...@osc.edu> wrote on 06/24/2011 04:47:45 PM:
>>>>
>>>> [X10-users] Java native interface and runtime?
>>>>
>>>> Hi All,
>>>>
>>>> I have a colleague with a Java implementation of a genetic
>>>> algorithm.  He is interested in parallelizing the application for
>>>> both multicore and multinode execution.
>>>>
>>>> In the initial implementation, there are a set of classes for
>>>> specifying fitness functions, expressing genes and implementing gene
>>>> manipulations.  There is a top-level simulation object that run the
>>>> various number of generations.  My plan was to try using the java
>>>> native interface to use the existing Java classes for organisms and
>>>> fitness, and rewrite the top level simulation in X10.
>>>>
>>>> I have been evaluating X10 for purely numeric applications on our
>>>> cluster (C++ back end, MPI runtime and mpiexec as a process
>>>> launcher).  I believe I read somewhere that the Java native
>>>> interface requires the Java back end.  In that case, I'd need to
>>>> make sure we could run the sockets runtime and whatever process
>>>> launcher we have for java (x10run?).
>>>>
>>>> Anyone have any advice?
>>>>
>>>
>>> Following up on what Igor said, I'd suggest going with your plan of writing
>>> the top level simulation in X10, but instead of using JNI, try to use the
>>> multi-place Java implementation of X10 and call the Java generic algorithm
>>> from X10 compiled to Java.
>>
>> So, that is like section 18.3 of the language spec ("External Java Code") as 
>> opposed to section 18.2 ("Native Blocks").  Are there examples of this in 
>> the regression tests?
>>
>> Thanks,
>> Dave
>>
>>>
>>> We're kicking off an activity over the summer to make the X10/Java
>>> interoperability even more user-friendly, so this could be an interesting
>>> case study for us.  Let us know if you run into problems.
>
> OK, first problem is that I am not sure how to start.
>
> In X10, I am able to create DistArrays of X10 objects.  The data structure 
> for the Java genetic algorithm is a vector of Individual (Individual is a 
> class and objects of that class represents organisms in the population).
>
> So, I tried to create a DistContainer for Individuals, but x10c did not like 
> it:
>
> import individual.*;
>
> public class DistContainer {
>        public static def main(args:Array[String](1)) {
>                val arraySize = 400;
>                val bob = new Individual();
>
>                Console.OUT.println("DistContainer test:  Starting");
>                val testArray = 
> DistArray.make[Individual](Dist.makeBlock(1..arraySize), () => new 
> Individual());
>
>                Console.OUT.println("DistContainer test:  Complete");
>        }
> }
>
> Individual.java is the same directory as DistContainer.x10:
>
> dhudak@opt0003 1028%> ls
> total 28
>  4 build-command   4 DistContainer-pbs.sh   4 DistContainer.x10   4 
> individual/  12 Individual.java
> dhudak@opt0003 1029%> x10c DistContainer.x10
> /nfs/07/dhudak/devel/x10/mcsweeny/examples/DistContainer/DistContainer.x10:13:
>  Could not find type "Individual".
> /nfs/07/dhudak/devel/x10/mcsweeny/examples/DistContainer/DistContainer.x10:13:
>  No valid constructor found for Individual().
> 2 errors.
>
>
> Thanks,
> Dave
>
>>>
>>> We've also been making some nice improvements (post 2.2 release) in the
>>> performance of the multi-JVM implementation of X10.  So once your code is
>>> working, if there are communication related performance problems, we could
>>> also work with you to try it on the development branch we have going right
>>> now to work on multi-JVM serialization performance.
>>>
>>> --dave

Hi, Dave,

That's not how Java interaction works at the moment.  If you intend to use your
Java class as a type argument to the X10 container, you have to create a wrapper
(using, e.g., @NativeClass) in X10 and access that from your X10 code.  See, for
example, the source for x10.util.concurrent.Lock, which wraps a Java class.

As Dave said, we are working on a better design, but there is no ETA for it yet.
        Igor

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to