|
43 | 43 | #include "r-interoff-lib.h" |
44 | 44 | #endif |
45 | 45 |
|
| 46 | +#ifdef OPENACC // If on GPU map fprintf to printf |
| 47 | +#define fprintf(stderr,...) printf(__VA_ARGS__) |
| 48 | +#endif |
| 49 | + |
46 | 50 | #pragma acc routine |
47 | 51 | double r_off_F(double x, double y,double z,double A,double B,double C,double D) { |
48 | 52 | return ( A*x + B*y + C*z + D ); |
@@ -366,9 +370,7 @@ int r_off_clip_3D_mod(r_intersection* t, Coords a, Coords b, |
366 | 370 | #ifdef OFF_LEGACY |
367 | 371 | if (t_size>OFF_INTERSECT_MAX) |
368 | 372 | { |
369 | | -#ifndef OPENACC |
370 | 373 | fprintf(stderr, "Warning: number of intersection exceeded (%d) (interoff-lib/off_clip_3D_mod)\n", OFF_INTERSECT_MAX); |
371 | | -#endif |
372 | 374 | return (t_size); |
373 | 375 | } |
374 | 376 | #endif |
@@ -450,9 +452,7 @@ int r_off_clip_3D_mod_grav(r_intersection* t, Coords pos, Coords vel, Coords acc |
450 | 452 |
|
451 | 453 | if (t_size>CHAR_BUF_LENGTH) |
452 | 454 | { |
453 | | -#ifndef OPENACC |
454 | 455 | fprintf(stderr, "Warning: number of intersection exceeded (%d) (interoff-lib/off_clip_3D_mod)\n", CHAR_BUF_LENGTH); |
455 | | -#endif |
456 | 456 | return (t_size); |
457 | 457 | } |
458 | 458 | //both planes intersect the polygon, let's find the intersection point |
@@ -891,6 +891,10 @@ int n2 = r - m; |
891 | 891 | r_intersection *L, *R; |
892 | 892 | L = (r_intersection *)malloc(sizeof(r_intersection) * n1); |
893 | 893 | R = (r_intersection *)malloc(sizeof(r_intersection) * n2); |
| 894 | + if (!L||!R) { |
| 895 | + fprintf(stderr,"Error allocating intersection arrays\n"); |
| 896 | + exit(-1); |
| 897 | + } |
894 | 898 | /* Copy data to temp arrays L[] and R[] */ |
895 | 899 | #pragma acc loop independent |
896 | 900 | for (i = 0; i < n1; i++) |
|
0 commit comments