Logo by AGUS - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Support us via Flattr FLATTR Link
 
*
Welcome, Guest. Please login or register. March 29, 2024, 10:41:27 AM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: 1 [2]   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: Fastest mandelbrot software? Perturbation method?  (Read 19523 times)
0 Members and 1 Guest are viewing this topic.
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #15 on: March 19, 2017, 11:38:43 PM »

java files "between" gui and mm64core..

iterArray/ *
math/ *
util/itercodec/ *
util/offHeapArrays/ *
WorkerThread *

...about 30 java files

ControlTread.class and ControlThreadStatus.class might be of interest as well as the Computation and Rendering classes in gui/toolbox/

maybe more, not sure if I will be able to get this all into my tiny brain  alien
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
recursiveidentity
Forums Freshman
**
Posts: 15


« Reply #16 on: March 20, 2017, 12:39:25 AM »

What languages do you know? I'm a .net programmer for my day job, so that's what I know best, but would think C# to Java would not be so difficult... And I know my way around the syntax and can read Java and C++... Know a little bit about memory management...
Logged
Dinkydau
Fractal Senior
******
Posts: 1616



WWW
« Reply #17 on: March 20, 2017, 02:14:12 AM »

Would it help if the latest Mandel Machine source code was released instead of that of the 1.3.10 version? Zoom depth was increased and bugs were fixed since then. I asked Botond Kosa for the latest source code a few weeks ago because I had some plans to add features to the program, because nowadays I'm copy-pasting coordinates between it and Kalles Fraktaler all the time. It seems he has disappeared completely and he might return, or not, it's unclear. They were just some relatively simple ideas, but I like to see more people seem to agree that because of the highly efficient core functionality, Mandel Machine is worth building upon and I will be interested to follow the events.
« Last Edit: March 20, 2017, 02:31:05 AM by Dinkydau » Logged

Kalles Fraktaler
Fractal Senior
******
Posts: 1458



kallesfraktaler
WWW
« Reply #18 on: March 20, 2017, 09:25:02 AM »

java files "between" gui and mm64core..

iterArray/ *
math/ *
util/itercodec/ *
util/offHeapArrays/ *
WorkerThread *

...about 30 java files

ControlTread.class and ControlThreadStatus.class might be of interest as well as the Computation and Rendering classes in gui/toolbox/

maybe more, not sure if I will be able to get this all into my tiny brain  alien
I think a way forward is to try to understand what the 12 exported functions does?
1.Java_mm_WorkerThread_getItNative_164a?
2. Java_mm_WorkerThread_getItNative_164b?
3.Java_mm_WorkerThread_getItNativeEx?
4.Java_mm_WorkerThread_getCPUidI think this is checking the capabilities of the CPU
5.Java_mm_WorkerThread_getIterationsPTnativeFMaybe this is the mandebrot iteration loop for a specific datatype, could it be per pixel?
6.Java_mm_WorkerThread_getIterationsPTnativeDMaybe this is the mandebrot iteration loop for a specific datatype, could it be per pixel?
7.Java_mm_WorkerThread_getIterationsPTnativeExMaybe this is the mandebrot iteration loop for a specific datatype, could it be per pixel?
8.Java_mm_WorkerThread_setOrbitSeems to have something to do with the refreence
9.Java_mm_WorkerThread_freeOrbitSeems to be release of the reference
10.Java_mm_WorkerThread_initRefOrbCoeffsExMay be the calculation of Series Approximation
11.Java_mm_WorkerThread_doAuxIterationEx?
12.Java_mm_WorkerThread_getIterationsDnativeMaybe this is the mandebrot iteration loop for a specific datatype, could it be per pixel?
Logged

Want to create DEEP Mandelbrot fractals 100 times faster than the commercial programs, for FREE? One hour or one minute? Three months or one day? Try Kalles Fraktaler http://www.chillheimer.de/kallesfraktaler
http://www.facebook.com/kallesfraktaler
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #19 on: March 21, 2017, 02:15:49 AM »

I agree, need to study the calls from the java flow to see what's going on

for me, the way forward is trying to compile but gcc doesn't like intel asm syntax, there is an option, .intel_syntax noprefix for the assembler that can be set for specific pieces of code but has to switch back using .att_syntax so that the compiler doesn't use it for other things...

