Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
15 user(s) are online (9 user(s) are browsing Forums)

Members: 3
Guests: 12

mbrantley, Paul, TearsOfMe, more...

Support us!

Headlines

 
  Register To Post  

« 1 2 3 (4) 5 »
Re: A1222 support in the SDK and problems
Quite a regular
Quite a regular


See User information
I tried to link it with gcc 11.2 and 10.3, still receive allingnment error.
Next I will try pointers workaround.

@all, thanks for advice

AmigaOS3: Amiga 1200
AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000
MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Go to top
Re: A1222 support in the SDK and problems
Just can't stay away
Just can't stay away


See User information
@sailor

You could use a method similar to what has been used in m68k-amigaos C code to allocate long word aligned structures like FileInfoBlock from the stack:

static char align_buffer[3*sizeof(double)-1];
double *T1ptr;
double *T2ptr;
#define T1 (*T1ptr)
#define T2 (*T2ptr)

__attribute__((constructor))
static 
void __init_T1T2(void)
{
    
T1ptr = (double *)(((uintptr_t)align_buffer sizeof(double) - 1) & ~(sizeof(double) - 1));
    
T2ptr T1ptr 1;
}


If T1 and T2 were arrays instead of simple double variables you could even make use of C's pointer/array equivalence to get rid of the ugly macros.

Go to top
Re: A1222 support in the SDK and problems
Quite a regular
Quite a regular


See User information
@salass00
interesting idea - many thanks. For the first time I heard about constructor attribute. Looks nice, on weekend I will test.

Before you post this advice, I had in plan more dirty solution, something like:
double Tarray[3];
double *pT,*pT1;
pT= (double*)((long)(Tarray +1) - (long)(Tarray % 8));
pT1= pT+1;

Thx!


Edited by sailor on 2025/1/24 20:47:35
Edited by sailor on 2025/1/24 20:48:45
Edited by sailor on 2025/1/24 20:53:08
Edited by sailor on 2025/1/24 20:53:41
AmigaOS3: Amiga 1200
AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000
MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Go to top
Re: A1222 support in the SDK and problems
Quite a regular
Quite a regular


See User information
@salass00
thanks, it works nice!
For global vars and global arrys too.


Edited by sailor on 2025/1/25 12:58:29
Edited by sailor on 2025/1/25 12:58:47
AmigaOS3: Amiga 1200
AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000
MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Go to top
Re: A1222 support in the SDK and problems
Quite a regular
Quite a regular


See User information
@salass00Quote:
salass00 wrote:@sailor

You could use a method similar to what has been used in m68k-amigaos C code to allocate long word aligned structures like FileInfoBlock from the stack:

static char align_buffer[3*sizeof(double)-1];
double *T1ptr;
double *T2ptr;
#define T1 (*T1ptr)
#define T2 (*T2ptr)

__attribute__((constructor))
static 
void __init_T1T2(void)
{
    
T1ptr = (double *)(((uintptr_t)align_buffer sizeof(double) - 1) & ~(sizeof(double) - 1));
    
T2ptr T1ptr 1;
}


If T1 and T2 were arrays instead of simple double variables you could even make use of C's pointer/array equivalence to get rid of the ugly macros.


If I used single dimension array, as you said alignment is easy for array[A]:
static char align_buffer[(A+1)*sizeof(double)-1];
double *array;
__attribute__((constructor))
static 
void __init_array(void)
{
    array = (
double *)(((uintptr_t)align_buffer sizeof(double) - 1) & ~(sizeof(double) - 1));
}


And please, how it will work for multidimensional arrays - like array[A][B][C]? Should I use this?
static char align_buffer[(A*B*C+1)*sizeof(double)-1];
double (*array)[A][B][C];
__attribute__((constructor))
static 
void __init_array(void)
{
    array = (
double *)(((uintptr_t)align_buffer sizeof(double) - 1) & ~(sizeof(double) - 1));
}

