如何编译使用std :: chrono和date的CUDA代码?

时间:2019-04-08 18:19:48

标签: c++ datetime c++14 chrono

NVCC编译器拒绝编译下面的代码(使用.cu扩展名),因为它不能很好地处理Howard Hinnant的日期库。 NVCC正在呼叫GCC 6.4.0。对于这个简单的示例,C ++编译器本身完全没有问题。我该怎么解决?

#include <iostream>
#include "date.h"

int main()
{
    const auto time = std::chrono::system_clock::now();
    const auto daypoint = date::floor<date::days>(time);
    const auto ymd = date::year_month_day{daypoint};

    std::cout << ymd.year() << std::endl;

    return 0;
}
../include/date.h:162:27: error: ‘const intmax_t std::__ratio_multiply<std::ratio<24l>, std::ratio<3600l> >::__gcd1’ is private within this context
 using days = std::chrono::duration
                           ^~~~~~~~                                                                                                                                                            
/nfs/admin/hpc/sw/RedHatEnterpriseServer7/GCCcore/6.4.0/include/c++/6.4.0/ratio:289:32: note: declared private here
       static const intmax_t __gcd1 =
                                ^~~~~ 

1 个答案:

答案 0 :(得分:1)

我唯一推荐的是将错误报告发送给Nvidia。这是一个简化的测试用例:

#include <chrono>
#include <ratio>

using days = std::chrono::duration
    <int, std::ratio_multiply<std::ratio<24>, std::chrono::hours::period>>;

int main() {}