The International Simutrans Forum

 

Author Topic: 64-bit version of Experimental?  (Read 9790 times)

0 Members and 1 Guest are viewing this topic.

Offline Carl

  • Devotee
  • *
  • Posts: 1599
    • Website
  • Languages: EN
64-bit version of Experimental?
« on: August 18, 2013, 09:41:22 AM »
Would it be possible for Experimental to support occupancy of more than 2GB of system RAM? I've been pushing near this limit on a couple of maps. While one can use certain third-party tools to unlock an executable for these purposes -- seemingly without error -- if it is a relatively simple change to make then it could be useful to have this supported natively.

This is, I suppose, a selfish request, but it might also be a good exercise in future-proofing the program. It's not at all unusual for systems to have upwards of 8GB of ram now, and this will only increase in the future. While an ordinary map is not, under current conditions, likely to get close to the 2GB limit, the fact that some uses of the program can get to this limit is hopefully some reason to consider making the change.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18721
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: 64-bit version of Experimental?
« Reply #1 on: August 18, 2013, 10:58:49 AM »
Hmm, yes, I noticed that I had memory issues running your large game in debug mode. I notice that Microsoft Visual Studio Express 2012 desktop is out and has a 64-bit mode built in. I am downloading that and will see how that works with Simutrans-Experimental.

Offline Carl

  • Devotee
  • *
  • Posts: 1599
    • Website
  • Languages: EN
Re: 64-bit version of Experimental?
« Reply #2 on: August 18, 2013, 03:02:17 PM »
Thanks for looking into this, James.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18721
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: 64-bit version of Experimental?
« Reply #3 on: August 18, 2013, 03:13:06 PM »
It is rather helpful that you prompted me to do so, actually, as the MS Visual Studio Express 2012 is, in my tests so far, easier to use and more responsive than the 2010 edition that I have been using so far.

Offline Sarlock

  • Devotee
  • *
  • Posts: 1340
  • Languages: EN
Re: 64-bit version of Experimental?
« Reply #4 on: August 18, 2013, 04:36:18 PM »
Would it be possible for Experimental to support occupancy of more than 2GB of system RAM? I've been pushing near this limit on a couple of maps. While one can use certain third-party tools to unlock an executable for these purposes -- seemingly without error -- if it is a relatively simple change to make then it could be useful to have this supported natively.

This is, I suppose, a selfish request, but it might also be a good exercise in future-proofing the program. It's not at all unusual for systems to have upwards of 8GB of ram now, and this will only increase in the future. While an ordinary map is not, under current conditions, likely to get close to the 2GB limit, the fact that some uses of the program can get to this limit is hopefully some reason to consider making the change.

Glad for this request, I have had the same thought.  As Simutrans matures, especially Experimental, it is becoming a very powerful tool to simulate a large real-world network.  I am working on something myself, to the same idea as your GB map, though it has not progressed enough for me to release a first update.

In a few years, 2GB will seem small.  I just got a new computer last week that has 16 GB installed.  Simutrans-Exp runs very nicely on this system.

I learned to program BASIC on a computer with 16k RAM.  1 million times less memory...

Offline kierongreen

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 2269
Re: 64-bit version of Experimental?
« Reply #5 on: August 18, 2013, 04:42:32 PM »
Now that would have been an interesting exercise - trying to write a reasonable transport simulator for the 1980s era home computers. I don't think BASIC would have been a realistic option if you were to get at all decent performance, and I suspect map sizes more than 64x64 tiles would have been completely out of the question...

Offline waerth

  • *
  • Posts: 145