and in the rest of code use normally array[a][b][c] ?

AmigaOS3: Amiga 1200
AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000
MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Go to top
Re: A1222 support in the SDK and problems
Just can't stay away
Just can't stay away


See User information
@sailor

I could be wrong but I don't think definining a pointer to a multi-dimensional array will work. In my experience multi-dimensional arrays in C are quite limited in how they can be used so I almost never use them in my code.

What should work however is something like (not quite as elegant):
static char align_buffer[(A*B*C+1)*sizeof(double)-1];
double *array[A][B];
__attribute__((constructor))
static 
void __init_array(void)
{
    
double *= (double *)(((uintptr_t)align_buffer sizeof(double) - 1) & ~(sizeof(double) - 1));
    
int ij;

    for (
0Ai++)
    {
        for (
0Bj++)
        {
            array[
i][j] = p;
            
+= C;
        }
    }
}

Go to top
Re: A1222 support in the SDK and problems
Just popping in
Just popping in


See User information
How can we get a fixed version of GCC to avoid all these workarounds/hacks?
Is there a guy able to fix it for a native version of GCC?

Memento audere semper!
Go to top
Re: A1222 support in the SDK and problems
Quite a regular
Quite a regular


See User information
@flash
native SPE version of gcc libraries will be fine, of course.
NXP had CodeWarrior IDE for SPE in past, but there were other compiller than gcc.
It will solve workarounds with float / double calls.

But global variable alignment error is probably directly in gcc - linking script error like salass00 said.

AmigaOS3: Amiga 1200
AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000
MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Go to top
Re: A1222 support in the SDK and problems
Home away from home
Home away from home


See User information
@sailor

static char align_buffer[3*sizeof(double)-1];


-1 ??


char does NOT add a extra 0\,
its not a string, so why do you want on less char?
a string is a class, not a array for chars.

GCC should automatilcy allign data, and you can use compiler options for it, "packed".

https://gcc.gnu.org/onlinedocs/gcc-4.0.1/gcc/Type-Attributes.html

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: A1222 support in the SDK and problems
Quite a regular
Quite a regular


See User information
@LiveForItQuote:
LiveForIt wrote:@sailor
static char align_buffer[3*sizeof(double)-1];

-1 ??
char does NOT add a extra 0\,
its not a string, so why do you want on less char?
a string is a class, not a array for chars.

This is code from salass00 hint (see above). If I understand it correctly, "-1" is here to allocate only needed memory, not more:
allign_buffer should have size at least ( nr.of variables + 1 )*( sizeof(variable)) - we need to shift variable to correct aligned address.
If variable is not correctly alligned, is shifted of certain nr. of bytes ( i.e. maximally of var.size -1 ). Shifting of var.size have no sense, because it have the same alignment like original. Thus we allocated one byte less.
Of course, if var.size is less then 8 bytes, this shape should be corrected a little.
Quote:
GCC should automatilcy allign data, and you can use compiler options for it, "packed".

https://gcc.gnu.org/onlinedocs/gcc-4.0.1/gcc/Type-Attributes.html

Yes, in theory. Please, see post nr.53. Aligning not works always for global variables. In that case I need 8-byte alignment for experiments with SPE SIMD unit.
And this workaround helps me much.
This error is connected to gcc linker script ( see comment )

AmigaOS3: Amiga 1200
AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000
MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Go to top
Re: A1222 support in the SDK and problems
Just can't stay away
Just can't stay away


See User information
@LiveForIt

Quote:

its not a string, so why do you want on less char?


I'm not allocating one byte less, I'm allocating sizeof(double)-1 bytes more than needed. This is to ensure that a double (8-byte) aligned address of the required size can always be found within the aligned buffer no matter what the alignment of the array itself is.

Quote:

GCC should automatilcy allign data, and you can use compiler options for it, "packed".


It should but it doesn't.

Using my own compiled test code as example:

