Some time ago Armin wrote:
>[SNIP] let me first
>describe a quick solution that would probably still give a serious
>speedup to all FP operations.
I'm attempting to do this on the theory that as I work on the little pieces,
I may absorb enough by osmosis to understand how Psyco actually works. This
may be false, but perhaps I can accomplish something useful anyway. If
someone else is already working on this, let me know and I'll try something
else. I'm sure I'll be asking for guidance repeatedly, but I'll try not to
be too much of a pest...
These parts are 'done' (they will certainly require some debugging):
* cimpl_fp_XXX
* PsycoFloat_FROM_DOUBLE()
* PsycoFloat_AS_DOUBLE_1() and PsycoFloat_AS_DOUBLE_2()
Hmmm.... that list looks awfully short so far ... sigh. Anyway, my question
for today involves ploat_add and friends. Armin suggested:
>2) metaimplementation: just like we have pint_add()&co, we need
>pfloat_add()&co. A priori, pfloat_add() is something like:
>
>static vinfo_t* pfloat_add(PsycoObject* po, vinfo_t* v, vinfo_t* w)
>{
> vinfo_t *a1, *a2, *b1, *b2, *x;
> vinfo_array_t* result;
> a1 = PsycoFloat_AS_DOUBLE_1(po, v);
> a2 = PsycoFloat_AS_DOUBLE_2(po, v);
> b1 = PsycoFloat_AS_DOUBLE_1(po, w);
> b2 = PsycoFloat_AS_DOUBLE_2(po, w);
> /* ... */
>}
Is there any reason that this can't be done in the same way as pint_add. For
example:
static vinfo_t* pfloat_add(PsycoObject* po, vinfo_t* v, vinfo_t* w)
{
vinfo_t *a1, *a2, *b1, *b2, *x;
vinfo_array_t* result;
CONVERT_TO_DOUBLE(v, a1, a2);
CONVERT_TO_DOUBLE(w, b1, b2);
/* ... */
}
Where CONVERT_TO_DOUBLE would start out as:
define CONVERT_TO_DOUBLE(vobj, vlng1, vlng2) \
if (Psyco_TypeSwitch(po, vobj, &psyfs_float) == 0) { \
PsycoFloat_AS_DOUBLE(po, vobj1, vobj2); \
if (vlng1 == NULL  vlng2 == NULL) \
return NULL; \
} \
else { \
if (PycException_Occurred(po)) \
return NULL; \
vinfo_incref(psyco_viNotImplemented); \
return psyco_viNotImplemented; \
}
Eventually it would get extended as we allowed integers and other types to
be converted to floats. psyfs_float would have to be defined in pobject.c
and presumably entered into some array of fixed_switch values somewhere, but
I haven't got that far yet.
Is this a reasonable way to approach this if my goal is to first get
floatfloat operations working and then to branch out from there, or am I
way off target here....
Thanks,
tim
