official-stockfish / Stockfish

A free and strong UCI chess engine
https://stockfishchess.org/
GNU General Public License v3.0
11.6k stars 2.28k forks source link

armv5 target #379

Closed ghost closed 8 years ago

ghost commented 9 years ago

I wanted to propose adding an armv5 target. Maybe nobody uses this except me, so I'm not sure how important this is. Anyway, here are the steps I use to compile stockfish on my kirkwood devices (armv5te).

Regarding step 1, I think that replacement might be preferable even for armv7. Recent gcc is smart enough to perform that optimization when it encounters __builtin_ctz(), so there should be no need to add the asm and subsequent clz call. This also applies to MIPS. But I don't want to hurt any armv7 performance if I'm wrong... Mostly I suggest checking this out and (probably) switching for all ARM.

Step 2.b is quite specific to the hardware I run and also (less so) to the gcc version I use. (I use 4.8.x and greater) So 2.b is probably not recommended to be added in its entirety. Perhaps -mtune=armv5 would be best here. Probably -fno-caller-saves is universally useful too. I don't think PIE matters for armv5 which is why you don't see that anywhere.

So here's the steps I take when compiling for kirkwood:

1) update bitboard.h

Replace

    inline int lsb32(uint32_t v) {
      __asm__("rbit %0, %1" : "=r"(v) : "r"(v));
      return __builtin_clz(v);
    }

With

    inline int lsb32(uint32_t v) {
      return __builtin_ctz(v);
    }

2) update Makefile

a) add configuration for armv5 target somewhere near the similar armv7 conf

            ifeq ($(ARCH),armv5)
                    arch = armv5
                    prefetch = yes
                    bsfq = yes
            endif

b) armv5 CXXFLAGS specific to this device and gcc version ifeq ($(arch),armv5) CXXFLAGS += -pipe -march=armv5te -mtune=xscale -fweb -fno-caller-saves -frename-registers -fomit-frame-pointer endif

c) add armv5 target to the help section near armv7

            @echo "armv5                   > ARMv5 32-bit"

d) include armv5 in the sanity check @test "$(arch)" = "ppc64" || test "$(arch)" = "ppc" || test "$(arch)" = "armv7" || test "$(arch)" = "armv5"

3) build

make profile-build ARCH=armv5

zamar commented 8 years ago

I suspect that hardly anyone would be using armv5 target. At least no one has shown interest in this.

Thus I'm closing this issue. Feel free to reopen if there is a genuine interest in this target.