In my test code, the cpu time used by complex computing between CX_LIMITED_RANGE ON/OFF
has no differences.
What's the difference between CX_LIMITED_RANGE ON/OFF
, when and how we use the #pragma STDC CX_LIMITED_RANGE ON
, and when we use default #pragma STDC CX_LIMITED_RANGE OFF
.
Thanks!
void use_CX_LIMITED_RANGE()
{
double complex z1 = 3.0 + I * 4.0;
double complex z2 = 1.0 + I * 2.0;
#pragma STDC CX_LIMITED_RANGE ON
clock_t c1 = clock();
double complex z3;
for (int i = 0; i < 100000; ++i) {
z3 = cabs(z1 * z2);
}
clock_t c2 = clock();
printf("CX_LIMITED_RANGE ON %lu cpu clock\n", c2 - c1);
printf("|z1 * z2| = %f + %fi\n", creal(z3), cimag(z3));
printf("\n");
#pragma STDC CX_LIMITED_RANGE OFF
c1 = clock();
for (int i = 0; i < 100000; ++i) {
z3 = cabs(z1 * z2);
}
c2 = clock();
printf("CX_LIMITED_RANGE OFF %lu\n", c2 - c1);
printf("|z1 * z2| = %f + %fi\n", creal(z3), cimag(z3));
}
've been trying to use this pragma with GCC in C++, with no luck. I get 5x performance boost with -fcx-limited-range, but specifying that in the code instead has no effect. According to GCC's C99 status page, they don't support standard pragmas yet.
http://gcc.gnu.org/c99status.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With