File indexing completed on 2026-04-09 07:49:16
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ssys.h"
0010 #include "SCurandState.h"
0011
0012 #include <curand_kernel.h>
0013 using RNG = curandStateXORWOW ;
0014
0015
0016 struct SCurandState_test
0017 {
0018 static SCurandChunk Chunk();
0019
0020 static int ctor();
0021 static int NumFromFilesize();
0022 static int ParseDir();
0023 static int ChunkLoadSave();
0024 static int load();
0025 static int loadAndUpload();
0026
0027 static int Main();
0028 };
0029
0030 inline SCurandChunk SCurandState_test::Chunk()
0031 {
0032 SCurandChunk chunk = {} ;
0033 chunk.ref.chunk_idx = 0 ;
0034 chunk.ref.chunk_offset = 0 ;
0035 chunk.ref.num = 1000000 ;
0036 chunk.ref.seed = 0 ;
0037 chunk.ref.offset = 0 ;
0038
0039 return chunk ;
0040 }
0041
0042 inline int SCurandState_test::ctor()
0043 {
0044 SCurandState cs ;
0045 std::cout << cs.desc();
0046 return 0 ;
0047 }
0048
0049 inline int SCurandState_test::NumFromFilesize()
0050 {
0051 SCurandChunk chunk = Chunk();
0052 std::string n = chunk.name() ;
0053 long st = SCurandChunk::NumFromFilesize(n.c_str());
0054 int rc = st == 1000000 ? 0 : 1 ;
0055 return rc ;
0056 }
0057
0058 inline int SCurandState_test::ParseDir()
0059 {
0060 std::vector<SCurandChunk> chunks ;
0061 SCurandChunk::ParseDir(chunks );
0062
0063 return 0 ;
0064 }
0065
0066 inline int SCurandState_test::ChunkLoadSave()
0067 {
0068 SCurandChunk chunk0 = Chunk();
0069 std::string n0 = chunk0.name();
0070
0071 typedef unsigned long long ULL ;
0072 ULL q_num = 0 ;
0073 const char* dir = nullptr ;
0074
0075 SCurandChunk chunk = {} ;
0076 int rc0 = SCurandChunk::OldLoad(chunk, n0.c_str(), q_num, dir) ;
0077 int rc1 = chunk.save("$FOLD");
0078
0079 std::cout
0080 << "SCurandState_test::ChunkLoadSave"
0081 << " rc0 " << rc0
0082 << " rc1 " << rc1
0083 << "\n"
0084 ;
0085
0086 return rc0 + rc1 ;
0087 }
0088
0089 inline int SCurandState_test::load()
0090 {
0091 SCurandChunk c = Chunk();
0092 scurandref lref = c.load();
0093
0094 std::cout
0095 << "SCurandState_test::load\n"
0096 << " c.ref.desc " << c.ref.desc() << "\n"
0097 << " lref.desc " << lref.desc() << "\n"
0098 << "\n"
0099 ;
0100
0101 return lref.states ? 0 : 1 ;
0102 }
0103
0104
0105
0106 inline int SCurandState_test::loadAndUpload()
0107 {
0108 SCurandState cs ;
0109 std::cout << cs.desc() ;
0110
0111 unsigned rngmax = 1000000 ;
0112 RNG* d0 = cs.loadAndUpload<RNG>(rngmax);
0113
0114 std::cout << " d0 " << d0 << std::endl ;
0115
0116 return 0 ;
0117 }
0118
0119
0120 inline int SCurandState_test::Main()
0121 {
0122 const char* TEST = ssys::getenvvar("TEST", "ALL");
0123 bool ALL = strcmp(TEST, "ALL") == 0 ;
0124
0125 int rc = 0 ;
0126 if(ALL||strcmp(TEST,"ctor") == 0) rc += ctor();
0127 if(ALL||strcmp(TEST,"NumFromFilesize") == 0) rc += NumFromFilesize();
0128 if(ALL||strcmp(TEST,"ParseDir") == 0) rc += ParseDir();
0129 if(ALL||strcmp(TEST,"ChunkLoadSave") == 0) rc += ChunkLoadSave();
0130 if(ALL||strcmp(TEST,"load") == 0) rc += load();
0131 if(ALL||strcmp(TEST,"loadAndUpload") == 0) rc += loadAndUpload();
0132 return rc ;
0133 }
0134
0135
0136 int main()
0137 {
0138 return SCurandState_test::Main() ;
0139 }