I ported my CryptoRnd to FreeBASIC.
For those not acquainted with CryptoRnd it uses Microsoft's BCryptGenRandom, so Windows Vista is the minimum OS required. Two buffers are created and random numbers are available once the first buffer has been populated, with the second buffer being populated in a separate thread of execution. When the first buffer has been exhausted we switch to the second buffer and then start to re-populate the first buffer. The buffers are actually split in two and each half is populated by its own thread of execution.
I recently learned of Thread Pooling, via Rick Kelly, so wrote CryptoRndII. CryptoRnd, with PowerBASIC, has a Single throughput of about 45MHz. CryptoRndII, with PowerBASIC, has a throughput of about 300MHz. PowerBASIC's RND has a throughput of about 80MHz. To put that into further perspective my CMWC256 comes in at about 142MHz. RND is a PRNG whereas CrytoRndII is a CPRNG. The test machine has an Intel i7-3770K @ 3.50GHz.
The output is Dword, Single, Double and Range. The Dword was fed into PractRand and it passed upto one Terabyte of data.
I may no longer be an active member here but I have not deserted and wanted to use CryptoRndII in some of my PowerBASIC apps but that would have required a rewrite. That would not have been a formidable task but the port of CryptoRnd to FreeBASIC was not exactly a 'walk in the park'. It was easier to create a dll. As with PowerBASIC, FreeBASIC creates small binaries - CrytoRndII.dll is only 20KB.
There are two procedures which must be employed before and after random number generation. The first is InitializeCryptoBuffers. Without this the host application will hang on Windows 10 and generate a GPF on earlier Windows. The second is CleanUpCryptoRndII which closes open threads in the pool, the pool itself and the BCryptGenRandom handle.
At the following link is a zipped folder, CryptoRndII.zip, which includes CryptoRndII.dll and TestBed.bas. TestBed.bas has the declares for all the public procedures and is a usage example as well as a test bed.
CryptoRndII.zip
For those not acquainted with CryptoRnd it uses Microsoft's BCryptGenRandom, so Windows Vista is the minimum OS required. Two buffers are created and random numbers are available once the first buffer has been populated, with the second buffer being populated in a separate thread of execution. When the first buffer has been exhausted we switch to the second buffer and then start to re-populate the first buffer. The buffers are actually split in two and each half is populated by its own thread of execution.
I recently learned of Thread Pooling, via Rick Kelly, so wrote CryptoRndII. CryptoRnd, with PowerBASIC, has a Single throughput of about 45MHz. CryptoRndII, with PowerBASIC, has a throughput of about 300MHz. PowerBASIC's RND has a throughput of about 80MHz. To put that into further perspective my CMWC256 comes in at about 142MHz. RND is a PRNG whereas CrytoRndII is a CPRNG. The test machine has an Intel i7-3770K @ 3.50GHz.
The output is Dword, Single, Double and Range. The Dword was fed into PractRand and it passed upto one Terabyte of data.
I may no longer be an active member here but I have not deserted and wanted to use CryptoRndII in some of my PowerBASIC apps but that would have required a rewrite. That would not have been a formidable task but the port of CryptoRnd to FreeBASIC was not exactly a 'walk in the park'. It was easier to create a dll. As with PowerBASIC, FreeBASIC creates small binaries - CrytoRndII.dll is only 20KB.
There are two procedures which must be employed before and after random number generation. The first is InitializeCryptoBuffers. Without this the host application will hang on Windows 10 and generate a GPF on earlier Windows. The second is CleanUpCryptoRndII which closes open threads in the pool, the pool itself and the BCryptGenRandom handle.
At the following link is a zipped folder, CryptoRndII.zip, which includes CryptoRndII.dll and TestBed.bas. TestBed.bas has the declares for all the public procedures and is a usage example as well as a test bed.
CryptoRndII.zip
Comment