This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Parameters for AArch64 processor

Hello,
I'm trying to compile an old code with an AArch64 processor but it's leading to memory leaks. After some troubleshooting, I have been able to locate one potential hot spot that includes the following definitions:

#define	MAXCHAR		255
#define	MAXSHORT	32767
#define MINSHORT	-32768
#define MAXTABLE	32500
#define BITS_PER_WORD	32
#define	WORDSIZE(n)	(((n)+(BITS_PER_WORD-1))/BITS_PER_WORD)
#define	BIT(r, n)	((((r)[(n)>>5])>>((n)&31))&1)
#define	SETBIT(r, n)	((r)[(n)>>5]|=((unsigned)1<<((n)&31)))

These values are unlikely to be accurate for an AArch64 CPU and I was wondering if anyone has any suggestions on what values to assign (note: the compiler is GCC-11). Thank you.  

Parents
  • Is the code part of Berkeley Yacc? Here they say that "BITS_PER_WORD is the number of bits in a C unsigned". The size of unsigned on aarch64 is 32 bits, so the definitions remain valid. Moreover, armv8 defines the "Word" datatype as an integer of size 32 bits, which coincides with the definition of the word as utilized by the program.

    The term WORD in the snippet does not seem to mean the actual machine word, which is indeed 64 bits in size for aarch64.

    As long as the parameters passed to these macros are unsigned integers or arrays of unsigned integers, the program should behave properly. For instance, the function set_EFF in here calls SETBIT on an array of unsigned; the function should behave as expected on aarch64 without any changes.

    Edit: The comments inside defs.h do seem to say that these definitions are 'machine-dependent'. Even if we assume that the term WORD implies the machine word, no changes are necessary for aarch64. The C unsigned type is at least 16 bits; the code might have, at one point in time, tried to optimize itself by creating arrays of machine-word-sized integers, where the machines had either 16-bit machine-word, or 32-bit machine word, and where the size of unsigned differed respectively. Although the machine word on aarch64 is 64-bit in size, the unsigned 'abstraction' is still 32-bit, and aarch64 does allow accessing the lower 32-bit portion of its 64-bit registers by accessing w###.

    Edit2: The code base within FreeBSD source is likely to have fixes that may help run the program on 64-bit architectures.

Reply
  • Is the code part of Berkeley Yacc? Here they say that "BITS_PER_WORD is the number of bits in a C unsigned". The size of unsigned on aarch64 is 32 bits, so the definitions remain valid. Moreover, armv8 defines the "Word" datatype as an integer of size 32 bits, which coincides with the definition of the word as utilized by the program.

    The term WORD in the snippet does not seem to mean the actual machine word, which is indeed 64 bits in size for aarch64.

    As long as the parameters passed to these macros are unsigned integers or arrays of unsigned integers, the program should behave properly. For instance, the function set_EFF in here calls SETBIT on an array of unsigned; the function should behave as expected on aarch64 without any changes.

    Edit: The comments inside defs.h do seem to say that these definitions are 'machine-dependent'. Even if we assume that the term WORD implies the machine word, no changes are necessary for aarch64. The C unsigned type is at least 16 bits; the code might have, at one point in time, tried to optimize itself by creating arrays of machine-word-sized integers, where the machines had either 16-bit machine-word, or 32-bit machine word, and where the size of unsigned differed respectively. Although the machine word on aarch64 is 64-bit in size, the unsigned 'abstraction' is still 32-bit, and aarch64 does allow accessing the lower 32-bit portion of its 64-bit registers by accessing w###.

    Edit2: The code base within FreeBSD source is likely to have fixes that may help run the program on 64-bit architectures.

Children