Ignore:
Timestamp:
Nov 26, 2008 2:37:41 PM (14 years ago)
Author:
srkline
Message:

Threading is now included in MonteCarlo?, and CylPolyRad?, and BCC, as WaveMetrics? has fixed teh bug in Igor in version 6.10B04

Threading can now be added to all appropriate fit functions, provided we require 6.10 (when it is a release version)

Threading issues with MonteCarlo? appear to be due to NR ran() routines, which are not thread safe. Duplicate function instances (with different names) have been created. This works, but is inelegant.

Location:
sans/Dev/trunk/NCNR_User_Procedures
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/Models/NewModels_2006/Cylinder_PolyRadius_v40.ipf

    r455 r457  
    294294 
    295295///////NON-THREADED VERSION /////// 
    296 #if exists("Cyl_PolyRadiusX")    
    297         yw = Cyl_PolyRadiusX(cw,xw) 
     296//#if exists("Cyl_PolyRadiusX")  
     297//      yw = Cyl_PolyRadiusX(cw,xw) 
     298//#else 
     299//      yw = fCyl_PolyRadius(cw,xw) 
     300//#endif 
     301 
     302///// THREADED VERSION NEEDS Igor 6.10B04 or higher to avoid crashes //////      
     303#if exists("Cyl_PolyRadiusX") 
     304 
     305        Variable npt=numpnts(yw) 
     306        Variable i,nthreads= ThreadProcessorCount 
     307        variable mt= ThreadGroupCreate(nthreads) 
     308 
     309        for(i=0;i<nthreads;i+=1) 
     310        //      Print (i*npt/nthreads),((i+1)*npt/nthreads-1) 
     311                ThreadStart mt,i,Cyl_PolyRadius_T(cw,yw,xw,(i*npt/nthreads),((i+1)*npt/nthreads-1)) 
     312        endfor 
     313 
     314        do 
     315                variable tgs= ThreadGroupWait(mt,100) 
     316        while( tgs != 0 ) 
     317 
     318        variable dummy= ThreadGroupRelease(mt) 
     319         
    298320#else 
    299         yw = fCyl_PolyRadius(cw,xw) 
     321                yw = fCyl_PolyRadius(cw,xw)             //the Igor, non-XOP, non-threaded calculation, messy to make ThreadSafe 
    300322#endif 
    301  
    302 /// THREADED VERSION HAS BEEN REMOVED DUE TO CRASHES //////      
    303 //#if exists("Cyl_PolyRadiusX") 
    304 // 
    305 //      Variable npt=numpnts(yw) 
    306 //      Variable i,nthreads= ThreadProcessorCount 
    307 //      variable mt= ThreadGroupCreate(nthreads) 
    308 // 
    309 //      for(i=0;i<nthreads;i+=1) 
    310 //      //      Print (i*npt/nthreads),((i+1)*npt/nthreads-1) 
    311 //              ThreadStart mt,i,Cyl_PolyRadius_T(cw,yw,xw,(i*npt/nthreads),((i+1)*npt/nthreads-1)) 
    312 //      endfor 
    313 // 
    314 //      do 
    315 //              variable tgs= ThreadGroupWait(mt,100) 
    316 //      while( tgs != 0 ) 
    317 // 
    318 //      variable dummy= ThreadGroupRelease(mt) 
    319 //       
    320 //#else 
    321 //              yw = fCyl_PolyRadius(cw,xw)             //the Igor, non-XOP, non-threaded calculation, messy to make ThreadSafe 
    322 //#endif 
    323323 
    324324//      Print "elapsed time = ",(StopMSTimer(-2) - t1)/1e6 
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/Models/NewModels_2008/BCC_ParaCrystal_v40.ipf

    r455 r457  
    105105        Wave cw,yw,xw 
    106106 
    107 ///// NO threading ///////// 
     107/////// NO threading ///////// 
     108//#if exists("BCC_ParaCrystalX") 
     109//      yw = BCC_ParaCrystalX(cw,xw) 
     110//#else 
     111//      yw = fBCC_ParaCrystal(cw,xw) 
     112//#endif 
     113 
     114 
     115/// THREADING /////// 
     116 
     117//      Variable t1=StopMSTimer(-2) 
     118                 
    108119#if exists("BCC_ParaCrystalX") 
    109         yw = BCC_ParaCrystalX(cw,xw) 
     120 
     121        Variable npt=numpnts(yw) 
     122        Variable i,nthreads= ThreadProcessorCount 
     123        variable mt= ThreadGroupCreate(nthreads) 
     124 
     125        for(i=0;i<nthreads;i+=1) 
     126        //      Print (i*npt/nthreads),((i+1)*npt/nthreads-1) 
     127                ThreadStart mt,i,BCC_ParaCrystal_T(cw,yw,xw,(i*npt/nthreads),((i+1)*npt/nthreads-1)) 
     128        endfor 
     129 
     130        do 
     131                variable tgs= ThreadGroupWait(mt,100) 
     132        while( tgs != 0 ) 
     133 
     134        variable dummy= ThreadGroupRelease(mt) 
     135         
    110136#else 
    111         yw = fBCC_ParaCrystal(cw,xw) 
     137                yw = fBCC_ParaCrystal(cw,xw)            //the Igor, non-XOP, non-threaded calculation, messy to make ThreadSafe 
    112138#endif 
    113139 
    114  
    115 /// THREADING /////// 
    116  
    117 ////    Variable t1=StopMSTimer(-2) 
    118 //               
    119 //#if exists("BCC_ParaCrystalX") 
    120 // 
    121 //      Variable npt=numpnts(yw) 
    122 //      Variable i,nthreads= ThreadProcessorCount 
    123 //      variable mt= ThreadGroupCreate(nthreads) 
    124 // 
    125 //      for(i=0;i<nthreads;i+=1) 
    126 //      //      Print (i*npt/nthreads),((i+1)*npt/nthreads-1) 
    127 //              ThreadStart mt,i,BCC_ParaCrystal_T(cw,yw,xw,(i*npt/nthreads),((i+1)*npt/nthreads-1)) 
    128 //      endfor 
    129 // 
    130 //      do 
    131 //              variable tgs= ThreadGroupWait(mt,100) 
    132 //      while( tgs != 0 ) 
    133 // 
    134 //      variable dummy= ThreadGroupRelease(mt) 
    135 //       
    136 //#else 
    137 //              yw = fBCC_ParaCrystal(cw,xw)            //the Igor, non-XOP, non-threaded calculation, messy to make ThreadSafe 
    138 //#endif 
    139 // 
    140 ////    Print "elapsed time = ",(StopMSTimer(-2) - t1)/1e6 
     140//      Print "elapsed time = ",(StopMSTimer(-2) - t1)/1e6 
    141141 
    142142 
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/Packages/ModelPicker/SANSModelPicker_v40.ipf

    r455 r457  
    576576                        DeletePoints ii, 1, includedFileWave,selToDel 
    577577                        // 
    578                         // be sure to kill the dependencies, otherwise some nasty crashes can result 
    579                         // (a bug in the WM's threading??? 
    580                         funcToDelStr = FunctionList("*",";","WIN:"+fname+fileVerExt+".ipf") 
    581                         KillAllDependentObjects("root:",funcToDelStr, 1, 1, 0) 
     578                        // could kill dependencies connected to the procedure file, but really not necessary 
     579                        //funcToDelStr = FunctionList("*",";","WIN:"+fname+fileVerExt+".ipf") 
     580                        //KillAllDependentObjects("root:",funcToDelStr, 1, 1, 0) 
    582581                          
    583582                endif 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/MultScatter_MonteCarlo_2D.ipf

    r456 r457  
    102102                        WAVE inputWave1,ran_dev1,nt1,j11,j21,nn1,linear_data1,retWave1 
    103103                        //retWave1[0] = -1*datetime             //to initialize ran3 
    104                         ThreadStart mt,i,Monte_SANS_W1(inputWave1,ran_dev1,nt1,j11,j21,nn1,linear_data1,retWave1) 
     104                        ThreadStart mt,i,Monte_SANS_W2(inputWave1,ran_dev1,nt1,j11,j21,nn1,linear_data1,retWave1) 
    105105                        Print "started thread 1" 
    106106                endif 
     
    191191        WAVE inputWave,ran_dev,nt,j1,j2,nn,linear_data,results 
    192192         
    193 #if exists("xxxxMonte_SANSX") 
    194         Monte_SANSX(inputWave,ran_dev,nt,j1,j2,nn,linear_data,results) 
     193#if exists("Monte_SANSX2") 
     194        Monte_SANSX2(inputWave,ran_dev,nt,j1,j2,nn,linear_data,results) 
    195195#else 
    196196        Monte_SANS(inputWave,ran_dev,nt,j1,j2,nn,linear_data,results) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/SASCALC.ipf

    r456 r457  
    758758                t0 = stopMStimer(-2) 
    759759                inputWave[0] = 1000 
     760//              Monte_SANS_Threaded(inputWave,ran_dev,nt,j1,j2,nn,linear_data,results) 
    760761                Monte_SANS_NotThreaded(inputWave,ran_dev,nt,j1,j2,nn,linear_data,results) 
    761762                t0 = (stopMSTimer(-2) - t0)*1e-6 
    762                 t0 *= imon/1000         //projected time, in seconds 
     763                t0 *= imon/1000/ThreadProcessorCount                    //projected time, in seconds (using threads for the calculation) 
    763764                inputWave[0] = imon             //reset 
    764765                 
     
    774775                 
    775776                linear_data = 0         //initialize 
    776 // threading crashes!! - there must be some operation in the XOP that is not threadSafe. What, I don't know...           
     777// threading crashes!! - there must be some operation in the XOP that is not threadSafe. What, I don't know... 
     778// I think it's the ran() calls, being "non-reentrant". So the XOP now defines two separate functions, that each 
     779// use a different rng. This works. 1.75x speedup.       
    777780                t0 = stopMStimer(-2) 
    778781 
    779 //              xMonte_SANS_Threaded(inputWave,ran_dev,nt,j1,j2,nn,linear_data,results) 
    780                 Monte_SANS_NotThreaded(inputWave,ran_dev,nt,j1,j2,nn,linear_data,results) 
     782                Monte_SANS_Threaded(inputWave,ran_dev,nt,j1,j2,nn,linear_data,results) 
     783//              Monte_SANS_NotThreaded(inputWave,ran_dev,nt,j1,j2,nn,linear_data,results) 
    781784 
    782785                t0 = (stopMSTimer(-2) - t0)*1e-6 
Note: See TracChangeset for help on using the changeset viewer.