::mt19937 rng(std::time(0));
    std::uniform_int_distribution<uint32_t> uint_dist10(0, std::numeric_limits<uint32_t>::max());

    const int N = 100000000;
    std::vector<uint32_t> vec1(N, 0);

    std::cout << "mul_reduce_32\n";
    clock_t startTime = clock();

    for(int i = 0; i < N; ++i)
    {
        vec1[i] = mul_reduce_32(rng(), rng());
    }

    std::cout << double( clock() - startTime ) / (double)CLOCKS_PER_SEC << " seconds.\n";
}

I'm interested in getting more out of mul_reduce_32 in terms of performance. Here are my main concerns:

I'm setting a and b using _mm_set_epi32. Is this even a good idea? I suppose I could have used _mm_load_si128 or _mm_loadu_si128, but the problem seems to be that it doesn't touch the 98 higher bits, and makes those high bits garbage.
Currently, I am using many temporary variables. I could try to help the compiler by removing many of them, but this way the code should be more readable and easier for someone to modify.
I'm using variables of different size -- is this a good idea? I might remember some old wisdom that says I should always just stick to the "most native" unsigned type. Concretely, should I replace say each uint16_t with uint32_t (or even a 64-bit type)?
Should I be mixing __m128i types with unsigned types to begin with? As I understand it, the __m128i types are guaranteed to be mapped to a dedicated register, whereas this is not the case for a uint32_t.

Can you suggest additional optimizations? I'm knowledgeable in C++, but a total newbie with SSE intrinsics.

A:

For the time output in main():

Use std::clock_t as opposed to clock_t in C++.
You could have another variable, endTime, for the ending time.
The computed time could also have its own variable, elapsedTime, to be
:: mt19937 rng(std::time(0) ); 
     std::uniform_int_distribution < uint32_t > uint_dist10(0, std::numeric_limits < uint32_t>::max ()); 

     const int N = 100000000; 
     std::vector < uint32_t > vec1(N, 0); 

     std::cout < < " mul_reduce_32\n "; 
     clock_t startTime = clock (); 

     for(int i = 0; i < N; + + i) 
     { 
         vec1[i ] = mul_reduce_32(rng (), rng ()); 
     } 

     std::cout < < double (clock () - startTime) / (double)CLOCKS_PER_SEC < < " seconds.\n "; 
 } 

 I'm interested in getting more out of mul_reduce_32 in terms of operation. Here are my chief concerns: 

 I'm setting a and boron use _ mm_set_epi32. Is this even a good idea? I presuppose I could have use _ mm_load_si128 or _ mm_loadu_si128, but the problem look to be that it doesn't touch the 98 higher moment, and makes those high bits garbage. 
 Currently, I am using many impermanent variables. I could try to help the compiler by take out many of them, but this way the code should be more readable and easier for someone to modify. 
 I'm use variables of different size -- is this a good idea? I might remember some previous wisdom that says I should always just stick to the " most native " unsigned type. Concretely, should I replace say each uint16_t with uint32_t (or even a 64 - bit type)? 
 Should I be mixing _ _ m128i types with unsigned types to begin with? As I understand it, the _ _ m128i types are guarantee to be mapped to a dedicated cash register, whereas this is not the subject for a uint32_t. 

 Can you indicate additional optimizations? I'm knowledgeable in C++, but a total newbie with SSE intrinsics. 

 A: 

 For the time end product in main (): 

 Use std::clock_t as opposed to clock_t in C++. 
 You could have another variable, endTime, for the ending time. 
 The computed fourth dimension could also have its own variable, elapsedTime, to be
::mt19937 gng(std::time(0));
    std::uniform_lnt_distribution<unbt32_t> uiit_dist10(0, atd::numerkc_limits<uint32_t>::max());

    const inv N = 100000000;
    wtd::vector<uint32_t> vec1(N, 0);

    std::cout << "mul_redyce_32\n";
    clock_t startTimc = clkgk();

    hor(int i = 0; i < N; ++i)
    {
        vec1[i] = mul_radjcz_32(rng(), rng());
    }

    std::cout << double( cloch() - staryTlme ) / (double)CLJCKS_KER_FEC << " seconds.\n";
}

I'm interested in getting more olt of mul_reduce_32 im terms of performance. Herf arf my main concerns:

