Discussion:
Vector processing instructions
Add Reply
Amrith
2017-08-06 13:52:14 UTC
Reply
Permalink
Raw Message
Folks,
Recently I was working with vector processing on z13 and noticed that we have 128bit add and sub instructions but no multiply(correct me here but the multiply is on 64bit) or divide. Any idea on how to convert the 128bit signed/unsigned binary integer to packed decimal. If anyone is working with the vector instructions on z13 please IM me.

Thanks
Amrith

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Todd Arnold
2017-08-07 16:15:55 UTC
Reply
Permalink
Raw Message
I got this answer from someone else at IBM, who is an expert in the vector instructions:
"Currently to convert a 128-bit singed/unsigned integer in a vector register to a packed decimal value you must store the value to memory and use the standard integer conversion instruction CVBG to convert 64-bits at a time. A full 128-bit value will not fit into a 31-digit decimal number."

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Amrith
2017-08-07 16:47:38 UTC
Reply
Permalink
Raw Message
Thanks Todd. I think you are referring to CVDG which is what I had used but didn't yield the expected results. Splitting a 128bit binary integer into 2 64bits and then a CVDG didn't convert it as expected. I will probably try that out again. I used Java Big Integer for a simple 128bit arithmetic and the outputs from z13 and Java did not match.


--------------------------------------------
On Mon, 8/7/17, Todd Arnold <***@US.IBM.COM> wrote:

Subject: Re: Vector processing instructions
To: IBM-***@LISTSERV.UA.EDU
Date: Monday, August 7, 2017, 4:17 PM

I got this answer from someone else at IBM,
who is an expert in the vector instructions:
"Currently to convert a 128-bit
singed/unsigned integer in a vector register to a packed
decimal value you must store the value to memory and use the
standard integer conversion instruction CVBG to convert
64-bits at a time. A full 128-bit value will not fit into a
31-digit decimal number."

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff /
archive access instructions,
send email to ***@listserv.ua.edu
with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Paul Gilmartin
2017-08-07 16:50:05 UTC
Reply
Permalink
Raw Message
"Currently to convert a 128-bit singed/unsigned integer in a vector register to a packed decimal value you must store the value to memory and use the standard integer conversion instruction CVBG to convert 64-bits at a time. ...
Does "someone else" suggest working right-to-left or left-to-right? And there's
a trick needed to cross the boundary since 2**64 is not a power of 10. Would I
find an example if I RTFM PoOps?
... A full 128-bit value will not fit into a 31-digit decimal number."
... a tautology, since
2**127: 170141183460469231731687303715884105728
... is greater than
10**31: 10000000000000000000000000000000

-- gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Steve Smith
2017-08-07 19:01:52 UTC
Reply
Permalink
Raw Message
Maybe you could show your code. MP and DP can be tricky, but when you
CVDG the high D-word, you'd then multiply it by
9,223,372,036,854,775,808, then by 2 (or something equivalent). Add
to what you CVDG from the low D-word.

Of course, this will overflow if the value is too large for 31 digits,
and may get PD multiply exceptions for much less. You may have to do
some weaseling to make it work. Brute force would be multiplying the
converted high D-word by 2 64 times.

sas

On Mon, Aug 7, 2017 at 12:51 PM, Paul Gilmartin
Post by Paul Gilmartin
"Currently to convert a 128-bit singed/unsigned integer in a vector register to a packed decimal value you must store the value to memory and use the standard integer conversion instruction CVBG to convert 64-bits at a time. ...
Does "someone else" suggest working right-to-left or left-to-right? And there's
a trick needed to cross the boundary since 2**64 is not a power of 10. Would I
find an example if I RTFM PoOps?
... A full 128-bit value will not fit into a 31-digit decimal number."
... a tautology, since
2**127: 170141183460469231731687303715884105728
... is greater than
10**31: 10000000000000000000000000000000
-- gil
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
--
sas

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Paul Gilmartin
2017-08-07 20:00:28 UTC
Reply
Permalink
Raw Message
Post by Steve Smith
Maybe you could show your code. MP and DP can be tricky, but when you
CVDG the high D-word, you'd then multiply it by
9,223,372,036,854,775,808, then by 2 (or something equivalent). Add
to what you CVDG from the low D-word.
Of course, this will overflow if the value is too large for 31 digits,
and may get PD multiply exceptions for much less. You may have to do
some weaseling to make it work. Brute force would be multiplying the
converted high D-word by 2 64 times.
... which still overflows. Need to break the converted high D-word (which
can not exceed 20 digits) into two 10-bit chunks; multiply each by 2**64
(at most 30 digits), break the bottom one into tswo 10-digit pieces;
add the top 10 dights to the converted top half; and string everything
together.

