@@ -139,11 +139,34 @@ typedef union {
139139 return c0.q; \
140140 } while(0)
141141
142+ #define child_q_str (funcStr , arg ) do { \
143+ char str[256]; \
144+ sprintf(str, funcStr " %s\n", arg); \
145+ write(ptoc[1], str, strlen(str)); \
146+ if (fgets(str, 255, fpctop) == NULL) stop("child " funcStr); \
147+ cnv128 c; \
148+ sscanf(str, "%" PRIx64 ":%" PRIx64, &c.h, &c.l); \
149+ return c.q; \
150+ } while(0)
151+
152+ #define child_str_q (funcStr , ret , arg ) do { \
153+ char str[256]; \
154+ cnv128 c; \
155+ c.q = arg; \
156+ sprintf(str, funcStr " %" PRIx64 ":%" PRIx64 "\n", c.h, c.l); \
157+ write(ptoc[1], str, strlen(str)); \
158+ if (fgets(str, 255, fpctop) == NULL) stop("child " funcStr); \
159+ sscanf(str, "%63s", ret); \
160+ } while(0)
161+
142162Sleef_quad child_addq_u05 (Sleef_quad x , Sleef_quad y ) { child_q_q_q ("addq_u05" , x , y ); }
143163Sleef_quad child_subq_u05 (Sleef_quad x , Sleef_quad y ) { child_q_q_q ("subq_u05" , x , y ); }
144164Sleef_quad child_mulq_u05 (Sleef_quad x , Sleef_quad y ) { child_q_q_q ("mulq_u05" , x , y ); }
145165Sleef_quad child_divq_u05 (Sleef_quad x , Sleef_quad y ) { child_q_q_q ("divq_u05" , x , y ); }
146166Sleef_quad child_sqrtq_u05 (Sleef_quad x ) { child_q_q ("sqrtq_u05" , x ); }
167+ Sleef_quad child_negq (Sleef_quad x ) { child_q_q ("negq" , x ); }
168+ Sleef_quad child_strtoq (const char * s ) { child_q_str ("strtoq" , s ); }
169+ void child_qtostr (char * ret , Sleef_quad x ) { child_str_q ("qtostr" , ret , x ); }
147170
148171Sleef_quad child_copysignq (Sleef_quad x , Sleef_quad y ) { child_q_q_q ("copysignq" , x , y ); }
149172Sleef_quad child_fabsq (Sleef_quad x ) { child_q_q ("fabsq" , x ); }
@@ -240,7 +263,7 @@ Sleef_quad child_fminq(Sleef_quad x, Sleef_quad y) { child_q_q_q("fminq", x, y);
240263 } while(0)
241264
242265#define checkAccuracyOuterLoop_q (mpfrFunc , childFunc , minStr , maxStr , nLoop , bound , seed ) do { \
243- xsrand(seed); \
266+ xsrand(seed); \
244267 Sleef_quad min = cast_q_str(minStr), max = cast_q_str(maxStr); \
245268 for(int i=0;i<nLoop && success;i++) { \
246269 Sleef_quad x = rndf128(min, max); \
@@ -263,7 +286,7 @@ void checkResult(int success, double e) {
263286#define STR_QUAD_MAX "1.18973149535723176508575932662800702e+4932"
264287#define STR_QUAD_DENORM_MIN "6.475175119438025110924438958227646552e-4966"
265288
266- void do_test () {
289+ void do_test (int options ) {
267290 mpfr_set_default_prec (256 );
268291 mpfr_t frx , fry , frz ;
269292 mpfr_inits (frx , fry , frz , NULL );
@@ -274,6 +297,7 @@ void do_test() {
274297 "0.0" , "-0.0" , "+0.5" , "-0.5" , "+1.0" , "-1.0" , "+1.5" , "-1.5" , "+2.0" , "-2.0" , "+2.5" , "-2.5" ,
275298 "1.234" , "-1.234" , "+1.234e+100" , "-1.234e+100" , "+1.234e-100" , "-1.234e-100" ,
276299 "+1.234e+3000" , "-1.234e+3000" , "+1.234e-3000" , "-1.234e-3000" ,
300+ "3.1415926535897932384626433832795028841971693993751058209749445923078164" ,
277301 "+" STR_QUAD_MIN , "-" STR_QUAD_MIN ,
278302 "+" STR_QUAD_DENORM_MIN , "-" STR_QUAD_DENORM_MIN ,
279303 "NaN" , "Inf" , "-Inf"
@@ -291,6 +315,13 @@ void do_test() {
291315 checkAccuracyOuterLoop_q_q (mpfr_add , child_addq_u05 , "0" , "Inf" , 5 * NTEST , errorBound , 1 );
292316 checkResult (success , maxError );
293317
318+ fprintf (stderr , "subq_u05 : " );
319+ maxError = 0 ;
320+ cmpDenormOuterLoop_q_q (mpfr_sub , child_subq_u05 , stdCheckVals );
321+ checkAccuracyOuterLoop_q_q (mpfr_sub , child_subq_u05 , "1e-100" , "1e+100" , 5 * NTEST , errorBound , 0 );
322+ checkAccuracyOuterLoop_q_q (mpfr_sub , child_subq_u05 , "0" , "Inf" , 5 * NTEST , errorBound , 1 );
323+ checkResult (success , maxError );
324+
294325 fprintf (stderr , "mulq_u05 : " );
295326 maxError = 0 ;
296327 cmpDenormOuterLoop_q_q (mpfr_mul , child_mulq_u05 , stdCheckVals );
@@ -311,11 +342,50 @@ void do_test() {
311342 checkAccuracyOuterLoop_q (mpfr_sqrt , child_sqrtq_u05 , "1e-100" , "1e+100" , 5 * NTEST , errorBound , 0 );
312343 checkAccuracyOuterLoop_q (mpfr_sqrt , child_sqrtq_u05 , "0" , "Inf" , 5 * NTEST , errorBound , 1 );
313344 checkResult (success , maxError );
345+
346+ fprintf (stderr , "negq : " );
347+ maxError = 0 ;
348+ cmpDenormOuterLoop_q (mpfr_neg , child_negq , stdCheckVals );
349+ checkAccuracyOuterLoop_q (mpfr_neg , child_negq , "1e-100" , "1e+100" , 5 * NTEST , errorBound , 0 );
350+ checkAccuracyOuterLoop_q (mpfr_neg , child_negq , "0" , "Inf" , 5 * NTEST , errorBound , 1 );
351+ checkResult (success , maxError );
352+
353+ if ((options & 2 ) != 0 ) {
354+ fprintf (stderr , "strtoq : " );
355+ for (int i = 0 ;i < sizeof (stdCheckVals )/sizeof (char * );i ++ ) {
356+ Sleef_quad a0 = cast_q_str (stdCheckVals [i ]);
357+ Sleef_quad a1 = child_strtoq (stdCheckVals [i ]);
358+ if (memcmp (& a0 , & a1 , sizeof (Sleef_quad )) == 0 ) continue ;
359+ if (isnanf128 (a0 ) && isnanf128 (a1 )) continue ;
360+
361+ fprintf (stderr , "\narg = %s\ntest = %s\ncorrect = %s\n" ,
362+ stdCheckVals [i ], sprintf128 (a1 ), sprintf128 (a0 ));
363+ success = 0 ;
364+ break ;
365+ }
366+ checkResult (success , maxError );
367+
368+ fprintf (stderr , "qtostr : " );
369+ for (int i = 0 ;i < sizeof (stdCheckVals )/sizeof (char * );i ++ ) {
370+ Sleef_quad a0 = cast_q_str (stdCheckVals [i ]);
371+ char s [100 ];
372+ child_qtostr (s , a0 );
373+ Sleef_quad a1 = cast_q_str (s );
374+ if (memcmp (& a0 , & a1 , sizeof (Sleef_quad )) == 0 ) continue ;
375+ if (isnanf128 (a0 ) && isnanf128 (a1 )) continue ;
376+
377+ fprintf (stderr , "\narg = %s\nteststr = %s\ntest = %s\ncorrect = %s\n" ,
378+ stdCheckVals [i ], s , sprintf128 (a0 ), sprintf128 (a1 ));
379+ success = 0 ;
380+ break ;
381+ }
382+ checkResult (success , maxError );
383+ }
314384}
315385
316386int main (int argc , char * * argv ) {
317387 char * argv2 [argc + 2 ], * commandSde = NULL ;
318- int i , a2s ;
388+ int i , a2s , options ;
319389
320390 // BUGFIX: this flush is to prevent incorrect syncing with the
321391 // `iut*` executable that causes failures in the CPU detection on
@@ -343,11 +413,10 @@ int main(int argc, char **argv) {
343413
344414 {
345415 char str [256 ];
346- int u ;
347416
348417 if (readln (ctop [0 ], str , 255 ) < 1 ||
349- sscanf (str , "%d" , & u ) != 1 ||
350- (u & 1 ) == 0 ) {
418+ sscanf (str , "%d" , & options ) != 1 ||
419+ (options & 1 ) == 0 ) {
351420 if (commandSde != NULL ) {
352421 close (ctop [0 ]);
353422 close (ptoc [1 ]);
@@ -360,8 +429,8 @@ int main(int argc, char **argv) {
360429 startChild (argv2 [0 ], argv2 );
361430
362431 if (readln (ctop [0 ], str , 255 ) < 1 ) stop ("Feature detection(sde, readln)" );
363- if (sscanf (str , "%d" , & u ) != 1 ) stop ("Feature detection(sde, sscanf)" );
364- if ((u & 1 ) == 0 ) {
432+ if (sscanf (str , "%d" , & options ) != 1 ) stop ("Feature detection(sde, sscanf)" );
433+ if ((options & 1 ) == 0 ) {
365434 fprintf (stderr , "\n\nTester : *** CPU does not support the necessary feature(SDE)\n" );
366435 return 0 ;
367436 }
@@ -378,7 +447,7 @@ int main(int argc, char **argv) {
378447
379448 fpctop = fdopen (ctop [0 ], "r" );
380449
381- do_test ();
450+ do_test (options );
382451
383452 fprintf (stderr , "\n\n*** All tests passed\n" );
384453
0 commit comments