Re: 64-bit version of Experimental?
« Reply #6 on: August 18, 2013, 05:01:30 PM »
I actually patched simutrans with the 4gb limit as I like to play on max size maps (about 4000x4000 or so the program does not allow bigger :( ) and with 2000 towns on the map (I am nuts I know!!) I have been playing with that for some time now. I really hope we will be able to create bigger maps :p

Maybe an option is to point people to this patch from where they download the experimental .exe? Saying that if you have more than 4 gb of Ram it is recommended to patch simutrans with that as it will stop crashes from happening (when it reaches to about 1800 mb of memory it crashes without the patch).

W

Offline Carl

  • Devotee
  • *
  • Posts: 1599
    • Website
  • Languages: EN
Re: 64-bit version of Experimental?
« Reply #7 on: August 18, 2013, 05:58:50 PM »
That's one option, but for the purposes of e.g. bug reports and sharing saves, it would be preferable if there was an officially supported 64-bit version.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18721
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: 64-bit version of Experimental?
« Reply #8 on: August 18, 2013, 06:05:34 PM »
Attempting to compile in 64-bits with Visual Studio 2012 gives me this error for a multi-threaded build:

Code: [Select]
1>  loadsave.cc
1>dataobj\loadsave.cc(527): warning C4267: 'argument' : conversion from 'size_t' to 'unsigned int', possible loss of data
1>dataobj\loadsave.cc(530): warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data
1>dataobj\loadsave.cc(615): warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data
1>dataobj\loadsave.cc(620): warning C4267: 'argument' : conversion from 'size_t' to 'unsigned int', possible loss of data
1>dataobj\loadsave.cc(923): warning C4267: 'argument' : conversion from 'size_t' to 'const int', possible loss of data
1>dataobj\loadsave.cc(986): warning C4267: 'argument' : conversion from 'size_t' to 'const int', possible loss of data
1>weg.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_lock
1>simplay.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_lock
1>simview.obj : error LNK2019: unresolved external symbol __imp_pthread_mutex_lock referenced in function "public: void __cdecl std::_Wrap_alloc<class std::allocator<char> >::construct<char *,char * &>(char * *,char * &)" (??$construct@PEADAEAPEAD@?$_Wrap_alloc@V?$allocator@D@std@@@std@@QEAAXPEAPEADAEAPEAD@Z)
1>tunnel.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_lock
1>wayobj.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_lock
1>leitung2.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_lock
1>loadsave.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_lock
1>powernet.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_lock
1>simgraph16.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_lock
1>crossing.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_lock
1>freelist.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_lock
1>gebaeude.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_lock
1>label.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_lock
1>weg.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_unlock
1>simplay.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_unlock
1>simview.obj : error LNK2019: unresolved external symbol __imp_pthread_mutex_unlock referenced in function "public: void __cdecl std::_Wrap_alloc<class std::allocator<char> >::construct<char *,char * &>(char * *,char * &)" (??$construct@PEADAEAPEAD@?$_Wrap_alloc@V?$allocator@D@std@@@std@@QEAAXPEAPEADAEAPEAD@Z)
1>tunnel.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_unlock
1>wayobj.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_unlock
1>leitung2.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_unlock
1>loadsave.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_unlock
1>powernet.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_unlock
1>simgraph16.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_unlock
1>crossing.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_unlock
1>freelist.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_unlock
1>gebaeude.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_unlock
1>label.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_unlock
1>loadsave.obj : error LNK2019: unresolved external symbol BZ2_bzReadOpen referenced in function "public: bool __cdecl loadsave_t::rd_open(char const *)" (?rd_open@loadsave_t@@QEAA_NPEBD@Z)
1>loadsave.obj : error LNK2019: unresolved external symbol BZ2_bzReadClose referenced in function "public: char const * __cdecl loadsave_t::close(void)" (?close@loadsave_t@@QEAAPEBDXZ)
1>loadsave.obj : error LNK2019: unresolved external symbol BZ2_bzRead referenced in function "private: unsigned __int64 __cdecl loadsave_t::read(void *,unsigned __int64)" (?read@loadsave_t@@AEAA_KPEAX_K@Z)
1>loadsave.obj : error LNK2019: unresolved external symbol BZ2_bzWriteOpen referenced in function "public: bool __cdecl loadsave_t::wr_open(char const *,enum loadsave_t::mode_t,char const *,char const *,char const *)" (?wr_open@loadsave_t@@QEAA_NPEBDW4mode_t@1@000@Z)
1>loadsave.obj : error LNK2019: unresolved external symbol BZ2_bzWrite referenced in function "private: unsigned __int64 __cdecl loadsave_t::write(void const *,unsigned __int64)" (?write@loadsave_t@@AEAA_KPEBX_K@Z)
1>loadsave.obj : error LNK2019: unresolved external symbol BZ2_bzWriteClose referenced in function "public: char const * __cdecl loadsave_t::close(void)" (?close@loadsave_t@@QEAAPEBDXZ)
1>loadsave.obj : error LNK2019: unresolved external symbol __imp_pthread_attr_init referenced in function "public: void __cdecl loadsave_t::set_buffered(bool)" (?set_buffered@loadsave_t@@QEAAX_N@Z)
1>simview.obj : error LNK2001: unresolved external symbol __imp_pthread_attr_init
1>simworld.obj : error LNK2001: unresolved external symbol __imp_pthread_attr_init
1>loadsave.obj : error LNK2019: unresolved external symbol __imp_pthread_attr_destroy referenced in function "public: void __cdecl loadsave_t::set_buffered(bool)" (?set_buffered@loadsave_t@@QEAAX_N@Z)
1>simview.obj : error LNK2001: unresolved external symbol __imp_pthread_attr_destroy
1>simworld.obj : error LNK2001: unresolved external symbol __imp_pthread_attr_destroy
1>loadsave.obj : error LNK2019: unresolved external symbol __imp_pthread_attr_setdetachstate referenced in function "public: void __cdecl loadsave_t::set_buffered(bool)" (?set_buffered@loadsave_t@@QEAAX_N@Z)
1>simview.obj : error LNK2001: unresolved external symbol __imp_pthread_attr_setdetachstate
1>simworld.obj : error LNK2001: unresolved external symbol __imp_pthread_attr_setdetachstate
1>loadsave.obj : error LNK2019: unresolved external symbol __imp_pthread_create referenced in function "public: void __cdecl loadsave_t::set_buffered(bool)" (?set_buffered@loadsave_t@@QEAAX_N@Z)
1>simview.obj : error LNK2001: unresolved external symbol __imp_pthread_create
1>simworld.obj : error LNK2001: unresolved external symbol __imp_pthread_create
1>loadsave.obj : error LNK2019: unresolved external symbol __imp_pthread_join referenced in function "public: void __cdecl loadsave_t::set_buffered(bool)" (?set_buffered@loadsave_t@@QEAAX_N@Z)
1>simworld.obj : error LNK2001: unresolved external symbol __imp_pthread_join
1>loadsave.obj : error LNK2019: unresolved external symbol __imp_pthread_mutex_init referenced in function "public: void __cdecl loadsave_t::set_buffered(bool)" (?set_buffered@loadsave_t@@QEAAX_N@Z)
1>simgraph16.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_init
1>simview.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_init
1>loadsave.obj : error LNK2019: unresolved external symbol __imp_pthread_mutex_destroy referenced in function "public: void __cdecl loadsave_t::set_buffered(bool)" (?set_buffered@loadsave_t@@QEAAX_N@Z)
1>simgraph16.obj : error LNK2001: unresolved external symbol __imp_pthread_mutex_destroy
1>loadsave.obj : error LNK2019: unresolved external symbol __imp_pthread_barrier_init referenced in function "public: void __cdecl loadsave_t::set_buffered(bool)" (?set_buffered@loadsave_t@@QEAAX_N@Z)
1>simview.obj : error LNK2001: unresolved external symbol __imp_pthread_barrier_init
1>loadsave.obj : error LNK2019: unresolved external symbol __imp_pthread_barrier_destroy referenced in function "public: void __cdecl loadsave_t::set_buffered(bool)" (?set_buffered@loadsave_t@@QEAAX_N@Z)
1>loadsave.obj : error LNK2019: unresolved external symbol __imp_pthread_barrier_wait referenced in function "private: unsigned __int64 __cdecl loadsave_t::write(void const *,unsigned __int64)" (?write@loadsave_t@@AEAA_KPEBX_K@Z)
1>simview.obj : error LNK2001: unresolved external symbol __imp_pthread_barrier_wait
1>simworld.obj : error LNK2019: unresolved external symbol __imp_sem_init referenced in function "private: void __cdecl karte_t::world_xy_loop(void (__cdecl karte_t::*)(short,short,short,short),bool)" (?world_xy_loop@karte_t@@AEAAXP81@EAAXFFFF@Z_N@Z)
1>simworld.obj : error LNK2019: unresolved external symbol __imp_sem_destroy referenced in function "private: void __cdecl karte_t::world_xy_loop(void (__cdecl karte_t::*)(short,short,short,short),bool)" (?world_xy_loop@karte_t@@AEAAXP81@EAAXFFFF@Z_N@Z)
1>simworld.obj : error LNK2019: unresolved external symbol __imp_sem_wait referenced in function "private: static void * __cdecl karte_t::world_xy_loop_thread(void *)" (?world_xy_loop_thread@karte_t@@CAPEAXPEAX@Z)
1>simworld.obj : error LNK2019: unresolved external symbol __imp_sem_post referenced in function "private: static void * __cdecl karte_t::world_xy_loop_thread(void *)" (?world_xy_loop_thread@karte_t@@CAPEAXPEAX@Z)
1>C:\Users\James\Documents\Development\Simutrans\simutrans-experimental-sources\x64\Debug\Simutrans-Experimental-debug.exe : fatal error LNK1120: 22 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

and this error for a single threaded build:

Code: [Select]
1>------ Build started: Project: Simutrans-Experimental, Configuration: Debug (single threaded) x64 ------
1>loadsave.obj : error LNK2019: unresolved external symbol BZ2_bzReadOpen referenced in function "public: bool __cdecl loadsave_t::rd_open(char const *)" (?rd_open@loadsave_t@@QEAA_NPEBD@Z)
1>loadsave.obj : error LNK2019: unresolved external symbol BZ2_bzReadClose referenced in function "public: char const * __cdecl loadsave_t::close(void)" (?close@loadsave_t@@QEAAPEBDXZ)
1>loadsave.obj : error LNK2019: unresolved external symbol BZ2_bzRead referenced in function "private: unsigned __int64 __cdecl loadsave_t::read(void *,unsigned __int64)" (?read@loadsave_t@@AEAA_KPEAX_K@Z)
1>loadsave.obj : error LNK2019: unresolved external symbol BZ2_bzWriteOpen referenced in function "public: bool __cdecl loadsave_t::wr_open(char const *,enum loadsave_t::mode_t,char const *,char const *,char const *)" (?wr_open@loadsave_t@@QEAA_NPEBDW4mode_t@1@000@Z)
1>loadsave.obj : error LNK2019: unresolved external symbol BZ2_bzWrite referenced in function "private: unsigned __int64 __cdecl loadsave_t::write(void const *,unsigned __int64)" (?write@loadsave_t@@AEAA_KPEBX_K@Z)
1>loadsave.obj : error LNK2019: unresolved external symbol BZ2_bzWriteClose referenced in function "public: char const * __cdecl loadsave_t::close(void)" (?close@loadsave_t@@QEAAPEBDXZ)
1>C:\Users\James\Documents\Development\Simutrans\simutrans-experimental-sources\x64\Debug (single threaded)\Simutrans-Experimental-debug.exe : fatal error LNK1120: 6 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I am not sure quite what the problem is. Are there 64-bit versions of the bzip2 and pthreads libraries?

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9518
  • Languages: De,EN,JP
Re: 64-bit version of Experimental?
« Reply #9 on: August 29, 2013, 10:00:12 PM »
Bzip2 you can (must) anyway compile yourself. Aparently phtreads must be compiled too. But I was told the MSVC Express 64bit compiler does not work properly (problems with setjump), so I am surprised that you get any compilation at all. (The MSVC 64 bit works, but not express). Did you install the 64 bit version of the SDK?

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18721
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: 64-bit version of Experimental?
« Reply #10 on: August 29, 2013, 10:38:44 PM »
Ahh, I wasn't aware of these issues with Express. I didn't install the SDK - just VS Express 2012 (is that the version that has trouble with 64-bit compilation?).

As to compiling pthreads and bzip2 - are their licences such that allow us to do that with a project under the Artistic Licence? The LGPL should probably suffice for our purposes, but not the full GPL if that is what they are licensed under.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9518
  • Languages: De,EN,JP
Re: 64-bit version of Experimental?
« Reply #11 on: August 30, 2013, 07:48:45 PM »
The bzip2 you use is very likely anyway compiled by Dwachs. So you can do this too.

I think the openttd-usefull library file also comes with a 64bit version. It may be your best guess.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18721
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: 64-bit version of Experimental?
« Reply #12 on: August 30, 2013, 09:44:01 PM »
Thank you; that is helpful.

Hmm - I have already set it to use the Open TTD library's 64-bit version, which has not helped.

Would I have to compile bzip2 as a separate .lib file, or could it be compiled at the same time as and as part of the main executable?

Edit: I have now managed to compile the .lib file and get the single threaded version going - thank you for your help. Will a similar technique work for pthreads, do you think?
« Last Edit: August 31, 2013, 12:40:20 PM by jamespetts »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9518
  • Languages: De,EN,JP
Re: 64-bit version of Experimental?
« Reply #13 on: August 31, 2013, 07:05:09 PM »
I think pthreads has a 64 bit version; if not, then you need to dig for one. Since it uses some assumption of the setjmp structures, which are no longer true in 64 bit mode some dedicated 64 bit code is needed. Hence the compatibility layer that allows for calling 32 bit dlls from 64 bit code will not work. Make sure, you have all 64 bit versions (and only those) in your path.

EDIT: Short googling revealed that pthreads should compile with x86_64 even on MSVC 2008.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18721
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: 64-bit version of Experimental?
« Reply #14 on: September 01, 2013, 11:31:27 AM »
Hmm - the trouble that I am having is that we seem to need pthreadsVCE2.lib when compiling with Visual Studio Express. pthreadsVCE2.lib comes in a 32-bit version but the 64-bit directory contains only pthreadsVC2.lib, which is not the same and does not work.

I tried to download the pthreads sources, and could compile a 64-bit version of pththreadsVC2.lib, but can still not work out how to set it to compile a 64-bit (or, indeed, any) version of pthreadsVCE2.lib.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18721
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: 64-bit version of Experimental?
« Reply #15 on: September 01, 2013, 05:39:51 PM »
I have now added a single threaded Windows 64-bit version to the latest .zip files with the binaries for 11.10. (The Linux platform has had a native 64-bit version for a while, of course).

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9518
  • Languages: De,EN,JP
Re: 64-bit version of Experimental?
« Reply #16 on: September 01, 2013, 09:24:23 PM »
VCE is with exceptions, which are not really used in simutranc The VC version should do fine.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18721
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: 64-bit version of Experimental?
« Reply #17 on: September 01, 2013, 09:43:38 PM »
Ahh, that does work, thank you! From what I have read, the VC version is probably better in any case. I had thought that Simutrans would only work with the VCE version.

Offline Junna

  • Devotee
  • *
  • Posts: 1082
Re: 64-bit version of Experimental?
« Reply #18 on: October 25, 2013, 03:58:32 PM »
I cannot seem to find a pre-compiled bzip2 that works for the x64 version, could that be shared here? I cannot figure out how to compile it from source, either...

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18721
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: 64-bit version of Experimental?
« Reply #19 on: October 25, 2013, 05:06:16 PM »
Bzip2 is statically linked; do you need one for the purposes of compiling your own Simutrans-Experimental? If you are not compiling yourself, you do not need this.

Offline Junna

  • Devotee
  • *
  • Posts: 1082
Re: 64-bit version of Experimental?
« Reply #20 on: October 25, 2013, 06:45:04 PM »
Bzip2 is statically linked; do you need one for the purposes of compiling your own Simutrans-Experimental? If you are not compiling yourself, you do not need this.

Yes, that is what I need it for.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18721
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: 64-bit version of Experimental?
« Reply #21 on: October 25, 2013, 07:47:59 PM »
I have uploaded it here. I hope that that helps!

Offline Junna

  • Devotee
  • *
  • Posts: 1082
Re: 64-bit version of Experimental?
« Reply #22 on: October 25, 2013, 08:07:38 PM »
Thank you, compilation works now.