Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test suite compilation failing on Mac #49

Open
kiranns opened this issue May 29, 2020 · 12 comments
Open

Test suite compilation failing on Mac #49

kiranns opened this issue May 29, 2020 · 12 comments
Labels

Comments

@kiranns
Copy link

kiranns commented May 29, 2020

My configuration:
MacOS Mojave 10.14.6Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Errors I am seeing:
template<typename...T>
^
/Users/kiran/libmorton/libmorton/test/libmorton_test.h:98:107: error: expected expression
return control_encode_impl<sizeof...(fields)>(std::numeric_limits<uint64_t>::digits / sizeof...(fields), { fields... });
^
/Users/kiran/libmorton/libmorton/test/libmorton_test.h:102:118: error: a space is required between consecutive right angle brackets
(use '> >')
void control_decode_impl(uint64_t encoding, std::size_t bitCount, const std::valarray<std::reference_wrapper<uint64_t>>& fields) {

@Forceflow
Copy link
Owner

Hmm ... weird.
I did recently drop C++11 requirement for the headers themselves, but the libmorton_test.h (part of the test suite, not the libmorton headers themselves) you're referring to still uses variadic templates, which are a C++11 feature

Does the clang version your using support that?

@kiranns
Copy link
Author

kiranns commented Jun 4, 2020 via email

@kiranns
Copy link
Author

kiranns commented Jun 4, 2020 via email

@Forceflow
Copy link
Owner

Forceflow commented Jun 4, 2020

Well, if each of your coordinates can be 64 bits (and you sure all of those bits are used), your morton number has to be 64*3 bits = 192 bits, so you'd need some kind of 256-bit type to store that. You can probably derive methods to do that based on this library.

You sure you're not dealing with 16 / 32 bit coordinates stored in a uint64?

@kiranns
Copy link
Author

kiranns commented Jun 5, 2020 via email

@Forceflow
Copy link
Owner

Forceflow commented Jun 5, 2020

Well, have a look at the pre-shifted LUT method in morton3D.h

// ENCODE 3D Morton code : Pre-Shifted LookUpTable (sLUT)
	template<typename morton, typename coord>
	inline morton m3D_e_sLUT(const coord x, const coord y, const coord z) {
		morton answer = 0;
		for (unsigned int i = sizeof(coord); i > 0; --i) {
			unsigned int shift = (i - 1) * 8;
			answer =
				answer << 24 |
				(Morton3D_encode_z_256[(z >> shift) & EIGHTBITMASK] |
					Morton3D_encode_y_256[(y >> shift) & EIGHTBITMASK] |
					Morton3D_encode_x_256[(x >> shift) & EIGHTBITMASK]);
		}
		return answer;
	}

You can adapt this method to work with 64-bit coordinates as well, and have some logic to writeout the result to three seperate uint64's. I see it's already using sizeof(coord) in its internal logic, so that's taken care of.

And to answer your original question: if you really want to compile the test suite (which, again: is not required to use the library!), you'll have to resort to a compiler which supports C++11 / variadic templates.

@Kristine1975
Copy link

Hmm ... weird.
I did recently drop C++11 requirement for the headers themselves, but the libmorton_test.h (part of the test suite, not the libmorton headers themselves) you're referring to still uses variadic templates, which are a C++11 feature

Does the clang version your using support that?

It does (Apple's clang 10.0.1 equals official clang 7.0.0), but it's not turned on by default. Adding -std=c++11 to CFLAGS in the makefile fixes it:

CFLAGS=-O3 -m64 -std=c++11 -I ../libmorton/include/

However this results in further compile errors because apparently Apple defines uint_fast16_t differently: it's not unsigned int but unsigned short:

libmorton_test.cpp:121:66: note: in instantiation of function template specialization 'libmorton::m3D_e_sLUT_ET<unsigned int, unsigned short>'
      requested here
        f3D_32_encode.push_back(encode_3D_32_wrapper("LUT Shifted ET", &m3D_e_sLUT_ET<uint_fast32_t, uint_fast16_t>));
                                                                        ^
./../libmorton/include/morton3D.h:67:16: note: candidate function template not viable: no known conversion from 'const uint_fast32_t [256]' to
      'const unsigned short *' for 2nd argument
        inline morton compute3D_ET_LUT_encode(const coord c, const coord *LUT) {

Morton3D_encode_x_256 is an array of uint_fast32_t and passed to compute3D_ET_LUT_encode as its second argument. According to the explicitly specified template arguments this second argument must in this case be a pointer to uint_fast16_t, not an array/pointer to uint_fast32_t. On platforms where both uint_fast16_t and uint_fast32_t are identical (most likely unsigned int) this compiles just fine. If they are different (as on macOS), you get @kiranns compile error.

@Forceflow
Copy link
Owner

Does only the test suite fail to compile, or are the header files not usable too?

@Forceflow Forceflow added bug and removed question labels Sep 19, 2021
@Kristine1975
Copy link

Kristine1975 commented Sep 20, 2021

The following tests fail to compile. Once I commented them out, the remaining tests compiled successfully:

f3D_32_encode.push_back(encode_3D_32_wrapper("LUT Shifted ET", &m3D_e_sLUT_ET<uint_fast32_t, uint_fast16_t>));

f3D_32_encode.push_back(encode_3D_32_wrapper("LUT ET", &m3D_e_LUT_ET<uint_fast32_t, uint_fast16_t>));

f3D_32_encode.push_back(encode_3D_32_wrapper("AVX512 instruction set", &m3D_e_BITALG<uint_fast32_t, uint_fast16_t>));

f3D_32_decode.push_back(decode_3D_32_wrapper("AVX512 Instruction set", &m3D_d_BITALG<uint_fast32_t, uint_fast16_t>));

f2D_64_encode.push_back(encode_2D_64_wrapper("LUT Shifted ET", &m2D_e_sLUT_ET<uint_fast64_t, uint_fast32_t>));

f2D_64_encode.push_back(encode_2D_64_wrapper("LUT ET", &m2D_e_LUT_ET<uint_fast64_t, uint_fast32_t>));

@davidwwalker611
Copy link

I'm still getting this same problem making libmorton_test on my new MacBook using clang 14. Has the bug been fixed?

@Forceflow
Copy link
Owner

Can you post the full compile output?

@davidwwalker611
Copy link

report.txt

Here is the compile output

@Forceflow Forceflow changed the title Compilation failing on Mac Test suite compilation failing on Mac Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants