添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
年轻有为的双杠  ·  npm ERR! gyp ERR! ...·  1 年前    · 
挂过科的酱肘子  ·  JPA-EntityManager.merg ...·  1 年前    · 
暗恋学妹的柑橘  ·  ABP 报错 ...·  2 年前    · 

这两天编译的时候由于用到了CGAL库,在用GCC或者其他编译器的时候遇到了问题:
*Expr: -CGAL_IA_MUL(-1.1, 10.1) != CGAL_IA_MUL(1.1, 10.1)
File: /usr/include/CGAL/Interval_nt.h
Line: 209
Explanation: Wrong rounding: did you forget the -frounding-math option if you use GCC (or -fp-model strict for Intel)*

上网搜了很久,有两个资料讲的比较详细,CGAL官网的discussion也讨论过这个,在下面也列出来了.具体的原因没看明白,解决办法可以归结为:
如果在源代码里面包含了CGAL库里的头文件(也就是调用了它实现的某个函数),这是在编译的时候需要使用GCC的参数 -frounding-math 选项.
如果使用的nvcc编译.cu文件,由于nvcc不是别上面的参数,此时在nvcc编译选项后添加宏-DCGAL_DISABLE_ROUNDING_MATH_CHECK应该就没问题了.

我是在调试修改后的caffe的时候遇到的这个问题,在正常情况下编译和运行caffe都没有问题,在debug模式下,编译没有问题,但是运行就会出现上面的错误,后来在reference里面找到了这个办法.如果有对这个问题更深入的解释或者更好的办法,欢迎交流~

Reference
[1] http://cgal-discuss.949826.n4.nabble.com/CGAL-Assertion-exception-CGAL-IA-MUL-1-1-10-1-CGAL-IA-MUL-1-1-10-1-td4655241.html
[2] http://cgal-discuss.949826.n4.nabble.com/frounding-math-trouble-with-GCC-4-0-1-td952635.html

这两天编译的时候由于用到了CGAL库,在用GCC或者其他编译器的时候遇到了问题: *Expr: -CGAL_IA_MUL(-1.1, 10.1) != CGAL_IA_MUL(1.1, 10.1) File: /usr/include/CGAL/Interval_nt.h Line: 209 Explanation: Wrong rounding: did you forget the - ```c++ #include < CGAL /Exact_predicates_exact_constructions_kernel.h> #include < CGAL /intersections.h> #include <vector> #include <iostream> typedef CGAL ::Exact_predicates_exact_constructions_kernel K; typedef K::Point_3 Point; typedef K::Tr ia ngle_3 Tr ia ngle; int main() // 输入两组点云数据 std::vector<Point> points1 = {Point(, , ), Point(1, , ), Point(, 1, )}; std::vector<Point> points2 = {Point(.5, .5, ), Point(1.5, .5, ), Point(.5, 1.5, )}; // 构造三角形 Tr ia ngle tri1(points1[], points1[1], points1[2]); Tr ia ngle tri2(points2[], points2[1], points2[2]); // 计算交集 auto result = CGAL ::intersection(tri1, tri2); if (result) { // 如果有交集,输出交集面积 std::cout << "交集面积为:" << result->area() << std::endl; } else { std::cout << "两者没有交集" << std::endl; return ; 这个代码使用了 CGAL 的精确计算库,可以保证计算结果的精度。