@@ -397,11 +397,12 @@ static int
397397quad_ufunc_promoter (PyUFuncObject *ufunc, PyArray_DTypeMeta *op_dtypes[],
398398 PyArray_DTypeMeta *signature[], PyArray_DTypeMeta *new_op_dtypes[])
399399{
400+ printf (" called comparison promoter\n " );
400401 int nin = ufunc->nin ;
401402 int nargs = ufunc->nargs ;
402403 PyArray_DTypeMeta *common = NULL ;
403404 bool has_quad = false ;
404-
405+ printf ( " dtyp1: %s dtype2: %s \n " , get_dtype_name (op_dtypes[ 0 ]), get_dtype_name (op_dtypes[ 1 ]));
405406 // Handle the special case for reductions
406407 if (op_dtypes[0 ] == NULL ) {
407408 assert (nin == 2 && ufunc->nout == 1 ); /* must be reduction */
@@ -415,6 +416,7 @@ quad_ufunc_promoter(PyUFuncObject *ufunc, PyArray_DTypeMeta *op_dtypes[],
415416 // Check if any input or signature is QuadPrecision
416417 for (int i = 0 ; i < nin; i++) {
417418 if (op_dtypes[i] == &QuadPrecDType) {
419+ printf (" Quaddtype found at index: %d\n " , i);
418420 has_quad = true ;
419421 }
420422 }
@@ -431,7 +433,6 @@ quad_ufunc_promoter(PyUFuncObject *ufunc, PyArray_DTypeMeta *op_dtypes[],
431433 }
432434 else if (common != signature[i]) {
433435 Py_CLEAR (common); // Not homogeneous, unset common
434-
435436 break ;
436437 }
437438 }
@@ -459,6 +460,7 @@ quad_ufunc_promoter(PyUFuncObject *ufunc, PyArray_DTypeMeta *op_dtypes[],
459460 else {
460461 // Otherwise, use the common dtype
461462 Py_INCREF (common);
463+ printf (" setting output to %s dtype\n " , get_dtype_name (common));
462464 new_op_dtypes[i] = common;
463465 }
464466 }
@@ -560,42 +562,9 @@ init_quad_binary_ops(PyObject *numpy)
560562
561563template <cmp_quad_def sleef_comp, cmp_londouble_def ld_comp>
562564int
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)
599568{
600569 npy_intp N = dimensions[0 ];
601570 char *in1_ptr = data[0 ], *in2_ptr = data[1 ];
@@ -617,6 +586,7 @@ quad_generic_comp_strided_loop_unaligned(PyArrayMethod_Context *context, char *c
617586 *((npy_bool *)out_ptr) = sleef_comp (&in1.sleef_value , &in2.sleef_value );
618587 }
619588 else {
589+ printf (" %Lf % Lf\n " , in1.longdouble_value , in2.longdouble_value );
620590 *((npy_bool *)out_ptr) = ld_comp (&in1.longdouble_value , &in2.longdouble_value );
621591 }
622592
@@ -632,7 +602,6 @@ comparison_ufunc_promoter(PyUFuncObject *ufunc, PyArray_DTypeMeta *op_dtypes[],
632602 PyArray_DTypeMeta *signature[], PyArray_DTypeMeta *new_op_dtypes[])
633603{
634604 PyArray_DTypeMeta *new_signature[NPY_MAXARGS];
635-
636605 memcpy (new_signature, signature, 3 * sizeof (PyArray_DTypeMeta *));
637606 new_signature[2 ] = NULL ;
638607 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)
654623
655624 PyArray_DTypeMeta *dtypes[3 ] = {&QuadPrecDType, &QuadPrecDType, &PyArray_BoolDType};
656625
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 }};
662631
663632 PyArrayMethod_Spec Spec = {
664633 .name = " quad_comp" ,
0 commit comments