Author Topic: largeadware question and gigabytes of memory  (Read 9057 times)

daydreamer

  • Member
  • *****
  • Posts: 2399
  • my kind of REAL10 Blonde
largeadware question and gigabytes of memory
« on: December 12, 2019, 01:36:28 AM »
Hi
this is 64bit .exe
got error when trying to make array in static,that it was max 07fffffffffh something,its too big
is this and dynamic alloc need largadware,despite its 64bit mode?
also wonder if I need different alloc/free in 64bit mode than previous
some method of check maxmemory and if I get 64gb, subtract that with x gb(maybe 2-5gb) before I alloc memory ,so windows doesnt get unstable or crash?
whats typical memory hz in your 64bit cpu compared to clock freqency?if working with a memoryintensive program,I am only guaranteed memoryspeed?
my none asm creations
http://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10583
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: largeadware question and gigabytes of memory
« Reply #1 on: December 12, 2019, 03:20:02 AM »
magnus,

With MASM (ml64) you use the /LARGEADDRESSAWARE option to ensure you only use fully compatible 64 bit code. When you get an error that says you cannot use that option, it will be a code construction that cannot be used in win64. It is usually things like trying to load a large "immediate" value into a memory variable, if you have the problem, load the value into a register first then move the register into the 64 bit variable.

As long as you keep the app fully compatible with 64 bit Windows, you can access very large amounts of memory, if you go the other route you limit the app to 32 bit address range for no real gain, you may as well write in 32 bit.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

aw27

  • Guest
Re: largeadware question and gigabytes of memory
« Reply #2 on: December 12, 2019, 03:44:28 AM »
07fffffffffh = ‭549,755,813,887‬ bytes = 512 GB
Quite a lot, it will not work in most systems.

daydreamer

  • Member
  • *****
  • Posts: 2399
  • my kind of REAL10 Blonde
Re: largeadware question and gigabytes of memory
« Reply #3 on: December 25, 2019, 03:09:09 AM »

As long as you keep the app fully compatible with 64 bit Windows, you can access very large amounts of memory, if you go the other route you limit the app to 32 bit address range for no real gain, you may as well write in 32 bit.
I wish that you and other who has highend 64bit with loads of RAM can test it on 64gig RAM systems,with a 64bit version of a numbercrunching 32program,inspired by 64bit Cg apps that take advantage of all aviable RAM,so it can have lots of photorealistic textures while numbercrunching with algos with the right math to render photorealistic
my none asm creations
http://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10583
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: largeadware question and gigabytes of memory
« Reply #4 on: December 25, 2019, 06:40:46 AM »
magnus,

You are missing something here, if you code in 32 bit Windows code, you have a 2 gig limit and about another gig if you use the /LARGEADDRESSAWARE flag. If you write 64 bit Windows code that uses the /LARGEADDRESSAWARE flag, you can use up to 192 gigabytes of memory if you have that much installed and make truly massive amounts of data.

Since you live in a northern hemisphere cold country, I hope you have a great white Christmas.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: largeadware question and gigabytes of memory
« Reply #5 on: December 25, 2019, 09:00:04 AM »
In 32-bit code, adding the negative addresses with /LARGEADDRESSAWARE is an interesting adventure, because all code that relies on addresses being positive will produce nice surprises.

I wonder, though, why 64-bit code would need /LARGEADDRESSAWARE? 2^63 is 9.223e18... :rolleyes:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10583
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: largeadware question and gigabytes of memory
« Reply #6 on: December 25, 2019, 11:09:09 AM »
> I wonder, though, why 64-bit code would need /LARGEADDRESSAWARE? 2^63 is 9.223e18...

So it does not get restricted to 2 gig. Without it, its one of those half arsed options for code that contains 32 bit constructions that are not valid in 64 bit mode. Its win32 on steroids as far as extra registers but knackered win64.  :eusa_hand:
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: largeadware question and gigabytes of memory
« Reply #7 on: December 25, 2019, 12:01:24 PM »
Right, that builds and runs indeed fine but is somehow against the 64-bit spirit:
Code: [Select]
include \Masm32\MasmBasic\Res\JBasic.inc ; ## console demo, builds in 32- or 64-bit mode with UAsm, ML, AsmC ##
Init
  mov eax, Chr$("Hello World")
  PrintLine rax
  MsgBox 0, "Wow, that works indeed!!!!", "Hi", MB_OK
