Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Richard

Pages: [1] 2 3 ... 25
1
QB64 Discussion / Re: The QB64 Bible (Work In Progress)
« on: April 15, 2022, 11:16:25 pm »
@SMcNeill

My suggestion...



After a brief description, mention in detail with examples if possible, of what's wrong with it (c/f PRINT, PRINT USING, etc).

Then mention what's right with it , eg how big numbers in theory you could go (+precision), when one should always use ## (irrespective  of dims, types, declare, constants,  etc). how it matches up to other .,variable types (I started on the number space of _FLOAT study, for the case of integers - so one could compare to INTEGER64 values).

Maybe have some speed comparisons e.g

SINGLE vs DOUBLE vs FLOAT vs INTEGER64

2
QB64 Discussion / Re: Has $Debug been working well for you?
« on: April 13, 2022, 11:14:06 am »
Although not going into specifics here, it was/is a great help - although floating point handling, as already noted is (and probably always still will be) an issue (and not referring to FLOAT which is a "problem" in itself).

Probably the best thing for me with $Debug was that it brought QB64 much closer to the already existing functionality of MS PDS 7.1 (upgrade to QB45) which I still use a lot (QB64 has a lot of catching up to what PDS could do).

3
            256 bit INC                      


Using techniques developed for 64 bit INC  (i.e. +1), tests performed on various variable/memory combinations for 256 bit INC.

Updated to include a large "X" to clearly show where the timings end for a particular module.

Also, on LHS, shows a linear-linear graph TIME vs TRIAL#. Because of Windows background tasks - there is a wide spread of timings per module.

Included are QB64 code results, using INTEGER64 unsigned variables, for timing comparisons.

4
QB64 Discussion / Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
« on: February 23, 2022, 08:56:09 am »
Changed compiling options for enumeration of INC in QB64.


File -O2.png is for gcc compiler flag settings.

File Standard.png is the default QB64 compiler settings.


QB64 INC is now for only one iteration (in line with all other modules).