roughly 32000 lines of java code total, if I can compile the asm on my linux machine maybe I will jump into the java and try to figure it out but if I can't compile it I probably won't dig much further and will leave it to the windows coders.
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
claude
Fractal Bachius
*
Posts: 563



WWW
« Reply #20 on: March 21, 2017, 08:53:03 AM »

if I can compile the asm on my linux machine

I recall Botond mentioning that the ABI of Windows and Linux is different, so chances are the ASM entry points would need massaging to fit...
Logged
_revers_
Conqueror
*******
Posts: 138



« Reply #21 on: March 21, 2017, 11:39:11 AM »

Also, I wonder if it would be easy to take the existing Java code and just recompile it for 1.8. There may not even be anything broken and it just needs to be built, but that's probably wishful thinking...

The sources aren't broken at all. I'm able to import them (mm_v1.3.10_src_java.zip) to Eclipse IDE and run/debug the Mandel Machine.

To make possible development of the Mandel Machine in Eclipse one needs to do few steps, though:

1. The Mandel Machine uses restricted Java API. To be able to compile it in Eclipse one needs to change the access rules from Error to Warning.



2. The Mandel Machine has dependencies to oracle.jdeveloper.layout package. The easiest way to acquire the package is to download MM binaries, extract file mm.jar (for example using 7zip) and copy folder "oracle" to the Eclipse's project "lib" folder (it needs to be created). Also it is good idea to copy all native libs and configuration files to the main project's directory:



Next you need to add the lib folder to the projects libriaries search path: RMB on the project -> Properties -> Java Build Path -> Libraries -> Add class folder and select "lib".



3. Finally you can run the app by RMB on mm/AppWindow.java file -> Run As -> Java Application



And voilà, you are ready for development of the Mandel Machine smiley


Logged
_revers_
Conqueror
*******
Posts: 138



« Reply #22 on: March 21, 2017, 03:43:20 PM »

In case of the newest sources, there is possibility to decompile Java classes from the latest Mandel Machine version. Produced code is very readable (even local variables have original names), though would require some fixes to compile.

But the question is: would the author mind if you would use his decompiled source code?
I wonder what was the reason to not publish the source code of five newest releases. Maybe there was one...
Logged
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #23 on: March 22, 2017, 01:58:19 AM »

@claude gcc prefers AT&T syntax and compiles libraries a little differently so not just ASM entry points but the src/dst order is reversed and register names need % prefix and a number of other things.

@_revers_ Thanks for the eclipse tutorial wink that will help to get others to look at this

the last code version on the MM site is v1.3.15 - 2015.06.16 almost 2yrs ago, I'm certainly impressed with Botond's work but oracle, intel syntax and java all together makes the coding part of my brain overheat  tongue stuck out
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
recursiveidentity
Forums Freshman
**
Posts: 15


« Reply #24 on: March 27, 2017, 03:19:23 AM »

I'm going to download Eclipse and play around with this for fun... Also, I assume from the direction this thread went that there aren't really any other programs out there right now that use perturbation?
Logged
Dinkydau
Fractal Senior
******
Posts: 1616



WWW
« Reply #25 on: August 02, 2017, 04:19:11 AM »

Edit: Before you read this post: I have already managed to solve the problems myself. I will make a later post on how to I compiled the full Mandel Machine when I understand better why it worked this time and when I'm more confident that it actually works well.

The definition "JNIEXPORT" indicates exported functions, I assume simliar to "__declspec(dllexport)"
There are only 12 exported functions:
1. Java_mm_WorkerThread_getItNative_164a
2. Java_mm_WorkerThread_getItNative_164b
3. Java_mm_WorkerThread_getItNativeEx
4. Java_mm_WorkerThread_getCPUid
5. Java_mm_WorkerThread_getIterationsPTnativeF
6. Java_mm_WorkerThread_getIterationsPTnativeD
7. Java_mm_WorkerThread_getIterationsPTnativeEx
8. Java_mm_WorkerThread_setOrbit
9. Java_mm_WorkerThread_freeOrbit
10. Java_mm_WorkerThread_initRefOrbCoeffsEx
11. Java_mm_WorkerThread_doAuxIterationEx
12. Java_mm_WorkerThread_getIterationsDnative

So, what do they do and how are they called?
I spent my time today reading about how java works, to understand more about how Mandel Machine works. According to some sites, functions from a dll should be declared with the keyword native in java. There are more functions in the java code with this keyword. All of them are declared in WorkerThread.java:
Code:
private static native int getItNative03_32(double[] iterArray, int index, int[] zxzy, int maxIterations, double bailout, final double lnlnbailout);
private static native int getItNative04_32(double[] iterArray, int index, int[] zxzy, int maxIterations, double bailout, final double lnlnbailout);
... it goes from 3 through 35
private static native int getItNative34_32(double[] iterArray, int index, int[] zxzy, int maxIterations, double bailout, final double lnlnbailout);
private static native int getItNative35_32(double[] iterArray, int index, int[] zxzy, int maxIterations, double bailout, final double lnlnbailout);

private static native void getItNative_64a(long[] zxzy, int minIterations, int maxIterations, double bailout, int fracs);
public static native void getItNative_64b(long[] zxzy, int maxIterations, double bailout, int fracs, double[] refOrbXYD, long[] refOrbXYE, int refOrbLength2, double mul, double glitchAbsThreshold, boolean extended);
private static native int getItNativeEx(double[] zxzyb, int minIterations, int maxIterations, boolean computeDE);
public static native void setOrbit(float[] referenceOrbitF, double[] referenceOrbitD, long[] referenceOrbitE);
public static native void freeOrbit();
public static native void initRefOrbCoeffsEx(long[] coeffsEx, int serApproxTerms, int coeffsScaleMode);
public static native void doAuxIterationEx(long[] coeffsEx, int serApproxTerms, int coeffsScaleMode, double[] refOrbXYs);
private static native void getIterationsDnative(int minIterations, int maxIterations, long zxzyb4Ptr, int pixels, int simdMode, boolean computeDE);
private static native void getIterationsPTnativeF(long minIterations, int orbitLength, long dxdyb4Ptr, int scale, int pixels, int simdMode);
private static native void getIterationsPTnativeD(long minIterations, int orbitLength, double[] dxdyb4, int scale, int pixels, int simdMode, boolean ignore);
private static native void getIterationsPTnativeEx(long minIterations, int orbitLength, double[] dxdyb, boolean ignore, boolean extendedReference);
public static native void getCPUid(long resultsPtr);
The remaining functions are declared in mm64.cpp and exist in mm64core.asm, so they must be the functions written in assembly language.

The source of the dll is availabe and consist of only 3 files:
mm_WorkerThread.h
mm64.cpp
mm64core.asm

...

I was able to compile the code by adding the following piece of code in the top of mm_WorkerThread.h, that defines the used datatypes and implements JNIEnv (although always return NULL):
Code:
#define JNIEXPORT __declspec(dllexport)
#define JNICALL
#define jclass void *
#define jint int
#define jdoubleArray double *
#define jfloatArray float *
#define jdouble double
#define jlong __int64
#define jlongArray __int64 *
#define jboolean bool

#define JNI_TRUE 1
#define JNI_ABORT -1

class JNIEnv
{
public:
double *GetPrimitiveArrayCritical(jdoubleArray dbla, jboolean isCopy)
{
return NULL;
}
jlongArray GetPrimitiveArrayCritical(jlongArray jzx,jboolean isCopy)
{
return NULL;
}
void ReleasePrimitiveArrayCritical(jdoubleArray dbla, jdouble* xyzbailout, jint i)
{
}
void ReleasePrimitiveArrayCritical(jlongArray dbla, jlong* xyzbailout, jint i)
{
}
void ReleaseFloatArrayElements(jfloatArray orbxyFref, float * orbxyF,jint i)
{
}
void DeleteGlobalRef(jfloatArray orbxyFref)
{
}
void DeleteGlobalRef(jdoubleArray orbxyFref)
{
}
void DeleteGlobalRef(jlongArray orbxyFref)
{
}
void ReleaseDoubleArrayElements(jdoubleArray orbxyDref, double *orbxyD, jint i)
{
}
void ReleaseLongArrayElements(jlongArray orbxyEref, __int64 *orbxyE, jint i)
{
}
double *GetDoubleArrayElements(jdoubleArray orbxyDref,jint i)
{
return NULL;
}
float *GetFloatArrayElements(jfloatArray orbxyFref,jint i)
{
return NULL;
}
__int64 *GetLongArrayElements(jlongArray orbxyEref,jint i)
{
return NULL;
}
jfloatArray NewGlobalRef(jfloatArray orbitXYF)
{
return NULL;
}
jlongArray NewGlobalRef(jlongArray orbitXYE)
{
return NULL;
}
jdoubleArray NewGlobalRef(jdoubleArray orbitXYD)
{
return NULL;
}
};
How do you do this? I tried using g++ from the commandline in cygwin64 to compile mm64.cpp. It fails (collect2: error: ld returned 1 exit status), so I inserted your piece of code, which changes the error to a lot of these:

Code:
mm_WorkerThread.h:4:14: error: declaration does not declare anything [-fpermissive]
 #define jint int
              ^
I googled the error, did some things without understanding what I was doing, which made this specific error go away and lead to another error, and another... So I can't get this compiled. Apparently it didn't normally work for you either (without the extra code). Do you have an idea why? I would assume the source code as shared by Botond Kosa be complete and we shouldn't need to change anything.

I tried to find the reference to the file containing the assembly language, because that's what the dll is really about, and couldn't find it. It makes me wonder how this code was supposed to be used.

Edit:
Apparently, this is how a c file with functions in assembly language should be compiled. Taken from an example from the JWasm assembler:
Code:
gcc -c mixed1c.c
jwasm -coff mixed132.asm
gcc mixed1c.o mixed132.obj -o mixed1c.exe

JWasm is not the correct assembler for Mandel Machine's source code - it's just where I found the example. I have now found out the right one is probably ml64, an executable included in some microsoft software packages including Visual Studio. It's very hard to find otherwise. I downloaded Visual Studio 2013 (several gigabytes) and installed it in a virtual machine only to copy the ml64.exe that's just 500 kB. Using that and assuming c++ should be compiled the same way as c, this is what I did:
Code:
ml64 /c mm64core.asm
g++ -c mm64.cpp
g++ mm64.o mm64core.obj -o mm64.dll
This assembles mm64core.asm to mm64core.obj, compiles mm64.cpp to mm64.o and links the two files to form mm64.dll.

This generates a dll. That's a good sign. Unfortunately the dll makes Mandel Machine crash, so I'm still not doing something right. (Mandel Machine can start succesfully when it doesn't need to use the dll: for example when a parameter file with iteration data is last loaded.)


The sources aren't broken at all. I'm able to import them (mm_v1.3.10_src_java.zip) to Eclipse IDE and run/debug the Mandel Machine.
This works. Thanks.

There is still a problem which I'm not sure what's causing it. I used mm64.dll from version 1.3.10 because the source code is for that version. The application crashes when zooming to exactly 1951 zooms or more. (Using the latest mm64.dll from version 1.3.15 doesn't allow zooming beyond 43 zooms.)
Edit: Ignore this. Parameter files with higher magnifications can be loaded succesfully and I can continue zooming without problems so it's probably just a bug.
« Last Edit: August 10, 2017, 07:29:06 PM by Dinkydau » Logged

Pages: 1 [2]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
3D Mandelbrot, pole vector method (see Theory forum) Mandelbulb Renderings cbuchner1 4 9492 Last post December 11, 2009, 08:25:51 PM
by cbuchner1
BBM15 software for layered 3D Mandelbrot sets Other / General Discussion Jules Ruis 0 5419 Last post December 31, 2009, 03:31:08 PM
by Jules Ruis
Priorities list for develop mandelbrot software. Programming Tux89 5 5190 Last post June 27, 2011, 08:30:55 PM
by ker2x
The Mandelbrot Set. Perturbation Theory. UltraFractal SeryZone 0 5609 Last post October 14, 2014, 07:54:14 PM
by SeryZone
Output from my own Software - simple Mandelbrot 2D Detail Images Showcase (Rate My Fractal) Florian 0 4749 Last post December 27, 2015, 06:03:39 PM
by Florian

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.208 seconds with 24 queries. (Pretty URLs adds 0.012s, 2q)