This is related to
supporting quads on 32 bit Perl. I believe that in all perls, the highest numeric data unit is a 8 byte double. I have a C library that takes and returns 128 bit SSE2 data. The library looks at the 128 bit value as a union of various things, sometimes its an array of 4 floats, an array of 16 chars, an array of 2 doubles, array of 2 64 bit integers or 1 128bit integer or 1 128 bit floating point, depending on a bitfield passed to the function or depending on the function's name. All the values are little endian. I use perl on windows. What should my XS wrapper around this C library expose these 16 byte SSE2 variables as? There seems to be alot negativity over
Math::BigInt's bloatedness. Also how to do you load packed little endian numbers into Math::BigInt, it seems bigint only knows what big endian ASCII hex is for importing numbers. The solution should be CPAN grade. The SSE2 variables are very rarely used by this C library but they need to be exposed somehow for the rare case someone wants to call that function. The easiest thing is just have the user supply a 16 byte string and they get a 16 byte string in return. They have to pack and unpack the union array themselves. Is this the best solution? I think the most difficult solution to make but easiest to use is a tied hash that takes and returns BigInts. I couldn't find anything on CPAN that already does SSE or SSE2.
edit: I have SSE2 not SSE data
edit: Instead of a 16 byte string (primative), or a tied hash (complicated), I thought of the following,
#load it as 4 floats, a little bit of precision is lost
$obj = Local::SSE->new_fp(1.0, 2.0, 3.0, 4.0);
#load it as 2 doubles
$obj = Local::SSE->new_fp(1.0, 2.0);
#load it as 4 32 bit ints
$obj = Local::SSE->new_int(1, 2, 3, 4);
#load it as 2 64 bit ints, quad support perl required
$obj = Local::SSE->new_int(1, 2);
#load it raw
$obj = Local::SSE->new_raw("\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x
+00\x00\x00\x00\x00\x01");
#read as 4 shorts
@array = $obj->get_fp(4);
#read as 2 doubles
@array = $obj->get_fp(2);
#read as 4 32 bit ints
@array = $obj->get_int(4);
#read raw packed value
$packedSSEVal = $obj->get_raw();
Is this a better choice for an api?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.