DGGRID icon indicating copy to clipboard operation
DGGRID copied to clipboard

weird behavior on some Macs

Open jsocolar opened this issue 1 year ago • 6 comments

Some pretty spooky behavior is bubbling up in users of R package dggridR that I think must have its origins in DGGRID itself. I think the most complete statement of the issue is here, though as noted this looks like the same issue. The issue has only been reported by users of M1 chips, but it isn't clear what the significance of that is--maybe it's specific to the M1 architecture, or maybe it is specific to some other aspect of these machines (e.g. the C++ compiler or goodness knows what else).

jsocolar avatar Mar 19 '23 04:03 jsocolar

Thanks for the heads up @jsocolar, I think you're probably right that this is a DGGRID issue so I'm going to have to have a look at it. Alas, I hate hunting weird numeric bugs...

sahrk avatar Mar 19 '23 05:03 sahrk

Thanks @sahrk! Happy to run tests on M1 for you if that's helpful, though I'd need relatively complete and explicit instructions for how to run them. Love DGGRID!

jsocolar avatar Mar 21 '23 03:03 jsocolar

Thanks @sahrk! Happy to run tests on M1 for you if that's helpful

Why I was just about to ask you if you might be willing to do so, thanks!

I'd like to confirm that the problem is with DGGRID and not dggridR. Could you build DGGRID from this repository, if you don't already have it? (See INSTALL.md)

Then put the two attached files geoPts.txt and meta.txt into your current directory and run:

DGGRID/build/src/apps/dggrid/dggrid meta.txt &> output.txt

Then please give me the resulting files output.txt and seqNums.txt.

Note that geoPts.txt contains the problem points from your issue, which are clustered near an icosahedron edge near a vertex (see picture). So I'm betting the ISEA projection is failing in some way.

geoPts geoPts.txt meta.txt

sahrk avatar Mar 21 '23 04:03 sahrk

Sorry this took me so long! I'm pretty sure I've managed to do the right steps. In case it matters DGGRID did not find GDAL on my system. The two files you requested are attached. output.txt seqNums.txt

This was on OS 12.2 with an M1 Pro chip.

jsocolar avatar Apr 09 '23 01:04 jsocolar

Thanks @jsocolar, that looks perfect and no worries on the time! I don't think the lack of GDAL should matter. I notice that the M1 has a 64 bit long double, vs. the 128 bits on intel Macs, which may somehow be causing the issues. Your output.txt narrowed down where the issue is manifesting; I'm wondering if I could ask you to do another run to narrow it down even more?

To do so, first update to (or download the latest version of) the master branch of DGGRID. Then in DGGRID/src/lib/dglib/include/dglib/DgBase.h line 36 change #define DGDEBUG 0 to #define DGDEBUG 1. Then run make.

Then put the two attached files into your current directory and run: DGGRID/build/src/apps/dggrid/dggrid transformMeta.txt &> output.txt

Finally, please give me the resulting files output.txt and transformed.txt.

input.txt transformMeta.txt

sahrk avatar Apr 20 '23 05:04 sahrk

Hello @sahrk. I've run this on a normal M1 chip, after building in debug mode. Here is the output. output.txt

I've also run meta.txt again and get the same error and cell numbers output_meta.txt seqNums.txt

It would be very nice if the source of this bug could be found, so we can push out an update to dggridR that will make it work again for Mac users. Curiously I find that v2.0.3 of dggridR, which uses v6.1 of DGGRID (https://github.com/r-barnes/dggridR/blob/v2.0.3/src/DgBase.h) does work with the M1. This version however uses depreciated spatial libraries in R so it will be best to resolve the issue in the current version of DGGRID and release an updated version of dggridR - also for apple silicon users of DGGRID.

SebKrantz avatar Jul 10 '23 17:07 SebKrantz