Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (804)
Games in Android Showcase (237)
games submitted by our members
Games in WIP (867)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  JOML 1.8.0 Release  (Read 40847 times)
0 Members and 1 Guest are viewing this topic.
Offline KaiHH

JGO Kernel


Medals: 790



« Posted 2016-06-03 19:11:16 »

Somewhat in tandem with the LWJGL 3.0.0 release there is now the next JOML version 1.8.0 of joml-master and joml-mini. Both can be used from Maven Central.
Here are the changes compared to the last version 1.7.1.
Offline basil_

« JGO Bitwise Duke »


Medals: 418
Exp: 13 years



« Reply #1 - Posted 2016-06-03 19:58:47 »

much obliged!
Offline KaiHH

JGO Kernel


Medals: 790



« Reply #2 - Posted 2016-06-08 17:50:30 »

Though not technically connected to the JOML 1.8.0 release -- I just did not want to open a new thread for it -- over the last weeks I collected some recurring "anti-patterns" and suboptimal usages of JOML from various projects making us of it as well as LWJGL and JGO forum posts and begun to write them down with best-practices to avoid them:
https://github.com/JOML-CI/JOML/wiki/Anti-Patterns-and-Best-Practices
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline KaiHH

JGO Kernel


Medals: 790



« Reply #3 - Posted 2016-06-10 16:46:41 »

Preview of what's to come in the next release:

Much of the next 1.8.1 release of JOML will be about performance improvements for commonly recurring usage patterns.
Most users (in projects, tutorials, online-books, videos) seen so far use JOML in the following way:

1  
Matrix4f m = new Matrix4f().translate(...).rotate(...).scale(...);

This is common for building a model transformation. Even though the above can be optimized with the existing special-case method:

1  
Matrix4f m = new Matrix4f().translationRotateScale(..., ..., ....);

most users probably won't use the special-case methods, yet expect peak performance.
Therefore, JOML 1.8.1 will focus on optimizing these usage patterns with the issue https://github.com/JOML-CI/JOML/issues/83.
The current implementation of Matrix4f gives a performance increase of around 11% for the above use-case when using rotate() with axis-angle.
When using rotate() with a quaternion it's even around 37% performance increase.
Offline Hydroque

JGO Coder


Medals: 25
Exp: 5 years


I'm always inspiring a good time.


« Reply #4 - Posted 2016-06-10 19:37:39 »

Nice Kai, but I suggest using a shorter name. My matrix class is called Mat3 Mat4 and my vectors Vec3 Vec4. LongNamesArentDifficult.class

You think I haven't been monitoring the chat? http://pastebin.java-gaming.org/c47d35366491fHere is a compilation <3
Offline Icecore
« Reply #5 - Posted 2016-06-10 20:11:47 »

Nice Kai, but I suggest using a shorter name. My matrix class is called Mat3 Mat4 and my vectors Vec3 Vec4. LongNamesArentDifficult.class
you know nothing, Jon Snow ^^

Real code...
1  
2  
abstract public class _E_PD_Use_Ref_Color_Mult<E extends _Param_Ref_Use_Obj_Col_Mult>
                           extends __E_PD_Use_Ref<Param_Ref_Color_Mult<E>, E, int[]>{

_E_PD - Short name XD
hm.. _E_PD_UR_Color_Mult

Last known State: Reassembled in Cyberspace
End Transmission....
..
.
Journey began Now)
Offline Hydroque

JGO Coder


Medals: 25
Exp: 5 years


I'm always inspiring a good time.


« Reply #6 - Posted 2016-06-10 20:26:49 »

That's really complex for no reason lol.

You think I haven't been monitoring the chat? http://pastebin.java-gaming.org/c47d35366491fHere is a compilation <3
Offline Icecore
« Reply #7 - Posted 2016-06-11 13:14:11 »

That's really complex for no reason lol.
you know nothing, Jon Snow =)

and this only template ,it will grow

Last known State: Reassembled in Cyberspace
End Transmission....
..
.
Journey began Now)
Offline Hydroque

JGO Coder


Medals: 25
Exp: 5 years


I'm always inspiring a good time.


« Reply #8 - Posted 2016-06-11 21:38:41 »

I feel sorry for the compiler and jvm.