While the .data section itself is 16-byte aligned to the start of the executable file:
Section Headers:
  [
NrName              Type            Addr     Off    Size     
  
6] .ctors            PROGBITS        01011094 001094 000008 00  WA  0   0  4
  
7] .dtors            PROGBITS        010110900109000008 00  WA  0   0  4
  
8] .data             PROGBITS        010110b0 0010b0 000010 00  WA  0   0 16


it is preceeded in the segment by .ctors and .dtors sections which are only 4-byte aligned (see above):
Section to Segment mapping:
  
Segment Sections...
   
00     .text .rodata .__newlib_version 
   01     
.ctors .dtors .data .sbss


The result is that when elf.library loads the entire segment 32-byte aligned the .data section gets loaded into it at offset 10b0-1094=1c which is only 4-byte aligned.

Go to top
Re: A1222 support in the SDK and problems
Just can't stay away
Just can't stay away


See User information
@LiveForIt
Quote:
GCC should automatilcy allign data, and you can use compiler options for it, "packed".
"packed" (__attribute__, #pragma, etc.) can only be used to reduce alignment, for example from 4 bytes integer default on PPC to 2 bytes (for compatibility to m68k, as used in most exec, etc. includes), but not to increase alignment.

@salass00
Quote:
The result is that when elf.library loads the entire segment 32-byte aligned the .data section gets loaded into it at offset 10b0-1094=1c which is only 4-byte aligned.
Still sounds like a linker script bug to me, missing or wrong align for .ctors/.dtors, not a bug in gcc, binutils (ld) nor elf.library.
However the last time I worked on it in the AmigaOS 4.x ports was IIRC gcc 2.95.x/binutils 2.14.x versions, i.e. about 20 years ago...


Edited by joerg on 2025/2/5 18:59:54
Go to top
Re: A1222 support in the SDK and problems
Amigans Defender
Amigans Defender


See User information
We'll take care of it

i'm really tired...
Go to top
Re: A1222 support in the SDK and problems
Just popping in
Just popping in


See User information
So someone could try to compile and assemble SPE code with native GCC 4 and link objects with GCC 11.
If problem rely on linker, and if it's a text file it could be easily fixed with a diff between GCC4 and GCC11 linker cfg text files

Memento audere semper!
Go to top
Re: A1222 support in the SDK and problems
Just popping in
Just popping in


See User information
@all

I have binutils version v2.40 adapted to align
.ctor/.dtor
section to 32.

I installed them in my test SDK and compiles the Stream source. It links and seems to be 32 bit align.
But even the pre build binary from os4depot are already align. So someone needs to try out the binutils
and see if the alignment stuff helps.

If someone installs these bintuils, I recommend to backup the old files. It still is development in progress with these binutils.

Installation

Unzip the content into
GCC:ppc-amigaos
(Backup the directory, to be able to revert the installation)

Additional put
.unix
file into
GCC:ppc-amigaos/bin
, because the binutils cannot handle native unix paths.
And thus you need a reason released
clib4.library


That should do it. Here the binutils can be downloaded. If the link has expired, repost here or DM me and I will updated the link.

Go to top
Re: A1222 support in the SDK and problems
Just popping in
Just popping in


See User information
@MigthyMax

Your work should be tested by a1222 owners and if confirmed it's working ok than could be adopted to build a1222 specific binaries.
IMHO it should be ok also for building standard os4 binaries.
Thanks a lot for your efforts!

Go to top
Re: A1222 support in the SDK and problems
Just can't stay away
Just can't stay away


See User information
@MigthyMax
For the 405 CPUs with "external" FPU (440, 460) 32 bit alignment isn't enough, all FPU accesses have to be cache-line aligned, i.e. at least sizeof(double) * 8 bit = 64 bit alignment is required.
If a FPU access is crossing a cache line boundary you get an alignment exception. It's handled by the 4x0 kernel (and my powerpc.library) exception handlers, but that's very slow.

CPUs with 64 byte cache line sizes like the ones in the X1000 and X5000 may even need larger alignment for max. performance, especially in case of the X1000 if AltiVec code is used.

I don't know what the alignment requirements for SPE code on the A1222+ are, but if you use 64 bytes = 512 bits alignment it should work on all supported CPU.

Something A1222+ developers might try, if it's still supported by elf.library, is building ELF REL instead of ELF EXEC executables.
ELF REL was only used in the very early days of AmigaOS 4.x, about 25 years ago, instead of ELF EXEC, but IIRC with ELF REL "executables" all segments were loaded into separate pages, i.e. you have 4096 bytes alignment for everything.

Go to top
Re: A1222 support in the SDK and problems
Quite a regular
Quite a regular


See User information
@MigthyMax
I will gladly test in weekend. Many thanks!
But in gcc:ppc-amigaos there are only two subdirs bin and lib with different gcc versions. Really it should be copied there?
And please, where to obtain clib4? I am afraid, maybe I need some more detailed instructions...

gcc:ppc-amigaos/ directory:
4.Work:SDK/gcc/ppc-amigaosdir all
     bin 
(dir)
          
10.3.0 (dir)
            
ppc-amigaos-c++-10        ppc-amigaos-cpp-10        ppc-amigaos-gcc-10        ppc-amigaos-gcc-ar-10     ppc-amigaos-gcc-nm-10
            ppc
-amigaos-gcc-ranlib-10 ppc-amigaos-gcov-10       ppc-amigaos-gcov-dump-10  ppc-amigaos-gcov-tool-10
          11.2.0 
(dir)
            
ppc-amigaos-c++-11        ppc-amigaos-cpp-11        ppc-amigaos-gcc-11        ppc-amigaos-gcc-ar-11     ppc-amigaos-gcc-nm-11
            ppc
-amigaos-gcc-ranlib-11 ppc-amigaos-gcov-11       ppc-amigaos-gcov-dump-11  ppc-amigaos-gcov-tool-11
          6.4.0 
(dir)
            
ppc-amigaos-c++-6        ppc-amigaos-cpp-6        ppc-amigaos-gcc-6        ppc-amigaos-gcc-ar-6     ppc-amigaos-gcc-nm-6
            ppc
-amigaos-gcc-ranlib-6 ppc-amigaos-gcov-6       ppc-amigaos-gcov-dump-6  ppc-amigaos-gcov-tool-6
          8.4.0 
(dir)
            
ppc-amigaos-c++-8        ppc-amigaos-cpp-8        ppc-amigaos-gcc-8        ppc-amigaos-gcc-ar-8     ppc-amigaos-gcc-nm-8
            ppc
-amigaos-gcc-ranlib-8 ppc-amigaos-gcov-8       ppc-amigaos-gcov-dump-8  ppc-amigaos-gcov-tool-8
          lib 
(dir)
               
ppc-amigaos (dir)
                    
10.3.0 (dir)
                      
gthr-amigaos-native.<sl>   gthr-amigaos-single.<sl>
                    
11.2.0 (dir)
                      
gthr-amigaos-native.<sl>   gthr-amigaos-single.<sl>
                    
8.4.0 (dir)
                      
gthr-amigaos-native.<sl>   gthr-amigaos-single.<sl>
          
libexec (dir)
               
gcc (dir)
                    
ppc-amigaos (dir)
                         
10.3.0 (dir)
                              
install-tools (dir)
                                
fixinc.sh     fixincl       mkheaders     mkinstalldirs
                           cc1              cc1plus          liblto_plugin
.a  liblto_plugin.la lto-wrapper      lto1
                         11.2.0 
(dir)
                              
install-tools (dir)
                                
fixinc.sh     fixincl       mkheaders     mkinstalldirs
                           cc1              cc1plus          liblto_plugin
.a  liblto_plugin.la lto-wrapper      lto1
                         6.4.0 
(dir)
                              
install-tools (dir)
                                
fixinc.sh     fixincl       mkheaders     mkinstalldirs
                           cc1              cc1plus          liblto_plugin
.a  liblto_plugin.la lto-wrapper      lto1
                         8.4.0 
(dir)
                              
install-tools (dir)
                                
fixinc.sh     fixincl       mkheaders     mkinstalldirs
                           cc1              cc1plus          liblto_plugin
.a  liblto_plugin.la lto-wrapper      lto1
       ar      
as      ld      ld.bfd  nm      objcopy objdump ranlib  strip
     lib 
(dir)
          
ldscripts (dir)
            
amigaos.x    amigaos.xbn  amigaos.xd   amigaos.xn   amigaos.xr   amigaos.xs   amigaos.xu   elf32ppc.x   elf32ppc.xbn elf32ppc.xc
            elf32ppc
.xd  elf32ppc.xdc elf32ppc.xdw elf32ppc.xn  elf32ppc.xr  elf32ppc.xs  elf32ppc.xsc elf32ppc.xsw elf32ppc.xu  elf32ppc.xw
4.Work
:SDK/gcc/ppc-amigaos>

AmigaOS3: Amiga 1200
AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000
MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Go to top
Re: A1222 support in the SDK and problems
Quite a regular
Quite a regular


See User information
@joergQuote:
joerg wrote:
CPUs with 64 byte cache line sizes like the ones in the X1000 and X5000 may even need larger alignment for max. performance, especially in case of the X1000 if AltiVec code is used.

For SPE it is similar: it needs 8-byte alignment to work properly and 32-bit alignment for best performance.

AmigaOS3: Amiga 1200
AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000
MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Go to top
Re: A1222 support in the SDK and problems
Just popping in
Just popping in


See User information
@joerg

Just to clarify the alignment I can adjust in the binutils ld linker is the alignment of the sections.

The alignment of individual defined variables within a program is probably handled by the c compiler and can be influenced by
the developer using the __attribute__((aligned(x)).

Of course the later somehow arranges all variables into the .data/.rodata section and than the linker aligns the section,
and if the section isn't aligned correctly all variables align by the compiler gets out fo alignment.

Quote:
For the 405 CPUs with "external" FPU (440, 460) 32 bit alignment isn't enough, all FPU accesses have to be cache-line aligned, i.e. at least sizeof(double) * 8 bit = 64 bit alignment is required.
If a FPU access is crossing a cache line boundary you get an alignment exception. It's handled by the 4x0 kernel (and my powerpc.library) exception handlers, but that's very slow.

CPUs with 64 byte cache line sizes like the ones in the X1000 and X5000 may even need larger alignment for max. performance, especially in case of the X1000 if AltiVec code is used.

I don't know what the alignment requirements for SPE code on the A1222+ are, but if you use 64 bytes = 512 bits alignment it should work on all supported CPU.


It sounds like that in the current linker script it, takes care of this, because lot of section etc is aligned with these configuration:

MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE})"


where SEGMENT_SIZE is/should be the TARGET_PAGE_SIZE.

What is the page size of our beloved target?

@sailor

I think it is the correct installation directory, the sub directory gcc version "only" contains the compiler. The important thing
is that the new binutils get picked up. This can be checked with adding verbose output (-v) during compiling or adding to the
link call. Than teh version will be output, which should be 2.40.

Here you fin the latest released clib4 version.

Quote:
AmigaOS 4.x uses the SysV PowerPC ABI, should be the same as AIX.
Only exceptions are R2 and R13, which aren't used at all (default) or as relative (small) data pointer: R13 when using -msdata, R2 when using -mbaserel.
http://refspecs.linux-foundation.org/elf/elfspec_ppc.pdf pages 30-32


Additional I try to collect all information about the ABI and Amiga Specific stuff here

Contributions/Corrections ar welcome

Go to top

  Register To Post
« 1 2 3 (4) 5 »

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project