Re: Any libraries for vector mask and vector population count?



Dan wrote:
Hi Tim and Dan,

I have some legacy code which includes calls to the CAL2 vector mask
and vector population count instructions. Lacking a nearby Cray, does
anyone know of subroutines that implement these instructions?
IIRC, vector mask is close to the standard merge().
Perhaps *** can recall better them I can.


Perhaps I'm wrong, but as I read the standard, both MERGE() and
MERGE_BITS() both want to play with integers. The standard explicitly
says

Yeah, you're wrong ;). MERGE takes any type (or kind) of arguments
for the first two (as long as they are of the same kind) and a logical
for the third. MERGE_BITS is a tough one to use; it's a Fortran 2008
function and it's going to be a while before there's a F2008 compiler.



Arguments (for MERGE_BITS)
I shall be of type integer or a boz-literal-constant.

J shall be of type integer or a boz-literal-constant.
If both I and J are of type integer they shall have the same
kind type parameter.
******** I and J shall not both be boz-literal-
constants.**********************************
(boz == binary, octal, hex)

Result Characteristics.
Same as I if I is of type integer; otherwise, same as J.
Result Value.
If any argument is a boz-literal-constant,
*************it is first converted as if by the intrinsic function INT
**********************
to the type and kind type parameter of the result. The
result has the value of
IOR (IAND (I,MASK), IAND (J, NOT (MASK))).


I'm probably missing something obvious, but this is not good. My data
are all four-bit values, and the original idea was somewhat like a
systolic array. Just keep reloading the second vector (J, in the terms
of the standard) do the mask, do the popcount, reload J with the next
set of bits. (Highly simplified, please let me know if I haven't
conveyed the idea clearly). There is already a tremendous amount of
bookkeeping going on, and I would prefer not to add a format
conversion (the implied INT) into the mix. Am I missing something?

I'm really lost about what you are trying to do. Could you give a
short code sample? On the one hand it sounds like you are doing
new code, and I thought your original message was about a legacy
code. But, I'm easily confused.

*** Hendrickson

Thanks again,
dan
.