EndOfCode

OPT_64 1 ; put 0 for 32 bit, 1 for 64 bit assembly
OPT_DebugL /LARGEADDRESSAWARE:NO

TimoVJL

  • Member
  • *****
  • Posts: 1320
Re: largeadware question and gigabytes of memory
« Reply #8 on: December 25, 2019, 06:10:47 PM »
Quote
The /LARGEADDRESSAWARE option tells the linker that the application can handle addresses larger than 2 gigabytes. In the 64-bit compilers, this option is enabled by default. In the 32-bit compilers, /LARGEADDRESSAWARE:NO is enabled if /LARGEADDRESSAWARE is not otherwise specified on the linker line.
May the source be with you

daydreamer

  • Member
  • *****
  • Posts: 2399
  • my kind of REAL10 Blonde
Re: largeadware question and gigabytes of memory
« Reply #9 on: December 25, 2019, 10:59:08 PM »
You are missing something here, if you code in 32 bit Windows code, you have a 2 gig limit and about another gig if you use the /LARGEADDRESSAWARE flag. If you write 64 bit Windows code that uses the /LARGEADDRESSAWARE flag, you can use up to 192 gigabytes of memory if you have that much installed and make truly massive amounts of data.

Since you live in a northern hemisphere cold country, I hope you have a great white Christmas.
thanks,not so often white christmas here close to Copenhagen,hope you also have a great Christmas
only have 20gb and C code so far that use 2gb and also x64 testing dynamic alloc

@JJ
the coolest looking pointer bug I did many years ago in ddraw software renderer,sea and atmosphere textures blended,accidently part of sphere used sea texture for outer atmosphere,looked like cool transparent wrinkled plastic wrapped part of sphere
my none asm creations
http://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10583
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: largeadware question and gigabytes of memory
« Reply #10 on: December 25, 2019, 11:20:20 PM »
He he, we had an almost sunny day today (Christmas Day) as it lightly rained last night and the wind blew the smoke away. For all of the heatwave predictions, we have not had very hot conditions here in Sydney, some evenings have been a bit cold. It would really help if we had a couple of days of really heavy rain but it does not look like its going to happen any time soon.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

aw27

  • Guest
Re: largeadware question and gigabytes of memory
« Reply #11 on: December 26, 2019, 09:06:32 PM »
A 32-bit application on a 64-bit OS can use the /LARGEADDRESSAWARE linker switch to address 4GB.
This is what Raymond Chen says.
https://devblogs.microsoft.com/oldnewthing/20050601-24/?p=35483

"Use" does not mean allocate, I have never been able to allocate more than 2GB on a 32-bit application running on a 64-bit OS when using /LARGEADDRESSAWARE, either with HeapAlloc or VirtualAlloc. When using /LARGEADDRESSAWARE I can allocate a bit more than without /LARGEADDRESSAWARE, but never more than 2GB. We can address but we can not allocate, the system DLLs continue to be placed above the 2GB address as before.

Now, about 64-bit applications:
Some people use /LARGEADDRESSAWARE switch when linking a 64 bit application. This is not necessary because the default for 64-bit applications is /LARGEADDRESSAWARE. What I have seen some people doing (here) is use /LARGEADDRESSAWARE:NO on a 64-bit application.
Although legal, when used blindly, as tends to be, causes problems.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10583
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: largeadware question and gigabytes of memory
« Reply #12 on: December 26, 2019, 09:14:04 PM »
With a 32 bit app with the /LARGEADDRESSAWARE flag set, you can allocate almost 2gig in one allocation but you can allocate another block depending on the extra size you get from using the flag after some of the high address space is used by some hardware.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

aw27

  • Guest
Re: largeadware question and gigabytes of memory
« Reply #13 on: December 26, 2019, 09:36:37 PM »
With a 32 bit app with the /LARGEADDRESSAWARE flag set, you can allocate almost 2gig in one allocation but you can allocate another block depending on the extra size you get from using the flag after some of the high address space is used by some hardware.
Yes, it is true.  :thumbsup:

aw27

  • Guest
Re: largeadware question and gigabytes of memory
« Reply #14 on: December 27, 2019, 06:36:14 AM »
Testing how far we can go with /LARGEADDRESSAWARE in 32-bit by top down allocation in chunks 10000 pages.