Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:17

0001 /**
0002 SGenstep_test.cc
0003 ==================
0004 
0005 ~/o/sysrap/tests/SGenstep_test.sh
0006 
0007 TEST=Slices_3 ~/o/sysrap/tests/SGenstep_test.sh
0008 TEST=Slices_4 ~/o/sysrap/tests/SGenstep_test.sh
0009 
0010 
0011 **/
0012 
0013 #include "ssys.h"
0014 #include "SGenstep.h"
0015 
0016 struct SGenstep_test
0017 {
0018     static int Slices_0();
0019     static int Slices_1();
0020     static int Slices_2();
0021     static int Slices_3();
0022     static int Slices_4();
0023     static int Slices_5();
0024 
0025     static int Main();
0026 };
0027 
0028 
0029 int SGenstep_test::Slices_0()
0030 {
0031     int64_t max_slot = 500 ;
0032     std::vector<int> num_ph = {  100,100,100,100,100,   100,100,100,100,100 } ;
0033     std::cout << SGenstep::DescNum(num_ph) ;
0034     NP* gs = SGenstep::MakeTestArray(num_ph) ;
0035 
0036     std::vector<sslice> sl ;
0037     SGenstep::GetGenstepSlices(sl, gs, max_slot );
0038 
0039     assert( sl.size() == 2 );
0040     assert( sl[0].matches(0,  5,   0, 500) );
0041     assert( sl[1].matches(5, 10, 500, 500) );
0042 
0043     std::cout << sslice::Desc(sl) ;
0044     return 0 ;
0045 }
0046 
0047 
0048 int SGenstep_test::Slices_1()
0049 {
0050     int64_t max_slot = 599 ;
0051     std::vector<int> num_ph = {  100,100,100,100,100,   100,100,100,100,100 } ;
0052     std::cout << SGenstep::DescNum(num_ph) ;
0053     NP* gs = SGenstep::MakeTestArray(num_ph) ;
0054 
0055     std::vector<sslice> sl ;
0056     SGenstep::GetGenstepSlices(sl, gs, max_slot );
0057 
0058     assert( sl.size() == 2 );
0059     assert( sl[0].matches(0,  5,   0, 500) );
0060     assert( sl[1].matches(5, 10, 500, 500) );
0061 
0062     std::cout << sslice::Desc(sl) ;
0063     return 0 ;
0064 }
0065 
0066 
0067 int SGenstep_test::Slices_2()
0068 {
0069     int64_t max_slot = 1000 ;
0070     std::vector<int> num_ph = {  100,100,100,100,100,   100,100,100,100,100 } ;
0071     std::cout << SGenstep::DescNum(num_ph) ;
0072     NP* gs = SGenstep::MakeTestArray(num_ph) ;
0073 
0074     std::vector<sslice> sl ;
0075     SGenstep::GetGenstepSlices(sl, gs, max_slot );
0076 
0077     assert( sl.size() == 1 );
0078     assert( sl[0].matches(0,  10,   0, 1000) );
0079 
0080     std::cout << sslice::Desc(sl) ;
0081     return 0 ;
0082 }
0083 
0084 
0085 int SGenstep_test::Slices_3()
0086 {
0087     int64_t max_slot = 1000 ;
0088     //                           0      1    2      3  4    5    6    7    8
0089     std::vector<int> num_ph =  { 300,   500, 200,   0, 100, 300, 400, 200, 400 } ;
0090     //                           300  800   1000  1000 1100 1400 1800 2000 2400
0091 
0092     std::cout << SGenstep::DescNum(num_ph) ;
0093     NP* gs = SGenstep::MakeTestArray(num_ph) ;
0094 
0095     std::vector<sslice> sl ;
0096     SGenstep::GetGenstepSlices(sl, gs, max_slot );
0097     std::cout << sslice::Desc(sl) ;
0098 
0099     assert( sl.size() == 3 );
0100     assert( sl[0].matches(0,  4,    0, 1000) );
0101     assert( sl[1].matches(4,  8, 1000, 1000) );
0102     assert( sl[2].matches(8,  9, 2000,  400) );
0103 
0104     return 0 ;
0105 }
0106 
0107 int SGenstep_test::Slices_4()
0108 {
0109     int64_t max_slot = 2400 ;
0110     //                           0      1    2      3  4    5    6    7    8
0111     std::vector<int> num_ph =  { 300,   500, 200,   0, 100, 300, 400, 200, 400 } ;
0112     //                           300  800   1000  1000 1100 1400 1800 2000 2400
0113     //  all 9 gs should fit into one slice
0114 
0115 
0116     std::cout << SGenstep::DescNum(num_ph) ;
0117     NP* gs = SGenstep::MakeTestArray(num_ph) ;
0118 
0119     std::vector<sslice> sl ;
0120     SGenstep::GetGenstepSlices(sl, gs, max_slot );
0121     std::cout << sslice::Desc(sl) ;
0122 
0123     assert( sl.size() == 1 );
0124     assert( sl[0].matches(0,  9,    0, 2400) );
0125 
0126     return 0 ;
0127 }
0128 
0129 int SGenstep_test::Slices_5()
0130 {
0131     int64_t MAX_INT32 = std::numeric_limits<int32_t>::max();
0132     int64_t max_slot = MAX_INT32 ;  // UNREALISTIC - DONT HAVE THAT AMOUNT OF VRAM
0133     std::vector<int64_t> num_ph =  { MAX_INT32, MAX_INT32, MAX_INT32, MAX_INT32 } ;
0134     //  expecting to need 4 slices for the 4 gensteps
0135 
0136     std::cout << SGenstep::DescNum(num_ph) ;
0137     NP* gs = SGenstep::MakeTestArray(num_ph) ;
0138 
0139     std::vector<sslice> sl ;
0140     int64_t tot_ph = SGenstep::GetGenstepSlices(sl, gs, max_slot );
0141     std::cout << sslice::Desc(sl) ;
0142 
0143     assert( tot_ph = 4*MAX_INT32 );
0144     assert( sl.size() == 4 );
0145     assert( sl[0].matches(0,  1,  0*MAX_INT32, MAX_INT32) );
0146     assert( sl[1].matches(1,  2,  1*MAX_INT32, MAX_INT32) );
0147     assert( sl[2].matches(2,  3,  2*MAX_INT32, MAX_INT32) );
0148     assert( sl[3].matches(3,  4,  3*MAX_INT32, MAX_INT32) );
0149 
0150     return 0 ;
0151 }
0152 
0153 
0154 
0155 
0156 
0157 
0158 int SGenstep_test::Main()
0159 {
0160     const char* TEST = ssys::getenvvar("TEST","ALL");
0161     bool ALL = strcmp(TEST, "ALL") == 0 ;
0162 
0163     int rc = 0 ;
0164     if(ALL||strcmp(TEST,"Slices_0") == 0 ) rc += Slices_0();
0165     if(ALL||strcmp(TEST,"Slices_1") == 0 ) rc += Slices_1();
0166     if(ALL||strcmp(TEST,"Slices_2") == 0 ) rc += Slices_2();
0167     if(ALL||strcmp(TEST,"Slices_3") == 0 ) rc += Slices_3();
0168     if(ALL||strcmp(TEST,"Slices_4") == 0 ) rc += Slices_4();
0169     if(ALL||strcmp(TEST,"Slices_5") == 0 ) rc += Slices_5();
0170 
0171     std::cout
0172         << "SGenstep_test::Main"
0173         << " TEST " << TEST
0174         << " rc " << rc
0175         << "\n"
0176         ;
0177 
0178 
0179     return rc ;
0180 }
0181 
0182 int main() {  return SGenstep_test::Main() ; }
0183