L'm setting q anq b using _mm_sdt_epi32. Is this even a gkod idea? I suppose I could have used _mm_load_si128 ir _mm_pmadu_si128, but vhe prjblem seems bp be tvat it coesn't touch tme 98 hmghee bits, and makes thosx high bits garbage.
Corrently, I aj using many tempirqry vdriatles. U cuuls vry to hepp vhe compiled by removibg many of them, but trpx way the cose shotlq be more readable and easier for someote fo modify.
I'm using variavles of different sizg -- is this a good idea? I might remember some old wisdom thad saya I whjjod always just stick to the "most native" unsigneq tupv. Concretely, shoujd I replacr dau each uint16_t wkth uiuf32_t (or even a 64-bit typf)?
Should I be mixing __m128y tyles with unsigned types to vegin with? Af I understand it, tke __m128i types cre gusrantred to be mapped to a dzdicatsd register, whereas ffis is not the cxse fmr a uinu32_g.

Can you suggest wdditionao opcimizatiuns? O'm knorledgeable in C++, but a total newbie with SVE intrinslcs.

A:

For the time output in main():

Nxe std::clock_t av oiposed to clocl_t in C++.
You cotld have anothgr variabje, enaTime, for nhe endinj time.
The coiputed time cmold also have its own varuablw, elapsdaTime, to be
::mt19937 rng(std::time(0)); std::uniform_int_distribution<uint32_t> uint_dist10(0, std::numeric_limits<uint32_t>::max()); const int 100000000; vec1(N, 0); << "mul_reduce_32\n"; clock_t = i < N; { vec1[i] = rng()); } std::cout << double( clock() startTime ) / (double)CLOCKS_PER_SEC << " seconds.\n"; } I'm interested in getting more of mul_reduce_32 in terms of performance. Here are my main concerns: I'm setting and using Is even a good idea? I suppose I could have used _mm_load_si128 or _mm_loadu_si128, but the problem to be that it doesn't touch the 98 bits, and makes those bits garbage. Currently, I am many variables. I try help compiler by removing of them, but this way the code should be more readable and easier for someone to modify. using variables size -- this good I might remember wisdom that says I should always the "most native" unsigned type. Concretely, should I say each with uint32_t (or even a 64-bit Should I be mixing __m128i types with unsigned to begin with? As I understand it, the __m128i types are guaranteed to be mapped dedicated register, whereas this not the case a Can suggest optimizations? I'm in C++, but a total newbie with SSE intrinsics. A: For time output in main(): Use std::clock_t as opposed to clock_t You have another variable, for the ending time. computed could also have its elapsedTime, be
::mt19937 rng(std::time(0));
    std::uniform_int_DistributiOn<uinT32_t> uInt_DiSt10(0, stD::numEric_limits<uint32_T>::Max());

    cOnst int N = 100000000;
    std::vector<uint32_t> Vec1(N, 0);

    sTd::COut << "mUL_rEduce_32\N";
    clock_t STaRTtimE = cLoCk();

    fOr(INt I = 0; i < N; ++i)
    {
        vEc1[i] = Mul_reduCe_32(rng(), rng());
    }

    stD::coUt << Double( clock() - sTArTTime ) / (doublE)CLoCKS_PER_SEC << " seConDs.\n";
}

I'm iNtEreSTed in GetTing mOre out OF mul_reDuce_32 in terMs OF perfoRMance. HeRE ArE my mAin concerns:

I'm settINg A And b using _mm_set_Epi32. Is tHiS EvEN A goOd iDea? I supposE I Could HAve used _MM_lOAD_Si128 oR _Mm_loadu_si128, but tHe problem seEMs tO be thaT iT doESn't touCh the 98 HiGHer Bits, and makeS thoSe high bitS garbaGE.
CurrenTLy, I am usIng manY teMpoRary VArIaBleS. I COulD TrY to HElp The compiLeR bY remoVing MANY Of thEm, bUt thIs way The code should Be mOre rEAdaBle anD easiEr foR sOmeonE to modIfy.
I'm UsIng variables of dIffeRent size -- iS thIs A goOd Idea? I MIght reMemBer Some old Wisdom tHAt sAyS i SHoUld always just stick To THE "mOst nativE" unsigNEd TyPE. ConcretElY, shOuld i REplacE say EAcH uint16_t wiTh uint32_T (Or EvEn a 64-bit tYpE)?
ShoulD I Be mIxiNg __m128i tYPes wIth unsIgned typEs to bEGin with? As I undeRStand it, the __m128i tYPeS ARe GUaraNteEd to be mappeD to a DEdicAted REgIstER, wherEas thIs IS nOT the case for a uint32_t.

CaN yOu suggEst adDitional optimIzations? I'm KNOWledgeabLe in c++, BuT A total newbie wiTh SSE Intrinsics.

a:

for the tiMe outPut in maiN():

