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 - jbk

Pages: [1] 2 3 ... 13
1
Wish List / Re: Nuclear Option
« on: March 23, 2024, 12:32:29 PM »
MrBcx
the more recent gcc toolchainns have much better warning and error reporting, if you try the example with gcc-13.2 or above you will see the error message
<edit>
are you using llvm-g++?
llvm g++ simply calls clang and clang does not report the pragma inside a function as an error but simply ignores it
you need to use an non-llvm g++ 13.2 or better, but I won't bother you anymore

2
Wish List / Re: Nuclear Option
« on: March 23, 2024, 10:11:15 AM »
MrBcx, in my web search I don't know for certain if I came across documentation that states that the optimize pragma can't be used inside a function, but gcc-13.2 gives this error if the pragma is inside the function main of the example that we have been testing LengthOfInteger.cpp:142:9: error: '#pragma GCC optimize' is not allowed inside functions
clang is happy to compile the program if the clang pragma is inside main but it's completely ignored, perhaps other pragmas are allowed inside functions but not optimize
I will search the web for documentation

3
Wish List / Re: Nuclear Option
« on: March 22, 2024, 06:27:07 PM »
using clang with atomic I get
Code: [Select]
Time for             recursive:       1349
Time for      divide-iterative:       1350
Time for    multiply-iterative:       1114
Time for         if-statements:       1130
Time for reverse-if-statements:       1177
Time for                log-10:       3860
Time for           binary chop:       1256
if instead of atomic I do
only the main function from Robert's code posted below with the addition of a pragma
Code: [Select]
#pragma clang optimize off
int main (int c, char *v[]) {
//  _Atomic int i, j, k, r;
    int i, j, k, r;
    int s = 1;

    /* Test code:
        printf ("%11d %d\n", INT_MIN, count_recur(INT_MIN));
        for (i = -1000000000; i != 0; i /= 10)
            printf ("%11d %d\n", i, count_recur(i));
        printf ("%11d %d\n", 0, count_recur(0));
        for (i = 1; i != 1000000000; i *= 10)
            printf ("%11d %d\n", i, count_recur(i));
        printf ("%11d %d\n", 1000000000, count_recur(1000000000));
        printf ("%11d %d\n", INT_MAX, count_recur(INT_MAX));
    */

    /* Randomize and create random pool of numbers. */

    srand (time (NULL));
    for (j = 0; j < numof (rndnum); j++) {
        rndnum[j] = s * rand();
        s = -s;
    }
    rndnum[0] = INT_MAX;
    rndnum[1] = INT_MIN;

    /* For testing. */
    for (k = 0; k < numof (rndnum); k++) {
        rt[k] = (fn[1].fnptr)(rndnum[k]);
    }

    /* Test each of the functions in turn. */

    clk[0] = clock();
    for (i = 1; i < numof (fn); i++) {
        for (j = 0; j < 10000; j++) {
            for (k = 0; k < numof (rndnum); k++) {
                r = (fn[i].fnptr)(rndnum[k]);
                /* Test code:
                    if (r != rt[k]) {
                        printf ("Mismatch error [%s] %d %d %d %d\n",
                            fn[i].desc, k, rndnum[k], rt[k], r);
                        return 1;
                    }
                */
            }
        }
        clk[i] = clock();
    }

    /* Print out results. */

    for (i = 1; i < numof (fn); i++) {
        printf ("Time for %s: %10d\n", fn[i].desc, (int)(clk[i] - clk[i-1]));
    }

    return 0;
}
my time is
Code: [Select]
Time for             recursive:        658
Time for      divide-iterative:        566
Time for    multiply-iterative:        438
Time for         if-statements:        519
Time for reverse-if-statements:        502
Time for                log-10:       2730
Time for           binary chop:        487
unfortunately pragmas can not be used inside a function

you cal also use __attribute__ ((optnone)) but I prefer the pragma, it's cleaner syntax and you can also turn optimize back on with #pragma clang optimize on

4
Wish List / Re: Nuclear Option
« on: March 22, 2024, 10:19:49 AM »
I prefer
Code: [Select]
#pragma GCC push_options
#pragma GCC optimize("O0")
// your code here
#pragma GCC pop_options

