New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
32-bit compatibility (64-bit gid on 32-bit architecture) #1065
32-bit compatibility (64-bit gid on 32-bit architecture) #1065
Conversation
- include stdint.h on 32-bit platforms - use uint64_t instead of unsigned long and size_t to ensure 64-bit data types also on 32-bit platforms
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
@apeyser please review the refactored version of the code. For the refactored experimental boost cpptests I suggest @jakobj as a reviewer. The 64-bit target-id layout can now be specified in a more generic way. Bit-masks and max-values are generated by const-expressions. I also removed some of the raw numbers to get rid of dangerous logical dependencies! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only one comment requires any response: whether cmake should just fail for 32-bit but non-ILP32 data model machines (the unlikely but technically possible case). Currently, it should compile properly rather than failing before fairly cryptically with a template error --- but maybe it should fail explicitly if someone where to try that (and maybe no one ever will).
@apeyser thanks for your comments! I have included your suggestions in the code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code bits look mostly OK to me. Has this been tested by CI on the different architectures? I'm testing it on the different arches Fedora supports at the moment. I'll have more to say once those builds finish.
set( CMAKE_EXTRA_INCLUDE_FILES "stdint.h" ) | ||
check_type_size( "long" LONG_SIZE ) | ||
if( NOT LONG_SIZE EQUAL 4 ) | ||
message( FATAL_ERROR "Platform not supported: None-ILP32 data model for 32 bit architecture." ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
message( FATAL_ERROR "Platform not supported: None-ILP32 data model for 32 bit architecture." ) | |
message( FATAL_ERROR "Platform not supported: Non-ILP32 data model for 32 bit architecture." ) |
@@ -53,6 +53,30 @@ if ( UINT16_T_SIZE GREATER 0 ) | |||
set( HAVE_UINT16_T ON ) | |||
endif () | |||
|
|||
set( CMAKE_EXTRA_INCLUDE_FILES "sys/types.h" ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering of this some comments should be added here just to make it easier for devs in the future to understand why this is here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This macro needs to be set up before check_type_size()
and loses scope after execution of check_type_size()
. This is CMake magic. I think it is clear what this part of the CMake script does. The rest is somehow CMake-technical and I tend not to begin documenting it.
Still getting build failures on the 2 32 bit architectures supported in Fedora: i686 and armv7hl:
I'm also uploading the build logs. These are "scratch" builds and will be deleted in few hours. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks a lot, new code looks good. test cases look solid 👍 i just have one small question
* Exception to be thrown if an internal error occures. | ||
* @ingroup KernelExceptions | ||
*/ | ||
class InternalError : public KernelException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this new exception? wouldn't a KernelException
by sufficient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are not all exceptions derived from the base class KernelException
? The enumeration that I introduced in targets.h
as well as the InternalError
exception should make the code more robust and easier to extend - just in case that there is more than a single status bit needed in future.
I'm afraid all the travis tests machines seem to be amd64 machines, so the tests don't really check these code changes. The code doesn't build in i686 and armv7hl for me (as commented above). Can someone please look at the attached logs to see if I've missed something there? |
@sanjayankur31 Ich checked the logs. The "constructor ambiguity" issue was one of the problems I also went into when testing on the 32-bit ARM Raspberry. It should be resolved. One of the warnings shows:
I removed that raw number from the code. Can you please check whether you ran your tests on the correct branch? |
@gtrensch ah, I think I may have run the build before those commits. I'll re-run with the latest one in your branch and report back. |
The latest builds for i686 and armvhl7 completed successfully: |
…ensch/nest-simulator into issue1031_64bitOn32bitSystem
The conflict is resolved. |
This pull request resolves #1031.
This pull request fixes an issue with compiling and running NEST on a 32-bit platform. It has been tested on a 32-bit ARM Raspberry Pi.
The source code changes do the following:
uint64_t
available instdint.h
.gid
explicitly as 64-bit. Both,unsigned long
andunsigend long long
are not appropriate for this. They are platform-dependent data types!uint64_t
might be equivalent tounsigned long
preventing overloading.I found that it is not needed for the moment to change the types of
index
andthread
as they are compiled from a subset of the bits still fitting 32-bit. Making thisuint64_t
breaks sli-types and will require more changes. Since we decided to follow the C++11 standard, I also introducedconstexpr
for the constant-definitions to ensure their evaluation at compile-time.