5
QB64 Discussion / Re: Project looking for Programmer (I can't do it myself)
« on: February 20, 2022, 06:31:49 am »
@TempodiBasic

Is your program in a somewhat usable form - as I would be interested in trying out in bare metal mode on a newer style CPU?

6
QB64 Discussion / Re: QB64 interoperability with FreeBasic
« on: February 06, 2022, 11:21:00 pm »
@jack

I tried your simple test program on QB64 win10x64 using FreeBASIC-1.09.0-winlibs-gcc-9.3.0 to create myDLL.dll and the output was

abcd

as per what you mentioned.


Just for fun, I (unsuccessfully) tried to create a STATIC library to test out instead of the dll. I was NOT after a smaller or faster exe - just wanted something that would "work". I based my attempt on the following link(s)

https://www.freebasic.net/forum/viewtopic.php?t=27380

with the corresponding sub link

https://github.com/marpon/mem_exe_dll/blob/master/dll2lib_test_enc_64.bas

In my case, only an    .a    file was created (not an .o) and Geany (for me) could not do anything with the .a file (hence I could not create a STATIC lib file).


Have you any progress on resolving the issue as per your first post and/or  can you create a STATIC library equivalent of myDLL.dll?

7
This reply is really meant for any relatively new programmers.



QB64 comparison of output formatting



@jack earlier mentioned about how print and using formats may not give the same numerical results. To attempt to do "proper" comparisons of some of the variable types of QB64, I have now standardized on including:-

STR$()  (which is often used as in PRINT  i.e. a$=STR$(a%) gives identical output result as PRINT a%)

PRINT USING "######.######" (say) for fixed format printing

PRINT USING "##.######^^^^^" (say) for scientific notation

and Hexadecimal format.

By simultaneously displaying these four formats, it is easier to see when the various formats begin to break, in the study of the QB64 number space set.



Relatively new programmers might be tempted to "dial up maximum resolution" for the output streams (which on purpose I did below to highlight the problems associated) - however without due "care", this will typically result in numerical artifacts. Of course, it is up to the programmer/program_user/intended_program_market/standards/government_regulations (if applicable) which would be the deciding factor on how to handle this.


At present, the attachment below has not been edited for "errors" (as numerical artifacts) with say "red boxes" etc - so in the meantime consider it a QUIZ - to identify/confirm any errors (say pick one set (function) , and as far as you are comfortable to analyze - use any readily available techniques (your own QB64 program, other programming languages, calculators, wiki/google etc) to "support" your answer.

Because of obvious formatting problems - just "ignore" the last dozen or so lines in the attachment.


The attachment is a "practice run" in preparation for further QB64 number space study.









8
QB64 Discussion / QB64 Development builds
« on: January 18, 2022, 08:20:26 pm »
Unless I went to the wrong site (or something)...


The development  build comes up as (for example)

qb64_development_win-x64.7z



Previously, the name included Date & Time and Version number.

Although I can get the version number quite easily, it would be nice to know these details BEFORE downloading the file.

9
QB64 Discussion / Re: Somebody explain this one to me...
« on: January 04, 2022, 08:00:45 am »
@SMcNeill


I understand your reply regarding differences in memory allocation for arrays (Main_Program)  versus  (SUBS) and how this affects timings in using these techniques for array work.


I attempted to time the big DIM array


Dim TempGrid(0 To _Width - 1, 0 To _Height - 1) As Long


for the two "passes"  of your circle program and did not see any significant changes (minor ones exist) between your two methods as far as DIM being setup.

I attempted to slightly modify your program (my alterations shown with "*** at the end of each relevant line) and is supplied below.

Perhaps you are correct - in which case there is a a coding problem in my alterations to your program.
Would you be kind enough to point out any coding problems in my alterations to establish correct timing results to support your last reply?



Code: QB64: [Select]
  1.  
  2. DECLARE DYNAMIC LIBRARY "kernel32"                                             '***
  3.     SUB QueryPerformanceCounter (BYVAL lpPerformanceCount AS _UNSIGNED _OFFSET)'***
  4.     SUB QueryPerformanceFrequency (BYVAL lpFrequency AS _UNSIGNED _OFFSET)     '***
  5. END DECLARE                                                                    '***
  6. DIM SHARED PerformanceCount AS _INTEGER64                                      '***
  7. DIM SHARED Frequency AS _INTEGER64                                             '***
  8. DIM SHARED StartingCount AS _INTEGER64                                         '***
  9. DIM SHARED dElapsedTime AS DOUBLE                                              '***
  10. DIM SHARED dElapsedTimeOLD AS DOUBLE                                           '***
  11. DIM SHARED CumulativeTime AS DOUBLE                                            '***
  12. QueryPerformanceFrequency (_OFFSET(Frequency))                                 '***
  13. QueryPerformanceCounter (_OFFSET(StartingCount))                               '***
  14. CumulativeTime#=0                                                              '***
  15.  
  16.  
  17. Screen _NewImage(1024, 720, 32)
  18.  
  19.  
  20. TestLimit = 100
  21. Radius = 350
  22.  
  23. t# = Timer
  24. For i = 1 To TestLimit
  25.     'Cls , &HFF000000 + Int(Rnd * &HFFFFFF)
  26.     k& = &HFF000000 + Int(Rnd * &HFFFFFF)
  27.  
  28.     Circle (512, 360), Radius, k&
  29.     Fill 512, 360, k&, 0
  30.  
  31. t1# = Timer
  32. CumulativeTime_T1_T#=CumulativeTime#                                           '***
  33. CumulativeTime#=0                                                              '***
  34.  
  35. For i = 1 To TestLimit
  36.     'Cls , &HFF000000 + Int(Rnd * &HFFFFFF)
  37.     k& = &HFF000000 + Int(Rnd * &HFFFFFF)
  38.  
  39.     Circle (512, 360), Radius, k&
  40.     Fill 512, 360, k&, -1
  41. t2# = Timer
  42. CumulativeTime_T2_T1#=CumulativeTime#                                          '***
  43.  
  44. Print Using "###.#### seconds for Fill."; t1# - t#;
  45. COLOR &HFF00FF00~&                                                             '***
  46. print "             ";                                                        '***
  47. print using "#,###";CumulativeTime_T1_T#;                                      '***
  48. print " microseconds to DIM array"                                            '***
  49. COLOR &HFFFFFFFF~&
  50.  
  51.  
  52. Print Using "###.#### seconds for Fill Method -1."; t2# - t1#;
  53. COLOR &HFF00FF00~&                                                             '***
  54. print "   ";                                                                  '***
  55. print using "#,###";CumulativeTime_T2_T1#;                                     '***
  56. print " microseconds to DIM array"                                            '***
  57. COLOR &HFFFFFFFF~&                                                             '***
  58.  
  59.  
  60.  
  61.  
  62. Sub Fill (Passx, Passy, kolor As Long, METHOD)
  63. B = _Blend
  64.  
  65.  
  66. TIMERe:dElapsedTimeOLD = dElapsedTime                                          '***
  67. Dim TempGrid(0 To _Width - 1, 0 To _Height - 1) As Long
  68. TIMERe                                                                         '***
  69. CumulativeTime#=CumulativeTime#+(dElapsedTime - dElapsedTimeOLD)*1000000       '***
  70.  
  71.  
  72. Dim As _MEM m, m1: m = _Mem(TempGrid()): m1 = _MemImage(0)
  73. If METHOD Then
  74.     _MemCopy m1, m1.OFFSET, m1.SIZE To m, m.OFFSET
  75. o = 0
  76. Do Until o >= m.SIZE
  77.     If _MemGet(m1, m1.OFFSET + o, _Unsigned Long) = kolor Then
  78.         _MemPut m, m.OFFSET + o, -1 As LONG
  79.         'Else
  80.         '_MemPut m, m.OFFSET + o, 0 As LONG
  81.     End If
  82.     o = o + 4
  83.  
  84. TempGrid(Passx, Passy) = 1
  85. startx = Passx: finishx = Passx
  86. starty = Passy: finishy = Passy
  87.  
  88. Do Until finished
  89.     pass = pass + 1
  90.     finished = -1
  91.     For x = startx To finishx
  92.         For y = starty To finishy
  93.             'If TempGrid(x, y) <> 0 Then Print x, y, TempGrid(x, y): Sleep
  94.  
  95.             If TempGrid(x, y) = pass Then
  96.                 tempx = x
  97.                 Do Until tempx = 0
  98.                     If TempGrid(tempx - 1, y) = 0 Then
  99.                         TempGrid(tempx - 1, y) = pass + 1
  100.                         tempx = tempx - 1
  101.                         If tempx < startx Then startx = tempx
  102.                         finished = 0
  103.                     Else
  104.                         tempx = 0
  105.                     End If
  106.                 Loop
  107.  
  108.                 tempx = x
  109.                 Do Until tempx = _Width - 1
  110.                     If TempGrid(tempx + 1, y) = 0 Then
  111.                         TempGrid(tempx + 1, y) = pass + 1
  112.                         tempx = tempx + 1
  113.                         If tempx > finishx Then finishx = tempx
  114.                         finished = 0
  115.                     Else
  116.                         tempx = _Width - 1
  117.                     End If
  118.                 Loop
  119.  
  120.                 tempy = y
  121.                 Do Until tempy = 0
  122.                     If TempGrid(x, tempy - 1) = 0 Then
  123.                         TempGrid(x, tempy - 1) = pass + 1
  124.                         tempy = tempy - 1
  125.                         If tempy < starty Then startx = tempy
  126.                         finished = 0
  127.                     Else
  128.                         tempy = 0
  129.                     End If
  130.                 Loop
  131.  
  132.                 tempy = y
  133.                 Do Until tempy = _Height - 1
  134.                     If TempGrid(x, tempy + 1) = 0 Then
  135.                         TempGrid(x, tempy + 1) = pass + 1
  136.                         tempy = tempy + 1
  137.                         If tempy > finishy Then finishy = tempy
  138.                         finished = 0
  139.                     Else
  140.                         tempy = _Height - 1
  141.                     End If
  142.                 Loop
  143.             End If
  144.     Next y, x
  145.  
  146. o = 0
  147. Do Until o >= m.SIZE
  148.     If _MemGet(m, m.OFFSET + o, _Unsigned Long) <> 0 Then _MemPut m1, m1.OFFSET + o, kolor As _UNSIGNED LONG
  149.     o = o + 4
  150.  
  151. '***
  152. SUB TIMERe                                                                     '***
  153. QueryPerformanceCounter (_OFFSET(PerformanceCount))                            '***
  154. dElapsedTime = (CDBL(PerformanceCount - StartingCount)) / Frequency            '***
  155. END SUB                                                                        '***
  156.  
  157.  






10
QB64 Discussion / Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
« on: December 26, 2021, 08:34:59 am »
Possible WIKI error (in Variable Type ranges) - case study unsigned integer components for

single 3.402823 e+38                     (2^128)      OK
double 1.797693134862310 e+308 (2^1024)     OK
float  1.18 e+4932                         (2^16384)   ???


The following code displays what I get when trying to access the range for FLOAT (for positive whole number component)

Code: QB64: [Select]
  1. a!=3.402823e+38 'single  
  2. print "single";a!
  3.  
  4. a# = 1.797693134862310e+308    
  5. print "double";a#
  6.  
  7. a## = 1.79769313486231580788856f308
  8. print "float ";a##
  9.  
  10. a## = 1.79769313486231580788857f308
  11. print "float ";a##
  12.  


Does anyone get a higher positive range value for FLOAT than illustrated above?






 
@SpriggsySpriggs

re your replies


Quote
« Reply #113 on: May 01, 2021, 05:17:03 am »

What is the reason for needing such a large number right now?



Quote
« Reply #115 on: May 02, 2021, 12:47:22 am »

I highly doubt we're doing that in QB64, though. It's not really being used for any serious applications. Simple graphics demos and games.



You question the reason for large numbers (128 bits) yet about 128 bits is needed to exactly represent the positive whole number component of QB64 single variables (refer table at start of this reply). SINGLE types are used commonly in programming tasks and because of limited range, QB64 has DOUBLE.

128 bit math would lessen the impact of the number space issues with the current variable types - it does not even begin to widen the range of the existing QB64 variable types.

11
QB64 Discussion / Re: Project looking for Programmer (I can't do it myself)
« on: December 13, 2021, 08:48:03 am »
@Daniel3D


You may already know this but ...

Have you tried DosBox-X which is released Nov 2021, instead of DosBox released Jun 2019?

DosBox-X, which I have not yet tried myself, is a fork from the DosBox project, can also support Linux and Mac OS - the later may allow the expansion of your Stunts community base with Mac users.

Hope this may be of help for you.













12
QB64 Discussion / Re: Somebody explain this one to me...
« on: December 05, 2021, 01:20:09 am »
@SMcNeill





I offer the following explanation as to how it is possible that by addition of one extra line of code, significant reduction in timing results rather than expected an increase.


This reply assumes you understand the background information as per the link below



https://www.qb64.org/forum/index.php?topic=2276.msg138538#msg138538

Reply 184



Firstly, very roughly when determining the size of your code (i.e. a program containing no code (untitled.exe) subtracted from your program.exe) - your actual running code (.exe) is about 10.2 Kbytes (I get 2094080 -2083840 =~10.2 Kbytes) . If your computer (which runs almost exactly 2x faster than mine) is of similar/related architecture (eg INTEL >= i7) - then the 10K of .exe code is a candidate for L1.

On my laptop, L1 is 32K - but from my observations Windows background processes are using all processors (4 physical, 8 logical) even when CPU useage (Task Manager) is only say 30%. So at any time, a fairly large percentage of L1 is being "hogged" by Windows and you would be lucky to have any where near 10 Kbytes of "your" code in L1 (similar considerations for L2 and L3).


When, for a clearer understanding, I reduce your program (supplied below) to minimal requirements, the active code (.exe) is (2092032 - 2083840) =~ 8.2 Kbytes. To me, although the difference (10.2 - 8.2 Kb) may not seem much, in relative terms for L1 location (which is being "butchered" in useage by Windows background processes) - it is apparent that even a relatively slight change in .exe code can yield wildly differing timing results (because of Windows).


So your.exe (heavily referred part = 10.2 Kbytes) is only partly residing in L1 (similarly for L2 and L3) at any instance of time. When the _MemCopy code is acted on - some (_WIDTH * _HEIGHT  =~ 730,000) memory accesses are efficiently at machine level being processed, which is a very large number, which means L1 (after a setup time) is preloaded with the relevant _MemCopy machine Code. Also probably the _MemCopy is relatively small (say << 1K bytes) and has a high chance of 'displacing' not-so-much utilized Windows background processes that are "lying around still in L1". By virtue of the fact that _MemCopy machine code is "resident" in L1, any future references to m and m1 _MEM BLOCKS  (i.e. the rest of your program) would benefit from MEM code being in L1. In fact, with your test limit value of 100, some 73 million MEM operations (over about 10 seconds) would have speed improvement simply because the fact that _MEMCOPY was utilized once. HAD all of your 10.2 Kbyte of code been resident in L1 then POSSIBLY there may not be any significant between (with _MEMCOPY) versus (without _MEMCOPY). I do not know how to measure what is L1, L2, L3 at any time but as far as L1 goes it seems very apparent that windows is very aggressive in "hogging" L1, leaving much less than 10K bytes for anything else, and ONLY when a highly repetitive "small" amount of code (_MemCopy), in this case >730,000 iterations, is when some of L1 being "hogged" by windows is released for other applications (your program). In the first running part of your program (before _MemCopy), it is apparent that the relevant code is "too large" for what is immediately free in L1 and even a billion iterations of that code set may not "displace Windows background processes". In conclusion, _MEMCOPY (machine code small) performing 730000 iterations of memory referencing, is the winner.


Now it is interesting when running the code below, which is a drastically reduced version of your program (and there is NOTHING ACTUALLY TO SEE WHEN RUNNING), that the timing differences (with _MEMCOPY) versus (without _MEMCOPY) are relatively minor and may not even warrant discussion. But now we are taking about a smaller program (8.2 Kbyte) which has a much higher chance of being "resident" in L1 than the 10.2 Kbyte (your program). Now if you ran this shortened program many times, AND also with varying applications installed/removed (eg other instances of QB64, EDGE, etc) - then you will get "widely varied results" including sometimes (with _MEMCOPY) taking LONGER than (without _MEMCOPY) and relative timing ratios approaching 3:1. It appears that the "erratic behaviour" (i.e. non-consistent) of Windows background processes is the reasoning of this.


As a side note, referring to the reply #184 mentioned above, it would appear (without proper study/analysis) that anything running in L1 is approaching being 10x faster than the first time code is being performed. One has to wait for the setup times for preloading L1 before taking advantage of this.



Code: QB64: [Select]
  1. TestLimit = 100
  2. Dim TempGrid(0 To _Width - 1, 0 To _Height - 1) As Long
  3. dim TempGridn(0 To _Width - 1, 0 To _Height - 1) As Long
  4. Dim As _MEM m, m1: m = _Mem(TempGrid()): m1 = _MemImage(0)
  5. Dim As _MEM n, n1: n = _Mem(TempGridn()): n1 = _MemImage(0)
  6. Dim o As _Offset:o = 0
  7.  
  8. tb#=timer
  9.  
  10. for trials%=1 to TestLimit
  11.     o = 0
  12.     Do Until o >= m.SIZE
  13.         If _MemGet(m, m.OFFSET + o, _Unsigned Long) <> 0 Then _MemPut m1, m1.OFFSET + o, kolor As _UNSIGNED LONG
  14.         o = o + 4
  15.     Loop
  16.  
  17. t0#=timer:
  18.  
  19. _MemCopy n1, n1.OFFSET, n1.SIZE To n, n.OFFSET '*** this _MemCopy line added
  20. for trials%=1 to TestLimit
  21.     o = 0
  22.     Do Until o >= n.SIZE
  23.         If _MemGet(n, n.OFFSET + o, _Unsigned Long) <> 0 Then _MemPut n1, n1.OFFSET + o, kolor As _UNSIGNED LONG
  24.         o = o + 4
  25.     Loop
  26.  
  27. t2#=timer
  28.  
  29. Print  "(without   _MemCopy)"; t0# - tb#
  30. Print  "(including _MemCopy)"; t2# - t0#:print
  31. print "# of MEM references GRAND TOTAL =";
  32. print using "###,###,###";_WIDTH*_HEIGHT*Testlimit;
  33.  
  34.  
  35.  
  36.  

13
QB64 Discussion / Re: [v2.1 dev build] $DEBUG - problem with _FREEIMAGE ...
« on: November 30, 2021, 08:32:57 pm »
@FellippeHeitor

t& source is my "Mission Control Style "TaskBar"" (it is 3200 x 100 and located at the very top of the display) - my regular Windows TaskBar is at the bottom of the display.

The switching between t& and s& has been working for many months in normal mode (i.e. without debug being used at all). Without the _freeimage t& or s&, I was getting a severe memory leak (the switch-overs are more than 100 per hour).

Just today I have been trying to add a small change to my "Mission Control Style TaskBar"  - but I have a problem that it cannot write to a file anywhere - hence why I am even using $DEBUG.

Part of the requirement of the Mission Control Style TaskBar program (focus t&) is to obtain information from anywhere on the whole screen as needed.



14
QB64 Discussion / Re: [v2.1 dev build] $DEBUG - problem with _FREEIMAGE ...
« on: November 30, 2021, 07:33:12 pm »


@FellippeHeitor

Some more info regarding this.  The other source I am switching around with is the whole display (which has the $DEBUG IDE on the right hand side, whereas what I am testing is on the left hand side, sometimes right hand side, but mainly the top of screen).

The $DEBUG error never seems to occur with _FREEIMAGE s&, ONLY with _FREEIMAGE t&.

Note that the t& source relates to only the very top of the display (non-overlapping with $DEBUG IDE).

I am beginning to understand the conflict - at present only one monitor used - if I added a second (low quality) monitor, is it possible (and how), to have $DEBUG IDE only display on the second monitor

When $DEBUG reports the error, after about a second or two, it carries on until the next  _FREEIMAGE t& and so on...

The breakpoint occurs when the program is accessing the very top of the display.

t& = _NEWIMAGE(wdth, hght,32)
SCREEN t&

...

if s& <-1 then _freeimage s&
s& = _SCREENIMAGE
_SOURCE s&
...

IF t& < -1 then _FREEIMAGE t&   'This is line xxx
_SOURCE t&

15
QB64 Discussion / [v2.1 dev build] $DEBUG - problem with _FREEIMAGE ...
« on: November 30, 2021, 06:50:52 pm »
@FellippeHeitor

9f81ba1 dev build   Windows x64 Pro 21H1 Nov updated


When switching around various sources and using _FREEIMAGE ... eg with the partial code below

t& = _NEWIMAGE(wdth, hght,32)
SCREEN t&

...

IF t& < -1 then _FREEIMAGE t&   'This is line xxx
_SOURCE t&


get   "Error occurred on line xxx" message  and $DEBUG does not reach my breakpoint.


As $DEBUG now stands - it is totally un-useable for me when I have _FREEIMAGE code.

Pages: [1] 2 3 ... 25