5
Wish List / Re: Nuclear Option
« on: March 21, 2024, 07:43:34 PM »
here are my times
clang non-atomic, clang from https://github.com/mstorsjo/llvm-mingw/releases
Code: [Select]
Time for             recursive:          0
Time for      divide-iterative:          0
Time for    multiply-iterative:          0
Time for         if-statements:          0
Time for reverse-if-statements:          0
Time for                log-10:         78
Time for           binary chop:          0
atimic
Code: [Select]
Time for             recursive:       1349
Time for      divide-iterative:       1350
Time for    multiply-iterative:       1114
Time for         if-statements:       1130
Time for reverse-if-statements:       1177
Time for                log-10:       3860
Time for           binary chop:       1256
g++ 13.2 non-atomic -O2 , g++ from https://winlibs.com/
Code: [Select]
Time for             recursive:        548
Time for      divide-iterative:        487
Time for    multiply-iterative:        471
Time for         if-statements:        377
Time for reverse-if-statements:        423
Time for                log-10:       1287
Time for           binary chop:        393
I don't like the atomic times, they are about 2 times slower than g++
am also surprised that g++ didn't eliminate the loops

6
Questions & Answers / Re: output cpp
« on: March 19, 2024, 09:52:04 PM »
thank you Mr. Robert  :)
MrBcx
the quote of Robert was from a conversation about s126, it was the first hit from searching for clang my goal being to get cpp output, but it was s154 that I was dealing with
s154 builds just fine with clang and so does my decfloat stuff, but decfloat compiles without complaint in 64-bit but in 32-bit I get about 150+ warnings that the exponent is not initialized or something similar to that, wonder why the difference?
maybe different compiler warning options were used, I will have a look maybe tomorrow if GOD wills.

7
Questions & Answers / Re: output cpp
« on: March 19, 2024, 07:25:33 PM »
I think that I figured it out, it is in the RunCon64.bat but
%BCX%\bc %1 -cpp 1>bcxout.txt
also needed to edit gc64.bat to compile %1.cpp istead of %1.c, other bat files need editing

8
Questions & Answers / output cpp
« on: March 19, 2024, 07:00:51 PM »

https://bcxbasiccoders.com/smf/index.php?topic=20.msg818#msg818
Try translating s126.bas with the BCX -c switch to output .cpp and use clang++to compile.

or

try using the clang (not clang++) compiler on the C code.

clang++ does both C and C++

clang only C.
where exactly or in what batch file do I add -c ?
I added it to RunCon64.Bat
%BCX%\bc -c %1 1>bcxout.txt
but it seems to have no effect, I then added $CPP  at the top of file and that will cause it to output a cpp file but if there's a c file by the same name then the c file is compiled and not the cpp one until I delete the c file
the reason is that I want to use mstorsjo llvm toolchain https://github.com/mstorsjo/llvm-mingw/releases
I edited the mingw batch files to call clang++ instead of g++ and it works with the issues above, but clang++ doesn't like compiling c files as if they were cpp files
clang-18: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]

9
no, I was hoping that Jos would provide it and hopefully pscore5.dll doesn't have other dependencies

10
pscore5.dll is needed

11
I looked at the headers provided in your link and to me a C beginner looks confusing, the function BTRCALL would be defined like the following in FreeBasic
function BTRCALL(byval operation as BTI_WORD, byval posBlock as BTI_VOID_PTR, byval dataBuffer as BTI_VOID_PTR, byval dataLength as BTI_WORD_PTR, byval keyBuffer as BTI_VOID_PTR, byval keyLength as BTI_BYTE, byval ckeynum as BTI_CHAR) as BTI_API

in BTITYPES.H BTI_WORD is defined as
typedef BTI_WORD  BTI_FAR* BTI_WORD_PTR;

I don't know how to parse "typedef BTI_WORD  BTI_FAR* BTI_WORD_PTR;", is BTI_WORD a BTI_FAR pointer? or does it boil down to a VOID ptr?
either way, I am not confident that all the parameters in your function declaration are correct



12
User Contributions / Re: UPDATED Storm Demos
« on: March 07, 2024, 05:21:43 PM »
the BCX_FLOODFILL did help some but the balls are still jittery even at SetTimer 30 and a bit fuzzy, the jitters are shorter at SetTimer 30 but they are still there

13
User Contributions / Re: UPDATED Storm Demos
« on: March 07, 2024, 03:36:23 PM »
MrBcx
how do change the background color?
on my PC the balls move jittery but if I change TimerID = SetTimer(Form1, ID_TIMER, 50, NULL) from 50 to 30 then the balls move smoothly though quite a bit faster, but the black background makes it hard to distinguish the contour of the balls thereby making them look fuzzy

14
Announcements / Re: BCX Documentation Version 8.0.8, December 27 2023
« on: December 27, 2023, 03:13:17 PM »
👍😁

15
Announcements / Re: BCX v8.0.8 is available for download
« on: December 27, 2023, 12:30:43 PM »
👍 :)

Pages: [1] 2 3 ... 13