[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Atlas: Help with s390 ASM

On Wed, 27 Jan 2010 18:39:31 -0500, Sylvestre Ledru wrote:
> Hello,
> I am trying to port the new version of Atlas on all Debian architectures
> [1]. 
> I am starting to try to fix s390 which is one of the non-supported archs
> of Atlas and I need your help to translate some x86 asm to s390.
> Atlas is an auto-optimized library. At the beginning of the script,
> atlas launch a script to check what is the CPU architecture, the
> optimisation available, etc. 
> One of the first check is the CPU. It is done in ASM.
> For example, the code for x86 is:
> --------
> #include "atlas_asm.h"
> #
> # x86-32 assembler for:
> # int asm_probe(int i)
> # RETURNS: i*3
> #
> .text
> .globl ATL_asmdecor(asm_probe)
> ATL_asmdecor(asm_probe):
>         movl    4(%esp), %eax
>         movl    %eax, %ecx
>         shl     $1, %eax
>         addl    %ecx, %eax
>         ret
> ---------
> while the PPC is:
> ---------
> #define ATL_GAS_PPC
> #include "atlas_asm.h"
> /*
>  * Linux PPC assembler for:
>  * int asm_probe(int i)
>  * RETURNS: i*3
>  */
> .globl ATL_asmdecor(asm_probe)
> ATL_asmdecor(asm_probe):
>         add     r4, r3, r3
>         add     r3, r3, r4
>         blr
> ---------
> I would like to know if someone could translate that for me to s390 ?
> If someone needs it, the procedure to reproduce the failure with atlas
> is:
> $ apt-get source -t experimental atlas
> $ cd atlas-*
> $ gcc -I CONFIG/include/ -o xprobe_gas_s390
> CONFIG/src/backend/probe_this_asm.c
> CONFIG/src/backend/probe_gas_CHANGE_HERE.S
> Many thanks!
> Please C/C me.
> Thanks
> Sylvestre
> [1] https://buildd.debian.org/status/package.php?suite=experimental&p=atlas

Hello, Sylvestre.

I know s390 assembler language well.  Unfortunately, I don't x86
assembler language at all -- or PPC assembler language.  And I don't know C either.
And that is the problem.

Finding someone who knows both the Linux world *AND* the s390 world
is very difficult.  There aren't that many people who know both worlds well.
The definitive documentation for s390 machine and assembly instructions is
an IBM manual called "z/Architecture Principles of Operation" (SA22-7832).
At the time of this writing, suffix -06 is the current revision.
(Of course there are secret, proprietary instructions which aren't documented
there, but that's another story).
I was going to give you a link to a PDF copy of the manual,
But it's not working for me right now for some reason.  I'm not sure why.

One of the issues you're going to run into is privileged vs. non-privileged
instructions.  For the most part, privileged instructions can only be
executed by a kernel module, not a user-space program.  Maybe if you're root
you can execute a privileged instruction, I don't know.  Anyway, there is
an assembler instruction called STORE CPU ID (mnemonic STIDP).  But it is
privileged.  The kernel issues one of these during initialization and you
may be able to extract that information from a kernel control block
somehow, but issuing it from a user-space program run by an ordinary user
almost certainly won't work.

Maybe you can get the information that you need by reading the right
pseudo-files in the /proc or /sys pseudo-filesystems.  Then you won't
need to resort to assembler.  Just a thought.  If you can give me a
specific list of the information it wants, maybe I can tell you where to
find that information in /proc or /sys files.

Reply to: