|
Post by emulog on Jan 7, 2023 15:08:23 GMT
For optimization purposes in order to prevent cache thrashing i need that some LUT be sequential to relevant code in memory, are they composed in RAM in order of appearance in original *.bas ? Must they be put into subroutine ? QB64 allow dimensioning new data anywhere in text and thus do they follow order ? How $Static change this ? Much alike to this are local jumptables, local sub vars and arrays, how QB64 do it ?
|
|
|
Post by emulog on Jan 9, 2023 1:21:53 GMT
Well, none seems to know it. Googling for GCC behavior i found almost nothing regarding.
I also found that QB64 do not align arrays and vars to 64bit granularity, they just go in order of appearance. I use uint64 for RGB colours addition via LUT and while hoping that transition from uint32 to 64 will greatly decrease LUT usage within loop and gain speed, it was not. Until i aligned target array by adding dim as _byte "varname". The dim itself i tossed back to start before all code. Depending on offset 0...+7 loop speed test show from 211 fps to 245 fps. It seems that first data block in QB64 is at +7 offset, or it just happen so in particular.
PS also cache line size may matter, usually is 64 byte on x64. First come program body and any typed symbol change offset for first DIM. I used cheat engine to find first values of an array in EXE, written manually, found address and manually padded by extra DIM as _byte values to shift at 64B granularity. It helps.
PPS such construction work, a sample :
Dim As _Byte AL1(44): Dim Shared As _Unsigned _Integer64 QPX(3528) ... Dim As _Offset OFS OFS = _Offset(QPX(0)) And 63:: If OFS > 0 Then Print "- - - QPX STOP OFFSET="; OFS: Sleep: End
So code will not run until manually change _byte array, better go by increasing value until done. Do same with every alignment crucial data at code start.
Though this works while compile and test, for EXE going standalone need to use Redim in cycle, all arrays being $dynamic
|
|
tonylazuto
New Member
Tony Lazuto says hello
Posts: 25
|
Post by tonylazuto on Jan 10, 2023 15:01:33 GMT
This forum isn't super active. I wish I knew the answer to your question because it sounds like you're working with some pretty neat stuff. I'm not sure who out there would be able to assist.
|
|
|
Post by emulog on Jan 10, 2023 15:15:14 GMT
I am ok with that. Like this.
S = 768: G = 63
' DIM autoalignment starts here by 64b margin Print "REDIM RANDOM SIZE="; S; ", GRANULAR MASK="; G
ReDim W(1): R = 0: Print "QPL>";: Do::::::::::: ReDim Shared As _Unsigned Long QPL(128 * 256): Q = _Offset(QPL(0)) And G If Q Then R = R + 1: R = Rnd * S: ReDim W(R): ReDim Shared As _Unsigned Long QPL(R): If R > 8000 Then Print "UNSOLVABLE.": End Loop Until Q = 0: Print R; " REDIMS DONE."
ReDim W(1): R = 0: Print "QPX>";: Do::::::::::: ReDim Shared As _Unsigned _Integer64 QPX(3528): Q = _Offset(QPL(0)) And G If Q Then R = R + 1: R = Rnd * S: ReDim W(R): ReDim Shared As _Unsigned _Integer64 QPX(R): If R > 8000 Then Print "UNSOLVABLE.": End Loop Until Q = 0: Print R; " REDIMS DONE."
|
|