Skip to content

Mingw tests (32-bit and 64-bit) #1004

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

Merged
merged 31 commits into from
Jun 30, 2020
Merged

Mingw tests (32-bit and 64-bit) #1004

merged 31 commits into from
Jun 30, 2020

Conversation

lemire
Copy link
Member

@lemire lemire commented Jun 29, 2020

This adds 32-bit and 64-bit tests under mingw (GCC for Windows). I only compile and run "basictests" because it is slllllooooowwww. If we find a way to run the tests faster, we could easily enable all tests.

You apparently can't have, at the same time, both the 64-bit and the 32-bit GCC compiler. So you need (?) two distinct tests.

Some issues with mingw:

  • The pow function is busted.
  • The inttypes header is not standard compliant.

@lemire lemire changed the title I'd feel better with mingw tests Mingw tests (32-bit and 64-bit) Jun 29, 2020
@jkeiser
Copy link
Member

jkeiser commented Jun 29, 2020

@lemire thanks for working so hard on this. I'd feel better with it too! And as we're seeing, to the extend simdjson can be used for language bindings, there are benefits to increased support :)

I don't think there are many libraries that try this hard for coverage, but it's a reason simdjson will stretch far (I hope).

@lemire
Copy link
Member Author

lemire commented Jun 29, 2020

@jkeiser It should pass now... essentially (this all works on my PC).

Copy link
Member

@jkeiser jkeiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fascinated at doing the real tests in github workflows! At the least it's another source of parallel CI, and at best it might be a place we can migrate more and more stuff to, as it has a massive company funding the machines.

A couple of nits and a lot more comments that don't need to be resolved, it seems good otherwise.

