fastfloat / fast_float

Fast and exact implementation of the C++ from_chars functions for number types: 4x to 10x faster than strtod, part of GCC 12, Chromium and WebKit/Safari
Apache License 2.0
1.35k stars 124 forks source link

New fast_float versions don't compile with NVIDIA's nvcc #246

Closed breyerml closed 4 months ago

breyerml commented 4 months ago

The small example on the GitHub main page:

#include "fast_float/fast_float.h"
#include <iostream>

int main() {
    const std::string input =  "3.1416 xyz ";
    double result;
    auto answer = fast_float::from_chars(input.data(), input.data()+input.size(), result);
    if(answer.ec != std::errc()) { std::cerr << "parsing failure\n"; return EXIT_FAILURE; }
    std::cout << "parsed the number " << result << std::endl;
    return EXIT_SUCCESS;
}

does not compile with NVIDIA's nvcc compiler (however, it works with nvc++).

Calling nvcc -O3 -std=c++17 -gencode arch=compute_80,code=sm_80 main.cu results in an error:

Documents/test/cuda/fast_float/fast_float/include/fast_float/bigint.h(579): error: incomplete type is not allowed
      size_t large_length = sizeof(large_power_of_5) / sizeof(limb);
                                  ^

1 error detected in the compilation of "main.cu".

Tested with CUDA versions 11.8.0, 12.0.1, and 12.2.2 and fast_float in the current main version.

Git bisecting starting from v3.10.0 to v6.1.1 resulted in showing that the commit:

5243dd97fe50d927f52b86c9388c8a3fde3b6230 is the first bad commit
commit 5243dd97fe50d927f52b86c9388c8a3fde3b6230
Author: Lenard Szolnoki <leni536@gmail.com>
Date:   Fri Mar 3 23:13:52 2023 +0000

    Constexpr bigint

 include/fast_float/bigint.h | 126 ++++++++++++++++++++++++++------------------
 1 file changed, 74 insertions(+), 52 deletions(-)

broke support for nvcc (and it's broken ever since).

lemire commented 4 months ago

@breyerml I expect it is a bug in nvcc.

You can add the following bogus line to get it to build...

    (void)large_power_of_5[0]; // bogus
    size_t large_length = sizeof(large_power_of_5) / sizeof(limb);

Please report the issue with Nvidia.

Or provide a detailed analysis to explain why the bug is in fast_float.