3.4.0 filters issue (Android)

Hi, I’m using the current gmic 3.4.0, did an update with ‘gmic up’, but still have problems with two filters, both from ‘samj’, which definitely worked with previous versions.
Of course, there may be other filters having a similar version compatibility issue I don’t know right now.
Example of issue with ‘Hallucinogen 2’ :

$ gmic input.png samj_Hallucinogen_b 1,300,10,10,10,10,80,2,80,1.5,2,0,0,1,1,80,8,1,0,14,1 o out_01.png   
[gmic]./ Start G'MIC interpreter (v.3.4.0).
[gmic]./ Input file 'input.png' at position 0 (1 image 310x290x1x4).
[gmic] *** Error in ./samj_Hallucinogen_b/*if/*substitute/ *** Command 'arg': Specified size (4294967295,1,1,1) exceeds maximum allowed buffer size of 3199959064
[gmic] Command 'arg' has the following description:

  arg:
      n>=1,_arg1,...,_argN

    Return the n-th argument of the
    specified argument list.

And the other, with ‘Cubisme B’:

$ gmic input.png samj_Test_Cubisme_B 11,6,0,30,40,17,6,0,0,0,0,3,1,1,64,25,8,1,0 o out_02.png
[gmic]./ Start G'MIC interpreter (v.3.4.0).
[gmic]./ Input file 'input.png' at position 0 (1 image 310x290x1x4).
[gmic] *** Error in ./samj_Test_Cubisme_B/*foreach/*substitute/ *** Command 'arg': Specified size (4294967295,1,1,1) exceeds maximum allowed buffer size of 3201218072
[gmic] Command 'arg' has... (etc)

Of course I could have copied the parameters out incorrectly, but I’m pretty sure that they are correct.
Thanks!

Hello,

I’ve tested these two commands, and they work for me (using latest release 3.4.0 as well).
I wonder why it does not work for you.

1 Like

Wish I knew David, thanks for testing it for me!

I’m wondering if they really did work on this phone before or maybe not…
Anyway, is it possible that my device (being only 32-bit armv7) processor couldn’t handle it?

Everything is possible. I’ve never tried running G’MIC on Android, so I would not be surprised if we find some bugs or strange behaviors related to the Android version.
Did you compile G’MIC by yourself to make it work on Android ?

I installed it via the package manager available with the ‘Termux’ terminal emulator - So I did ‘pkg install gmic’ to get it, I don’t know a lot about the packaging but I believe it’d be based on the Debian system.

EDIT: I am starting the process of compiling gmic on this android phone now, through an instance of Ubuntu ( via ‘proot-distro’ in Termux.)

EDIT#2: Installed all the required tools and libraries, got the G’MIC source, cd’d to the correct directory, then did ‘make cli’, but got an error, displayed here for anyone to peruse:

root@localhost:~/gmic-3.4.0/src# make climake "CFLAGS+=-Dgmic_community -Dcimg_date=\\\"\\\" -Dcimg_time=\\\"\\\" -Dcimg_use_zlib -I.    -std=c++11 -pedantic -Wall -Wextra -Wfatal-errors -Werror=unknown-pragmas -Werror=unused-label -Wshadow -Dcimg_use_vt100 -Dcimg_use_abort -Dgmic_is_parallel -Dcimg_use_fftw3  -Dcimg_use_curl -I/usr/include/arm-linux-gnueabihf  -Dcimg_use_png -I/usr/include/libpng16  -Dcimg_use_jpeg  -Dcimg_use_tiff -I/usr/include/arm-linux-gnueabihf -I/usr/include/webp  -fopenmp -Dcimg_use_openmp -Dcimg_display=1   -Dcimg_use_openexr -I/usr/include/OpenEXR -pthread -I/usr/include/Imath  -O3 -mtune=generic " "LIBS+=gmic.o -lz   -L. -L/usr/lib -Wl,-rpath,. -lpthread -lfftw3  -lfftw3_threads -lcurl  -lpng16  -ljpeg  -ltiff  -lgomp -lX11  -lpthread  -lOpenEXR-3_1 -lOpenEXRUtil-3_1 -lOpenEXRCore-3_1 -lIex-3_1 -lIlmThread-3_1 -lImath-3_1  " gmic.o _cli                          make[1]: Entering directory '/root/gmic-3.4.0/src'
g++ -o gmic.o -c gmic.cpp -Dgmic_core -Dgmic_community -Dcimg_date=\"\" -Dcimg_time=\"\" -Dcimg_use_zlib -I.    -std=c++11 -pedantic -Wall -Wextra -Wfatal-errors -Werror=unknown-pragmas -Werror=unused-label -Wshadow -Dcimg_use_vt100 -Dcimg_use_abort -Dgmic_is_parallel -Dcimg_use_fftw3  -Dcimg_use_curl -I/usr/include/arm-linux-gnueabihf  -Dcimg_use_png -I/usr/include/libpng16  -Dcimg_use_jpeg  -Dcimg_use_tiff -I/usr/include/arm-linux-gnueabihf -I/usr/include/webp  -fopenmp -Dcimg_use_openmp -Dcimg_display=1   -Dcimg_use_openexr -I/usr/include/OpenEXR -pthread -I/usr/include/Imath  -O3 -mtune=generic          cc1plus: error: unrecognized -mtune target: generic                               compilation terminated due to -Wfatal-errors.                                     make[1]: *** [Makefile:441: gmic.o] Error 1                                       make[1]: Leaving directory '/root/gmic-3.4.0/src'                                 make: *** [Makefile:415: cli] Error 2

Perhaps try something like:

$ gcc -march=native -Q --help=target | grep march=
  -march=                     		skylake
  Known valid arguments for -march= option:
 $ gcc -mtune=native -Q --help=target | grep mtune=
  -mtune=                     		skylake
  Known valid arguments for -mtune= option:

to get decent starting march/mtune values for your architecture. Don’t use skylake; that is what the tuning target is for the Dell laptop I’m using and is for illustration only. You will get different values. Patch the Makefile, replacing mtune=generic with what you obtain.

Hope this helps.

1 Like

Thanks, I found out what you asked:
-mtune = cortex-
and
-march = rmv8.2-a+fp16+dotprod
… edited the Makefile, but I get:

 cc1plus: error: unrecognized -mtune target: cortex-                               compilation terminated due to -Wfatal-errors.                                     make[1]: *** [Makefile:441: gmic.o] Error 1
make[1]: Leaving directory '/root/gmic-3.4.0/src'                                 make: *** [Makefile:415: cli] Error 2

So I assume it is a no-no… :confused:

There should be something after the hyphen. Blame it on the cheap filter I suggested: ‘grep mtune=’. I think it may have found the target string mtune= near the end of a line, so whatever followed the hyphen after cortex- wrapped to the next line, fooling the simple-minded grep filter. Try:

gcc -mtune=native -Q --help=target

without piping to grep. You’ll get a much larger output. Look for a line (something like) The following options are target specific: then a long list of equivalencies, alphabetically sorted. Without filtering, you should find what is after the hyphen. It may be something like cortex-A or cortex-M4 or cortex-M or something else.

Compiling gmic on/for an Android is a bit of an outlier. Wear a helmet; you’ll probably hit other brick walls down this path. But, with patience, you’ll work through them.

EDIT:
Could also omit mtune= and march= entirely and let the compiler use its defaults. May not be optimal, but — 'build first; optimize later.'

1 Like

Yes I thought that was slightly odd also… will try your suggestions tomorrow as it’s rapidly approaching midnight here - need to catch some zzz’s
Many thanks!

Maybe you can provide us a tutorial on compiling gmic on android by then. It seems interesting. I’d really like to test thing on the bed by then.

Ended up trying it with ‘cortex-a55’ and succeeded in compiling gmic 3.4.0!
samj_Hallucinogen_b command works! Will try the other one in the morning and give more details.

2 Likes

Isn’t it still the wee hours on your side of the Atlantic Pond? Couldn’t sleep, or what?
Congratulations, then. Always a satisfying affair to face the sunrise with an confirmed sense of accomplishment. Have fun!

1 Like

It was a case of ‘or what’ (for the sake of brevity)!
At approximately half past stupid o’clock, I suddenly had the urge to try out the newly-found ‘cortex-’ completion, i.e. ‘a55’, for that is apparently what it is according to the output of your later supplied command, for which I was/am extremely grateful!
However, it still didn’t work… So I was thinking to finally give up for the night, when it came to me to try something that I’d also tried with the ‘-mtune=generic’ attempt, but that failed at the time, which was the helpful hint on the website to use the following command:

make cli OPENMP_CFLAGS="" OPENMP_LIBS=""

…even though that’s primarily for people running the older g++ versions 4.8.1 or 4.8.2 (mine is 13.2.0). Combined with the newly edited Makefile… it succeeded and I was pleasantly surprised but not so smug to think all my problems were solved…Yet here we are! (He says smugly.):smirk:

I’ve tried both the problematic commands detailed at the top of the page and both work well. Very kind of you and David to help me out, much obliged!

In response to @Reptorian I could definitely set out a tutorial of sorts, with my compiling hints, although the way I have done it may not be the most straightforward way possible on an Android device.
The extremely condensed and not at all helpful version is F-Droid- Termux - proot-distro - Ubuntu (or similar) - gmic, but a more extensive version I will work on soon - would it be an idea to post it here or start a new subject I wonder?

2 Likes

Probably the tidiest. Tons of gems get misplaced here because they’re asides in a topic with an entirely different name.

Most tutorials are like that — quite often by design, as it is better to be illustrative than straightforward. And, in any case, it is better to have some hints than none at all.

Thanks for posting!

2 Likes

Hey @Mushy, if you are so inclined, you could even write an article or tutorial for pixls.us proper. We could use one from yet another contributor.

:mage::wave: You will write an article for us.

Thanks for asking, I’ve started a draught of the tutorial suggested in this thread, I could do another one, but would it not be easier to write this one here (in the gmic forum) and copy it to the main forum, or are you talking about some completely different topic(s)?

I’d like to do something different so let’s see how it goes, any suggestions gratefully received (from anyone about anything). Thanks. :blush:

No problem and thanks for the advice!

Well, you can just try and we’ll do our best following along, so we can define the tutorial further. Plus, this is great for me because I can develop filters or do some math in my phone, and no longer having to need Python for tests.

1 Like

Give it a go, the tutorial is up now!
Tutorial: Compiling G’MIC for Android Devices

1 Like