@@ -69,6 +71,9 @@ namespace number_tests {
if(ulp > maxulp) maxulp = ulp;
if(ulp > 0) {
std::cerr << "JSON '" << buf << " parsed to " << actual << " instead of " << expected << std::endl;
printf("actual: %18.18g\n", actual);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why both this and std::cerr?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because C++ has a terrible API for formatting numbers. I will document this choice.

@@ -152,18 +157,20 @@ namespace number_tests {
std::cout << __func__ << std::endl;
char buf[1024];
simdjson::dom::parser parser;
for (int i = -1000000; i <= 308; ++i) {// large negative values should be zero.
for (int i = -307; i <= 308; ++i) {// large negative values should be zero.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming this is for speed? Do you feel we have enough coverage at -307, or should it extend a little further just to test that some out of range values yield 0?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is because the pow function in mingw is busted. But I will change the code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. In the next commit, I check if it is busted, if it is, I tell the user about it.

(We try to be correct, but the standard library is not correct on mingw.)

@@ -87,7 +87,11 @@ void found_integer(int64_t result, const uint8_t *buf) {
char *endptr;
long long expected = strtoll((const char *)buf, &endptr, 10);
if ((endptr == (const char *)buf) || (expected != result)) {
#if (!(__MINGW32__) && !(__MINGW64__))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can avoid the ifdef by making a macro:

#if __MINGW32__ || __MINGW64__
#define SIMDJSON_LLD PRId64
#define SIMDJSON_LLU PRIu64
#else
#define SIMDJSON_LLD "lld"
#define SIMDJSON_LLU "llu"
#endif

fprintf(stderr, "Error: parsed %" SIMDJSON_LLD " out of %.32s, ", result, buf);

I'm fine with the 2 ifdefs we have now, but if you mess with common_defs for other reasons, this might be worth it :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Both PRIu64 and PRId64 are part of the standard so I don't know why they don't work. But at some point, you run out of steam trying to find out why something that is perfectly fine by the standard does not work.

Copy link
Member

@jkeiser jkeiser Jun 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understandable :) I did find a stackoverflow indicating that you can get PRIu64 by including <inttypes.h>. But who knows if THAT exists in all the compilers we support ... and it's not worth spending more of your time right now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. Right. I assumed we were importing these in the main library, but I think we do not.

Thanks. (I knew of the header, I just assumed it was there already.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. It is there, look in the files. We have cinttypes. It is another instance where mingw is busted.

Copy link
Member Author

@lemire lemire Jun 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is flat out a bug on their part.

@@ -12,7 +12,7 @@
#define JSON_TEST_STRINGS
#endif

#ifndef _MSC_VER
#if (!(_MSC_VER) && !(__MINGW32__) && !(__MINGW64__))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given how many places we do this,is there a macro that makes sense and covers these three cases? Better yet, perhaps we should have a <simdjson_dirent.h> somewhere, and get rid of the if entirely :)

Eh. For now it's fine, we should really do the simdjson_dirent.h thing regardless of this patch (which suggests it should be done outside of this patch). I'll file an issue.

@@ -1,4 +1,5 @@
#ifndef __GETOPT_H__
/** This file has been modified by D. Lemire for use in simdjson. **/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be happy when we get it all in cxxopts :) Thanks for leaving a changelog in the file!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now cxxopts is not available when git is unavailable and it is not reasonable to deactivate our tests if networking and git are unavailable.

So if we move everything to cxxopts, I think we need to bring a hard copy of cxxopts in the project. Yeah. I know it is unfortunate, but at some point, we need to build on an isolated machine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. It's not terrible as long as we give ourselves a way to check for and update our dependencies (the real reason for a submodule).

# Under Windows, exectuting a bash script works, except that you cannot generally
# do bash C:/path to my script. You need a "mounted" path: /mnt/c/path

if (BASH AND (NOT WIN32))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh. We're going to just have to get rid of all of our bash scripts at some point.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, if we could convert it to a mounted path, it would work. There may already have a really simple way to do this.

With WSL becoming standard... I bet that people know how to do this.

@jkeiser
Copy link
Member

jkeiser commented Jun 29, 2020

Holy lord of knickerbockers, it takes over an hour to build and run basictests?

@lemire
Copy link
Member Author

lemire commented Jun 29, 2020

Holy lord of knickerbockers, it takes over an hour to build and run basictests?

I have no idea how long it takes, but it takes a really long time.

My bet is that we have some kind of quota and our quota has been exhausted.

@jkeiser
Copy link
Member

jkeiser commented Jun 29, 2020

That seems likely, given that there are no logs for the tests that have supposedly been running for over and hour.

@@ -152,18 +155,25 @@ namespace number_tests {
std::cout << __func__ << std::endl;
char buf[1024];
simdjson::dom::parser parser;
for (int i = -1000000; i <= 308; ++i) {// large negative values should be zero.

bool is_pow_correct{1e-308 == std::pow(10,-308)};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkeiser I hope you like this better.

Copy link
Member Author

@lemire lemire Jun 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkeiser Basically, elsewhere we compare the parsed value of "1e-..." against power(10,...). This works. Except if the pow function is inaccurate. Then we get a failing test... not our fault.

@@ -1949,6 +1960,11 @@ int main(int argc, char *argv[]) {
if (simdjson::active_implementation->name() == "unsupported") {
printf("unsupported CPU\n");
}
// We want to know what we are testing.
std::cout << "Running tests against this implementation: " << simdjson::active_implementation->name();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkeiser For John!

@lemire
Copy link
Member Author

lemire commented Jun 29, 2020

That seems likely, given that there are no logs for the tests that have supposedly been running for over and hour.

This makes GitHub actions somewhat less useful that it could be. Maybe there is a way to ask for more compute time.

@lemire
Copy link
Member Author

lemire commented Jun 30, 2020

@jkeiser Can you have a look at my actions. The caching does not work. Without caching, these github actions are crazily expensive. I don't understand what is wrong with my configuration.

@lemire
Copy link
Member Author

lemire commented Jun 30, 2020

Ok. I figured it out. Merging.

@lemire lemire merged commit ccc94c9 into master Jun 30, 2020
@lemire lemire deleted the dlemire/mingw branch June 30, 2020 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants