You can pass structs as parameters to native functions, or even define your
own struct natively.  If you tell us the precise API you want, we can
probably point you to some existing code that you can use as a template.

If in doubt, check the c++ code emitted by x10c++ :)


On Thu, Jan 20, 2011 at 9:21 AM, Minor Gordon <min...@us.ibm.com> wrote:

> Hi Sascha,
>
> I've cc:'d x10-users, since you wrote directly to me.
>
> We usually pass pointers as Long's in x10, since those are 64 bit. Structs
> are a bit more difficult. There you have a few options:
> (1) Keep a pointer to the struct as a Long and have native methods that
> access individual fields of the struct.
> (2) Use @NativeClass. See e.g.
> x10/trunk/x10.runtime/src-x10/x10/lang/Lock.x10 for an example of that.
>
> Hope that helps.
>
> Minor
>
>
> From:   Sascha Roloff <sascha.rol...@googlemail.com>
> To:     Minor Gordon/Watson/Contr/IBM@IBMUS
> Date:   01/20/2011 05:36 AM
> Subject:        Re: [X10-users] X10_NTHREADS slowdown with IO
>
>
>
> Hi Olivier,
>
> thank you for information, I will waiting. I In the meantime I want to try
> to build my own parallel IO library using native calls like Vijay said. I
> already looked at the native code integration to use C/C++ native call. It
> is easy, if the called function only takes arguments of primitive
> datatypes or no arguments, but how do I work with pointer-types or
> struct-types in the called function?
>
> Best regards,
> Sascha
>
> 2011/1/18 Minor Gordon <min...@us.ibm.com>
> Hi Josh,
>
> Yes, the new I/O libraries are designed for random access. They take more
> or less directly from POSIX, rather than trying to follow the myriad Java
> APIs.
>
> Minor
>
>
>
>
> From:   Josh Milthorpe <josh.miltho...@anu.edu.au>
> To:     x10-users@lists.sourceforge.net, Minor
> Gordon/Watson/Contr/IBM@IBMUS, Sascha Roloff
> <sascha.rol...@googlemail.com>
> Date:   01/17/2011 05:50 PM
> Subject:        Re: [X10-users] X10_NTHREADS slowdown with IO
>
>
>
> Hi Sascha,
>
> aside from any inefficiencies in x10.io, I suspect that the problem is
> that your IO is single threaded.  In other words, one thread reads the
> file while the others wait for some work.
>
> Unfortunately, those threads are "busy waiting", and constantly
> interrupting the IO thread to attempt to steal work.  This is known to
> slow down single threaded sections.
> https://jira.codehaus.org/browse/XTENLANG-1012
>
> It may be possible to do multi-threaded IO, using random access similar
> to e.g. Java's FileChannel.  However there is currently no X10 IO class
> that supports this.
> https://jira.codehaus.org/browse/XTENLANG-1254
>
> Minor, does your IO rewrite include random access files?
>
> Cheers,
>
> Josh
>
>
> On 18/01/11 02:46, Minor Gordon wrote:
> > Hi Tetsu,
> >
> > The current x10.io library is known to perform very poorly in general,
> not
> > just in parallel code. We are currently working on a rewrite of it that
> > should have much better performance.
> >
> > Cheers,
> > Minor
> >
> >
> >
> >
> > From:   Tetsu Soh<tetsu.soh....@gmail.com>
> > To:     Mailing list for users of the X10 programming language
> > <x10-users@lists.sourceforge.net>
> > Date:   01/17/2011 10:09 AM
> > Subject:        Re: [X10-users] X10_NTHREADS slowdown with IO
> >
> >
> >
> > Hello,
> >
> > I met same problem too. I tested and confirmed that both Java and C++
> > back-end have this problem.
> >
> > Test is very easy. Just reads a large file (for me, 80M) and throws the
> > data away. Uses -INIT_THREADS/$X10_NTHREADS to control how many threads
> > should be active.
> >
> > Another thing I notice is that more threads you used, more times
> > consumed by GC. Even though you do not allocate any objects with these
> > threads.
> >
> > However, the I/O problem seems less related to GC. This problem confused
> > me over 2 months. :(
> >
> > Thanks
> > -Tetsu
> >
> > On Thu, Jan 13, 2011 at 7:25 PM, Sascha Roloff
> > <sascha.rol...@googlemail.com
> >
> >> wrote:
> >>
> >
> >> Dear list,
> >>
> >> I'm writing an X10 application which is suitable to parallelise. I work
> >>
> > on
> >
> >> an Intel Quad Core CPU and want to use 4 Threads. I changed
> X10_NTHREADS
> >> accordingly. The results are ok, I got almost a linear speedup at the
> >> calculations. But there is one problem. I also have to read a big
> >>
> > imagefile
> >
> >> at the beginning and this takes a lot more time, when I use more
> >>
> > Threads.
> >
> >> $ x10c++ -STATIC_CALLS -O -NO_CHECKS  -o x10app Code.x10
> >>
> >> $ export X10_NTHREADS=1
> >> $ ./x10app
> >> read image data: 2336 ms
> >> calculation: 8290 ms
> >>
> >> $ export X10_NTHREADS=4
> >> $ ./x10app
> >> read image data: 6129 ms
> >> calculation: 2330 ms
> >>
> >> Here is a code snippet of reading the image:
> >>
> >> comp1 = new Array[Int]((0..(height-1))*(0..(width-1)));
> >> comp2 = new Array[Int]((0..(height-1))*(0..(width-1)));
> >> comp3 = new Array[Int]((0..(height-1))*(0..(width-1)));
> >>
> >> for([i,j] in comp1) {
> >>   comp1(i,j) = filereader.readByte()&  0xFF;
> >>   comp2(i,j) = filereader.readByte()&  0xFF;
> >>   comp3(i,j) = filereader.readByte()&  0xFF;
> >> }
> >>
> >> I don't understand, maybe someone can help me?
> >>
> >> Sascha
> >>
> >>
> >>
> >
>
> ------------------------------------------------------------------------------
> >
> >> Protect Your Site and Customers from Malware Attacks
> >> Learn about various malware tactics and how to avoid them. Understand
> >> malware threats, the impact they can have on your business, and how you
> >> can protect your company and customers by using code signing.
> >> http://p.sf.net/sfu/oracle-sfdevnl
> >> _______________________________________________
> >> X10-users mailing list
> >> X10-users@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/x10-users
> >>
> >>
> >
>
> ------------------------------------------------------------------------------
> > Protect Your Site and Customers from Malware Attacks
> > Learn about various malware tactics and how to avoid them. Understand
> > malware threats, the impact they can have on your business, and how you
> > can protect your company and customers by using code signing.
> > http://p.sf.net/sfu/oracle-sfdevnl
> > _______________________________________________
> > X10-users mailing list
> > X10-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/x10-users
> >
> >
> >
> >
>
> ------------------------------------------------------------------------------
> > Protect Your Site and Customers from Malware Attacks
> > Learn about various malware tactics and how to avoid them. Understand
> > malware threats, the impact they can have on your business, and how you
> > can protect your company and customers by using code signing.
> > http://p.sf.net/sfu/oracle-sfdevnl
> > _______________________________________________
> > X10-users mailing list
> > X10-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/x10-users
> >
>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> Protect Your Site and Customers from Malware Attacks
> Learn about various malware tactics and how to avoid them. Understand
> malware threats, the impact they can have on your business, and how you
> can protect your company and customers by using code signing.
> http://p.sf.net/sfu/oracle-sfdevnl
> _______________________________________________
> X10-users mailing list
> X10-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/x10-users
>
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to