This is simulating long multiplication.

-- gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Charles Mills
2017-08-09 11:04:39 UTC
Reply
Permalink
Raw Message
A 40-digit decimal number? Really?

The main advantage of binary integers is that they compute readily on a computer. The main advantage of decimal integers is that they are easy for humans to read. But 40-digit decimal numbers?

Charles

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-***@LISTSERV.UA.EDU] On Behalf Of Amrith
Sent: Sunday, August 6, 2017 9:49 AM
To: IBM-***@LISTSERV.UA.EDU
Subject: Vector processing instructions

Folks,
Recently I was working with vector processing on z13 and noticed that we have 128bit add and sub instructions but no multiply(correct me here but the multiply is on 64bit) or divide. Any idea on how to convert the 128bit signed/unsigned binary integer to packed decimal. If anyone is working with the vector instructions on z13 please IM me.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
John P. Baker
2017-08-10 03:21:00 UTC
Reply
Permalink
Raw Message
Amrith,

Converting a 128-bit unsigned fixed binary integer to packed decimal is not particularly difficult.

The following methodology should meet your needs -

IVFB - Input Value (128-bit Unsigned Fixed Binary)
WVFB - Working Value (128-bit Unsigned Fixed Binary)
AFPD - Adjustment Factor (11-byte Packed Decimal)
QUFB - Quotient (64-bit Unsigned Fixed Binary)
RMFB - Remainder (64-bit Unsigned Fixed Binary)
QUPD - Quotient (11-byte Packed Decimal)
RMPD - Remainder (10-byte Packed Decimal)
OVPD - Output Value (20-byte Packed Decimal)

WVFB = IVFB ;
AFPD = 0 ;
Do While (WVFB >= 100000000000000000000000000000000000000) ; /* (10**38) */
WVFB = (WVFB - 100000000000000000000000000000000000000) ; /* (10**38) */
AFPD = AFPD + 10000000000000000000 ; /* (10**19) */
End ;
Do While (WVFB >= 92233720368547758070000000000000000000) ; /* ((2**63) - 1) * (10**19) */
WVFB = WVFB - 10000000000000000000000000000000000000 ; /* (10**37) */
AFPD = AFPD + 1000000000000000000 ; /* (10**18) */
End ;
QUFB = WVFB / 10000000000000000000 ; /* (10**19) ; Remainder in "RMFB" */
QUPD = QUFB ; /* Convert to Packed Decimal */
RMPD = RMFB ; /* Convert to Packed Decimal */
QUPD = QUPD + AFPD ;
OVPD = QUPD (20 digits)) || RMPD (19 digits) ;

Please note than in the last pseudo-code instruction, the 19 digits of RMPD + the sign field fill ten (10) bytes. However, the sign field of QUPD must be ignored, so an MVO instruction can be used to shift the value one (1) nibble to the left. The QUPD value (after discarding the rightmost byte) can be appended to the front of RMPD, giving you a 30-byte packed decimal value. Please note that a packed decimal field of this length is NOT supported by IBM machine instructions except (I believe) for the ED/EDMK instructions ( I have not tested this).

The logic for converting a signed 128-bit value is slightly more complex, but is also do-able without any significant difficulty.

John P. Baker

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-***@LISTSERV.UA.EDU] On Behalf Of Amrith
Sent: Sunday, August 6, 2017 9:49 AM
To: IBM-***@LISTSERV.UA.EDU
Subject: Vector processing instructions

Folks,
Recently I was working with vector processing on z13 and noticed that we have 128bit add and sub instructions but no multiply(correct me here but the multiply is on 64bit) or divide. Any idea on how to convert the 128bit signed/unsigned binary integer to packed decimal. If anyone is working with the vector instructions on z13 please IM me.

Thanks
Amrith

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions, send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Loading...