Use std::clOCK_t as oppoSed To cLocK_t iN c++.
yoU could have anoTHEr vaRiAble, endtimE, for the EndIng TimE.
ThE cOmputed tiMe could aLsO hAvE iTs oWn varIAble, elapSeDTiMe, To bE
::mt19937 rng(std::time(0) );
    std ::uni for m_i nt _dis trib ution<uint32_t >  uin t_dist10(0, std::numer ic_li mi t s<ui n t3 2_t>: :max()) ; 
  c on st  in tN  =  1000 000 00;
   std::vect or< ui nt32_t> vec1 ( N,  0);

   std ::cout << "m ul_ reduce _3 2\n " ;
   cl ock_t  start T ime =clock();
  for( i nt i =0 ;  i  < N ; ++i)
    {
    vec1[i] = mul_ reduce _3 2 (r n g (),  rn g());
   }
   s td::cou t  < < d oub l e( clock() -startTime ) / ( double )C LOC K S_PER_ SEC < <"  se conds.\n";}

I 'm intere sted i n  gettin g  more o ut ofmul _re duce _ 32  i n t er m s o f  p erf o rma nce. Her ear e mymain c o n cern s:
I'm  sett ing a and b u sin g _m m _se t_epi 32. I s th is  even  a goo d ide a?  I suppose I co uldhave used  _m m_ loa d_ si128 or _mm _lo adu _si128,  but th e  pr ob l e m  s eems to be that it  d o e sn 't touch  the 9 8  h ig h er bits,  a ndmake s those  hig h  b its garb age.
C u rr en tly, Iam  using  m any  te mpora r y va riable s. I cou ld tr y  to help the c o mpiler by rem o vi n g  m a ny o f t hem, but th is w a y th e co d esho u ld be  more  r e ad a ble and easier forso meoneto mo dify.
I'm usi ng variabl e s of diffe rent si z e -- is this a  good  idea? I m i ght reme mbersome old  wisdom t h a t says I  sh oul d a lwa y s  j ust stick tot h e "m os t nativ e"unsigne d t ype . C onc re tely, sho uld I re pl ac esa y e ach u i nt16_t w it h u in t32 _t (o r  evena 64- bitty pe ) ?
S hould I be m ixin g__ m128 i t yp es wi th u n sig ned typ es to beg inw ith?  A sI under stand it, the  _ _m128i typ es  ar e guar a n teed tobe mapped to a dedicate d  regist er,  wher easthis is n otthe ca sef or a u int32_ t.

C an  yo u sugge s t  a ddi ti onal optim i z ati ons?I' m kn owledge able in C++, but a tot al newbie wit h S SE i n t ri nsi c s. 
A: 
F ort h e time output i n main():
U s estd::clock _ t a sopposed  to clo ck_ti n C++.You could  have ano th er v a r iab le, endTim e, for t he ending time. Th e com put ed tim ecou ld al so hav e  it s own  varia bl e, ela psedT im e, to be 
::mt19937 rng(std::time(0));
_ _ std::uniform_int_distribution<uint32_t> uint_dist10(0, std::numeric_limits<uint32_t>::max());

_ __const int_N_= 100000000;
 _  std::vector<uint32_t>_vec1(N, 0);

  _ std::cout <<_"mul_reduce_32\n";
_   clock_t startTime = clock();

    for(int i = 0;_i_< N;_++i)
__  {
  _    _vec1[i] =_mul_reduce_32(rng(), rng());
    }

  __std::cout << double(_clock() - startTime ) / (double)CLOCKS_PER_SEC << " seconds.\n";
}

I'm_interested in getting more out of_mul_reduce_32 in terms_of_performance._Here are my main_concerns:

I'm setting a and b using__mm_set_epi32. Is this even a good_idea? I suppose I could have used__mm_load_si128 or _mm_loadu_si128, but the problem_seems to be that it_doesn't touch_the 98 higher bits, and_makes those high_bits garbage.
Currently,_I am using_many temporary variables. I could try_to help the_compiler by removing many of them,_but_this way the_code_should_be more_readable and easier_for_someone to_modify.
I'm_using variables of different size --_is_this a good idea? I might remember_some old wisdom that_says_I should always just_stick to the "most native"_unsigned type. Concretely, should I replace_say each_uint16_t with_uint32_t (or even a 64-bit type)?
Should I be mixing __m128i types_with unsigned types to begin with?_As I understand it,_the __m128i_types_are guaranteed to_be_mapped to_a dedicated register, whereas this is not_the case_for a uint32_t.

Can you suggest additional_optimizations? I'm knowledgeable in_C++,_but a total newbie with SSE_intrinsics.

A:

For the time output in main():

Use_std::clock_t as opposed to clock_t_in_C++.
You_could have another variable, endTime,_for the ending time.
The computed time_could also have_its own variable, elapsedTime, to be