Re: To increase speed on manipulating big arrays in Java with minimal bounds checking, ...



Chris Uppal wrote:
> Casey Hawthorne wrote:
>
>> To increase speed on manipulating big arrays in Java with minimal
>> bounds checking, would it be possible to have some operators that
>> only do bounds checking at the boundaries of the array?
>
> You could always write custom array operations in JNI. Otherwise the
> answer is no (not without a change to the JVM design, which isn't
> going to happen).

I'm not sure whether array accesses via JNI actually bypass bounds checks.
You probably would have to copy the Java array into a native array,
perform the algorithm on it and copy results back. This sounds quite
imperformant to me.

> OTOH, it is /said/ (I find it plausible, but I can't confirm it from
> personal knowledge) that the big name JVM's JITers are pretty
> aggressive about removing bounds checks in the generated code, so
> there might not be much to gain from special operators.

Also: what do you gain by a specific operator to be used on boundaries?
If you *know* you're at a boundary why then even bother to check? Bounds
checking is there to prevent accidental violations - something that would
lead to undefined behavior or even crashes if omitted.

Kind regards

robert

.



Relevant Pages

  • Re: Java Generic programming using subclassing
    ... Java nowhere guarantees that the elements of an array ... Now chances are that any Java ... > reference will be visible through the other. ... > eligible for garbage collection, and will in fact be collected before ...
    (comp.lang.java.programmer)
  • Re: java based supercomputer
    ... checking the correlation beteween an array of data and another array ... java psuedo remote threads will take a considerrably less time. ... Does your algorithm lend itself well to paralellization? ... the only bottleneck i can see is checking the correlation value ...
    (comp.lang.java.programmer)
  • Re: How to store a large amount of 3D data points in Java?
    ... >>None of which would be a problem if you could store ints in a Java ... > With 1.5 autoboxing you can, even if it is implemented with objects. ... ArrayList does array copy for resizing. ...
    (comp.lang.java.programmer)
  • Re: MinMax aus Integer-Array schnell ermitteln
    ... Trick "Loop unrolling" erreicht. ... Java sollte eigentlich an Delphi rankommen, ... Array UP ... private static void fillArray0() ...
    (de.comp.lang.java)
  • Re: MinMax aus Integer-Array schnell ermitteln
    ... Trick "Loop unrolling" erreicht. ... Java sollte eigentlich an Delphi rankommen, ... Array UP ... private static void fillArray0() ...
    (de.comp.lang.java)