@@ -397,11 +397,12 @@ static int
397
397
quad_ufunc_promoter (PyUFuncObject *ufunc, PyArray_DTypeMeta *op_dtypes[],
398
398
PyArray_DTypeMeta *signature[], PyArray_DTypeMeta *new_op_dtypes[])
399
399
{
400
+ printf (" called comparison promoter\n " );
400
401
int nin = ufunc->nin ;
401
402
int nargs = ufunc->nargs ;
402
403
PyArray_DTypeMeta *common = NULL ;
403
404
bool has_quad = false ;
404
-
405
+ printf ( " dtyp1: %s dtype2: %s \n " , get_dtype_name (op_dtypes[ 0 ]), get_dtype_name (op_dtypes[ 1 ]));
405
406
// Handle the special case for reductions
406
407
if (op_dtypes[0 ] == NULL ) {
407
408
assert (nin == 2 && ufunc->nout == 1 ); /* must be reduction */
@@ -415,6 +416,7 @@ quad_ufunc_promoter(PyUFuncObject *ufunc, PyArray_DTypeMeta *op_dtypes[],
415
416
// Check if any input or signature is QuadPrecision
416
417
for (int i = 0 ; i < nin; i++) {
417
418
if (op_dtypes[i] == &QuadPrecDType) {
419
+ printf (" Quaddtype found at index: %d\n " , i);
418
420
has_quad = true ;
419
421
}
420
422
}
@@ -431,7 +433,6 @@ quad_ufunc_promoter(PyUFuncObject *ufunc, PyArray_DTypeMeta *op_dtypes[],
431
433
}
432
434
else if (common != signature[i]) {
433
435
Py_CLEAR (common); // Not homogeneous, unset common
434
-
435
436
break ;
436
437
}
437
438
}
@@ -459,6 +460,7 @@ quad_ufunc_promoter(PyUFuncObject *ufunc, PyArray_DTypeMeta *op_dtypes[],
459
460
else {
460
461
// Otherwise, use the common dtype
461
462
Py_INCREF (common);
463
+ printf (" setting output to %s dtype\n " , get_dtype_name (common));
462
464
new_op_dtypes[i] = common;
463
465
}
464
466
}
@@ -560,42 +562,9 @@ init_quad_binary_ops(PyObject *numpy)
560
562
561
563
template <cmp_quad_def sleef_comp, cmp_londouble_def ld_comp>
562
564
int
563
- quad_generic_comp_strided_loop_aligned (PyArrayMethod_Context *context, char *const data[],
564
- npy_intp const dimensions[], npy_intp const strides[],
565
- NpyAuxData *auxdata)
566
- {
567
- npy_intp N = dimensions[0 ];
568
- char *in1_ptr = data[0 ], *in2_ptr = data[1 ];
569
- char *out_ptr = data[2 ];
570
- npy_intp in1_stride = strides[0 ];
571
- npy_intp in2_stride = strides[1 ];
572
- npy_intp out_stride = strides[2 ];
573
-
574
- QuadPrecDTypeObject *descr = (QuadPrecDTypeObject *)context->descriptors [0 ];
575
- QuadBackendType backend = descr->backend ;
576
-
577
- while (N--) {
578
- if (backend == BACKEND_SLEEF) {
579
- *((npy_bool *)out_ptr) =
580
- sleef_comp ((const Sleef_quad *)in1_ptr, (const Sleef_quad *)in2_ptr);
581
- }
582
- else {
583
- *((npy_bool *)out_ptr) =
584
- ld_comp ((const long double *)in1_ptr, (const long double *)in2_ptr);
585
- }
586
-
587
- in1_ptr += in1_stride;
588
- in2_ptr += in2_stride;
589
- out_ptr += out_stride;
590
- }
591
- return 0 ;
592
- }
593
-
594
- template <cmp_quad_def sleef_comp, cmp_londouble_def ld_comp>
595
- int
596
- quad_generic_comp_strided_loop_unaligned (PyArrayMethod_Context *context, char *const data[],
597
- npy_intp const dimensions[], npy_intp const strides[],
598
- NpyAuxData *auxdata)
565
+ quad_generic_comp_strided_loop (PyArrayMethod_Context *context, char *const data[],
566
+ npy_intp const dimensions[], npy_intp const strides[],
567
+ NpyAuxData *auxdata)
599
568
{
600
569
npy_intp N = dimensions[0 ];
601
570
char *in1_ptr = data[0 ], *in2_ptr = data[1 ];
@@ -617,6 +586,7 @@ quad_generic_comp_strided_loop_unaligned(PyArrayMethod_Context *context, char *c
617
586
*((npy_bool *)out_ptr) = sleef_comp (&in1.sleef_value , &in2.sleef_value );
618
587
}
619
588
else {
589
+ printf (" %Lf % Lf\n " , in1.longdouble_value , in2.longdouble_value );
620
590
*((npy_bool *)out_ptr) = ld_comp (&in1.longdouble_value , &in2.longdouble_value );
621
591
}
622
592
@@ -632,7 +602,6 @@ comparison_ufunc_promoter(PyUFuncObject *ufunc, PyArray_DTypeMeta *op_dtypes[],
632
602
PyArray_DTypeMeta *signature[], PyArray_DTypeMeta *new_op_dtypes[])
633
603
{
634
604
PyArray_DTypeMeta *new_signature[NPY_MAXARGS];
635
-
636
605
memcpy (new_signature, signature, 3 * sizeof (PyArray_DTypeMeta *));
637
606
new_signature[2 ] = NULL ;
638
607
int res = quad_ufunc_promoter (ufunc, op_dtypes, new_signature, new_op_dtypes);
@@ -654,11 +623,11 @@ create_quad_comparison_ufunc(PyObject *numpy, const char *ufunc_name)
654
623
655
624
PyArray_DTypeMeta *dtypes[3 ] = {&QuadPrecDType, &QuadPrecDType, &PyArray_BoolDType};
656
625
657
- PyType_Slot slots[] = {{NPY_METH_strided_loop,
658
- (void *)&quad_generic_comp_strided_loop_aligned <sleef_comp, ld_comp>},
659
- {NPY_METH_unaligned_strided_loop,
660
- (void *)&quad_generic_comp_strided_loop_unaligned <sleef_comp, ld_comp>},
661
- {0 , NULL }};
626
+ PyType_Slot slots[] = {
627
+ {NPY_METH_strided_loop, (void *)&quad_generic_comp_strided_loop <sleef_comp, ld_comp>},
628
+ {NPY_METH_unaligned_strided_loop,
629
+ (void *)&quad_generic_comp_strided_loop <sleef_comp, ld_comp>},
630
+ {0 , NULL }};
662
631
663
632
PyArrayMethod_Spec Spec = {
664
633
.name = " quad_comp" ,
0 commit comments