You think I haven't been monitoring the chat? http://pastebin.java-gaming.org/c47d35366491fHere is a compilation <3
Offline theagentd
« Reply #9 - Posted 2016-06-12 00:02:14 »

I feel sorry for the compiler and jvm.
Feel sorry for whoever has to maintain that code. It may run fine, until it doesn't, and then it doesn't.

Myomyomyo.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Hydroque

JGO Coder


Medals: 25
Exp: 5 years


I'm always inspiring a good time.


« Reply #10 - Posted 2016-06-12 00:41:17 »

I feel sorry for the compiler and jvm.
Feel sorry for whoever has to maintain that code. It may run fine, until it doesn't, and then it doesn't.

Haha. Thanks for the lol.

You think I haven't been monitoring the chat? http://pastebin.java-gaming.org/c47d35366491fHere is a compilation <3
Offline Icecore
« Reply #11 - Posted 2016-06-12 10:32:43 »

I feel sorry for the compiler and jvm.
Its true, even from small refactoring
- eclipse jvm crash compilation build - on any file change (with 0 error shown – build error),
So need clear project Build Data =), weak eclipse ^^

Bad advices from enterprise developer..
"How to be good enterprise developer and become irreplaceable part of company:
-write code, that no one except you can"t support XD"

(can't find youtube video about this Sad )

p.s y, need move classes together by usage in img above - it save little space and organize folders ^^
It's all in big refactoring - i can't run code someting like half month Wink
(so all i doing now, can't even work at all (1000 - 2000 errors in project its ok) XD)

up:
pp.s I have no idea how people support big projects - its ongoing nightmare..

Last known State: Reassembled in Cyberspace
End Transmission....
..
.
Journey began Now)
Offline KaiHH

JGO Kernel


Medals: 790



« Reply #12 - Posted 2016-07-01 17:26:23 »

Latest release 1.8.1 is out and can be used from Maven Central. See the change log
It contains the performance improvements talked about earlier in this thread. This is for users who used the generic Matrix4 methods, such as mul() and invert() in situations where certain properties of the matrix are known so that rather the much faster specialized methods could have been used instead. The new release will now route to these methods automatically.
Offline KaiHH

JGO Kernel


Medals: 790



« Reply #13 - Posted 2016-07-09 11:27:49 »

The next release version 1.8.2 of JOML will make memory copies of Matrix4f on common JVMs, such as OpenJDK and HotSpot, even faster.
This includes typical usecases such as transferring a Matrix4f into a NIO buffer for submission to OpenGL via an OpenGL binding library, copying a Matrix4f into another Matrix4f or setting it to identity().
See commits:
- 235aa12 and
- db1639e
Offline KaiHH

JGO Kernel


Medals: 790



« Reply #14 - Posted 2016-07-31 15:26:22 »

This is a small maintenance release mainly improving Matrix4f <-> NIO Buffer copying. See the release notes for full info.
Offline Riven
Administrator

« JGO Overlord »


Medals: 1371
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #15 - Posted 2016-07-31 16:18:15 »

... copying a Matrix4f into another Matrix4f ...

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
        final void copy(Matrix4f src, Matrix4f dest) {
            UNSAFE.putLong(dest, m00FieldOffset,    UNSAFE.getLongVolatile(src, m00FieldOffset));
            UNSAFE.putLong(dest, m00FieldOffset+8,  UNSAFE.getLongVolatile(src, m00FieldOffset+8));
            UNSAFE.putLong(dest, m00FieldOffset+16, UNSAFE.getLongVolatile(src, m00FieldOffset+16));
            UNSAFE.putLong(dest, m00FieldOffset+24, UNSAFE.getLongVolatile(src, m00FieldOffset+24));
            UNSAFE.putLong(dest, m00FieldOffset+32, UNSAFE.getLongVolatile(src, m00FieldOffset+32));
            UNSAFE.putLong(dest, m00FieldOffset+40, UNSAFE.getLongVolatile(src, m00FieldOffset+40));
            UNSAFE.putLong(dest, m00FieldOffset+48, UNSAFE.getLongVolatile(src, m00FieldOffset+48));
            UNSAFE.putLong(dest, m00FieldOffset+56, UNSAFE.getLongVolatile(src, m00FieldOffset+56));
        }


Why volatile?

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline KaiHH

JGO Kernel


Medals: 790



« Reply #16 - Posted 2016-07-31 16:23:53 »

True. Volatile was not really needed, only "ordered" writes. The current code that shipped with 1.8.2 for this method is:
1  
2  
3  
4  
5  
final void copy(Matrix4f src, Matrix4f dest) {
    for (int i = 0; i < 8; i++) {
        UNSAFE.putOrderedLong(dest, Matrix4f_m00 + (i << 3), UNSAFE.getLong(src, Matrix4f_m00 + (i << 3)));
    }
}

When not using "ordered", the JIT seemed to "optimize"/rewrite memory write accesses across subsequent reads of the same fields (maybe because the JIT did not know anymore that it actually was _that_ field being written to).
Offline KaiHH

JGO Kernel


Medals: 790



« Reply #17 - Posted 2016-10-13 18:24:19 »

Since the last notification, three new versions of JOML have been released, the latest of which is 1.8.5 (now in Maven Central).

Most notable changes:
- new non-lookup-table approximation of sin/cos
  - see: http://www.gamedev.net/topic/681723-faster-sin-and-cos/#entry5308906
  - see: https://github.com/JOML-CI/JOML/wiki/Configuration
- many performance optimizations
- more left-handed matrix transformations
- various other additions

See the release change logs for more information:
- https://github.com/JOML-CI/JOML/releases/tag/1.8.3
- https://github.com/JOML-CI/JOML/releases/tag/1.8.4
- https://github.com/JOML-CI/JOML/releases/tag/1.8.5
Offline Roquen

JGO Kernel


Medals: 518



« Reply #18 - Posted 2016-10-14 20:57:22 »

To note.  The linked paper and that thread on polynomial approximations are examples of exactly how to not attack a problem.  If anyone want to create approximations..start here: http://sollya.gforge.inria.fr/ either the software itself or walk the papers.  There's also the papers by robin green which cover the basics quickly.

Example: "It takes a long time to create these approximations".  It should take less than a second.  The approximation is 15th degree (pretty high) and the range reduction is unsound.
Offline theagentd
« Reply #19 - Posted 2016-10-14 23:58:28 »

Err.... Isn't that just a simple Taylor expansion of sin(x) around x=0? You can calculate almost optimal coefficients for that very easily. I wrote a tiny program that calculates them, then refines them by testing extremely tiny random variations of to try to refine the final results, compared to Math.sin(). Took me a solid 20 min to code up:

1  
2  
3  
4  
5  
6  
7  
8  
9  
Current error: 9.706913049840798E-14
    1E0
    -1.6666655242443085E-1
    8.333154022693634E-3
    -1.9835088460240513E-4
    2.7543485430214787E-6
    -2.503251117502714E-8
    1.6041354355955662E-10
    -6.5907815229721E-13


Error was the total squared error of 100 evenly distributed sin() samples between 0 and PI/2.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
private static double sinApprox(float[] constants, float x){
   float x2 = x * x;
   float tx = x * x2;
   float sin = x * constants[0];
   for(int i = 1; i < constants.length; i++){
      sin += tx * constants[i];
      tx *= x2;
   }
   return sin;
}

Myomyomyo.
Offline KaiHH

JGO Kernel


Medals: 790



« Reply #20 - Posted 2016-10-15 14:25:03 »

To note. It does work pretty well with an absolute max. error of <= 1.97E-8 within the range -800PI..+800PI (and beyond) compared to java.lang.Math.sin(), and it is faster. That's all I care.
Offline Roquen

JGO Kernel


Medals: 518



« Reply #21 - Posted 2016-10-16 01:09:27 »

Like I said.  They have no clue what they're talking about.



@theagentd: You would want to walk the other way...https://en.wikipedia.org/wiki/Horner%27s_method
Offline CommanderKeith
« Reply #22 - Posted 2016-10-16 09:42:04 »

Is that a graph of the error compared to Math.sin of the different approximations 'order-9, order-11', etc?
What is the 'n' on the y-axis?

Offline Roquen

JGO Kernel


Medals: 518



« Reply #23 - Posted 2016-10-16 11:49:28 »

junk=approximation from linked thread, order-9,11,15 are 9,11 and 15th degree polynomial approximations from the software package I provided a link to.  These were designed to minimize relative error and not required to be correct at sin(+/- pi/2) or any other constraints.  Call each of the approximations p(x) then the plot is abs. error expressed as p(x)-sin(x) where sin was computed at 165 bits.  The 'n' is nano.  I should have change that output but it didn't seem worth the time.  So the 15th degree poly from the linked thread has lower error than a proper 9-th degree poly for about 1/2 the domain.  At all other error measures it's worse, peak, average, RMS.  Average error is directly related to the unsigned area under the error curve. 
Offline CommanderKeith
« Reply #24 - Posted 2016-10-16 12:27:52 »

Thanks, interesting to read about that software package Sollya. It looks difficult to use for non mathematicians, I couldn't see any sin approximation function there ready-made. I assume that you used it to make one yourself somehow for those nth degree polynomials?

Offline Roquen

JGO Kernel


Medals: 518



« Reply #25 - Posted 2016-10-17 12:12:57 »

Yeah I just did a REPL session. 

I tossed together a script example: http://pastebin.java-gaming.org/aee29618e4d11
The output of the script looks like this: http://pastebin.java-gaming.org/ee2917e8d411b

Offline CommanderKeith
« Reply #26 - Posted 2016-10-17 22:08:47 »

Impressive, thank you. I'll try to run your code and do a test to see how much faster this approximation is.
By the way, what is your job or study area?

Offline Roquen

JGO Kernel


Medals: 518



« Reply #27 - Posted 2016-10-17 22:23:21 »

No..I just need to approximate a function once in a blue moon.

And since I forgot above, here's the Robin Green papers.  These assume minimal background in any of the topics.
https://basesandframes.wordpress.com/2016/05/17/faster-math-functions/
Offline Roquen

JGO Kernel


Medals: 518



« Reply #28 - Posted 2016-10-19 07:49:53 »

Use Horner's form:  Less instruction issues and more accurate.  If you wanted more speed (call-site dependent) you could convert to Estrin's method at a very small accuracy reduction.  Rewritten in Horner's:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
private static double sin_theagentd_arith(double x)
{
  double xi = Math.floor((x + Math.PI/4.0) * 1.0/Math.PI);
  double x_ = x - xi * Math.PI;
  double sign = ((int)xi & 1) * -2 + 1;
  double x2 = x_ * x_;

// double sin = x_;
// double tx = x_ * x2;
// sin += tx * c1; tx *= x2;
// sin += tx * c2; tx *= x2;
// sin += tx * c3; tx *= x2;
// sin += tx * c4; tx *= x2;
// sin += tx * c5; tx *= x2;
// sin += tx * c6; tx *= x2;
// sin += tx * c7;
// return sign * sin;

  double sin;
 
  x_  = sign*x_;
  sin =          c7;
  sin = sin*x2 + c6;
  sin = sin*x2 + c5;
  sin = sin*x2 + c4;
  sin = sin*x2 + c3;
  sin = sin*x2 + c2;
  sin = sin*x2 + c1;
  return x_ + x_*x2*sin;
}
Offline theagentd
« Reply #29 - Posted 2016-10-19 17:59:54 »

Tested Roquen's version for error:

TheAgentD:
    1.2978632316690104E-16
Roquen:
    1.2978632799710485E-16

Precision is mostly unaffected. I'll leave the benchmarking to KaiHH. =P

Myomyomyo.
Pages: [1] 2
  ignore  |  Print  
 
 

 
Riven (439 views)
2019-09-04 15:33:17

hadezbladez (5297 views)
2018-11-16 13:46:03

hadezbladez (2213 views)
2018-11-16 13:41:33

hadezbladez (5565 views)
2018-11-16 13:35:35

hadezbladez (1156 views)
2018-11-16 13:32:03

EgonOlsen (4592 views)
2018-06-10 19:43:48

EgonOlsen (5467 views)
2018-06-10 19:43:44

EgonOlsen (3128 views)
2018-06-10 19:43:20

DesertCoockie (4023 views)
2018-05-13 18:23:11

nelsongames (4741 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!