Changeset 34952

Show
Ignore:
Timestamp:
08/20/09 22:02:35 (4 years ago)
Author:
saturday06
Message:

tbb

Location:
lang/objective-cplusplus/i3/trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • lang/objective-cplusplus/i3/trunk/src/mil/include/mil/Memory.h

    r34852 r34952  
    8282    MemoryList* memory; 
    8383}; 
    84  
    85 #define MIL_MALLOC_PRODUCERioioioio 
     84} 
     85} 
     86 
     87#define MIL_MALLOC_PRODUCERooo 
     88#define MIL_TBB_PRODUCERooo 
     89 
    8690#ifdef MIL_MALLOC_PRODUCER 
    87  
     91namespace mil { 
     92namespace pool { 
    8893class Producer { 
    8994public: 
     
    115120    } 
    116121}; 
    117  
    118 #elif MIL_TBB_PRODUCER 
     122} 
     123} 
     124#elif defined(MIL_TBB_PRODUCER) 
     125#include <tbb/scalable_allocator.h> 
     126namespace mil { 
     127namespace pool { 
     128struct TbbMemoryUnit { 
     129        char data[BLOCK_SIZE]; 
     130}; 
     131extern tbb::scalable_allocator<TbbMemoryUnit> tbb_allocator; 
     132class Producer { 
     133public: 
     134    Producer() { 
     135    } 
     136    Producer(intptr_t) { 
     137    } 
     138    template <int BYTES> 
     139    void* malloc() { 
     140        int blocks = Bytes2Blocks<BYTES>::value; 
     141        if (blocks > MALLOC_BLOCKS_THESHOLD) { 
     142            return ::malloc(BYTES); 
     143        } else { 
     144            return tbb_allocator.allocate(blocks); 
     145        } 
     146    } 
     147    void free(void*, int) { 
     148        halt << "free2()"; 
     149    } 
     150    void free(MemoryList*) { 
     151        halt << "free()"; 
     152    } 
     153}; 
     154 
     155class Consumer { 
     156public: 
     157    MemoryList* pop(int) { 
     158        return NULL; 
     159    } 
     160 
     161    template <class T> 
     162    void store(T* mem) { 
     163        size_t blocks = pool::bytes_to_blocks(return_memory_considered_sizeof<T>()); 
     164        if (blocks > (size_t)MALLOC_BLOCKS_THESHOLD) { 
     165            ::free((void*)mem); 
     166        } else { 
     167                        tbb_allocator.deallocate((mil::pool::TbbMemoryUnit*)mem, blocks); 
     168        } 
     169    } 
     170}; 
     171} 
     172} 
    119173#else 
    120  
     174namespace mil { 
     175namespace pool { 
    121176#define MIL_DEBUG_PRODUCERiii 
    122177 
     
    215270 
    216271    enum { 
    217         MAX_STORES = 20, 
     272        MAX_STORES = 30, 
    218273    }; 
    219274 
     
    254309    } 
    255310}; 
    256  
     311} 
     312} 
    257313#endif // MIL_MALLOC_PRODUCER, MIL_TBB_PRODUCER 
    258314 
     
    278334}; 
    279335*/ 
    280  
    281 } 
    282 } 
    283  
    284  
  • lang/objective-cplusplus/i3/trunk/src/mil/include/mil/StaticData.cpp

    r34863 r34952  
    1717 
    1818namespace mil { 
     19#ifdef MIL_TBB_PRODUCER 
     20namespace pool { 
     21tbb::scalable_allocator<TbbMemoryUnit> tbb_allocator; 
     22} 
     23#endif 
    1924 
    2025namespace thread { 
  • lang/objective-cplusplus/i3/trunk/src/mil/src/Test11.cpp

    r34865 r34952  
    3737 
    3838// bench class 
    39 const unsigned int POST_MAX = 2000; 
     39const unsigned int POST_MAX = 200000; 
    4040const unsigned int NUM_THREADS = 19; 
    4141 
     
    7777    } 
    7878    void execute(AllPosted& e) { 
    79         //printf("AllPosted Received : %lf, global = %d, index = %d\n", 
    80         //       (double)(clock() - begin) / CLOCKS_PER_SEC, global.load(), index); 
     79        printf("AllPosted Received : %lf, global = %d, index = %d\n", 
     80               (double)(clock() - begin) / CLOCKS_PER_SEC, global.load(), index); 
    8181        spin_status.fetch_and_add(1); 
    8282    } 
     
    142142#endif 
    143143 
    144     for (int i = 0; i < 50; i++) { 
     144    for (int i = 0; i < 5; i++) { 
    145145        n_times(); 
    146         //puts("---"); 
     146        puts("---"); 
    147147    } 
    148148} 
  • lang/objective-cplusplus/i3/trunk/src/os-windows/Pty.cpp

    r34947 r34952  
    4141 
    4242Pty::~Pty() { 
    43     interrupt(); 
     43    //interrupt(); 
    4444    write("exit\n"); 
    4545} 
  • lang/objective-cplusplus/i3/trunk/windows/mil_test.vcproj

    r34940 r34952  
    919919                        </File> 
    920920                        <File 
    921                                 RelativePath="..\src\mil\src\Test1.cpp" 
    922                                 > 
    923                         </File> 
    924                         <File 
    925                                 RelativePath="..\src\mil\src\Test10.cpp" 
    926                                 > 
    927                         </File> 
    928                         <File 
    929921                                RelativePath="..\src\mil\src\Test11.cpp" 
    930                                 > 
    931                         </File> 
    932                         <File 
    933                                 RelativePath="..\src\mil\src\Test12.cpp" 
    934                                 > 
    935                         </File> 
    936                         <File 
    937                                 RelativePath="..\src\mil\src\Test2.cpp" 
    938                                 > 
    939                         </File> 
    940                         <File 
    941                                 RelativePath="..\src\mil\src\Test3.cpp" 
    942                                 > 
    943                         </File> 
    944                         <File 
    945                                 RelativePath="..\src\mil\src\Test4.cpp" 
    946                                 > 
    947                         </File> 
    948                         <File 
    949                                 RelativePath="..\src\mil\src\Test5.cpp" 
    950                                 > 
    951                         </File> 
    952                         <File 
    953                                 RelativePath="..\src\mil\src\Test6.cpp" 
    954                                 > 
    955                         </File> 
    956                         <File 
    957                                 RelativePath="..\src\mil\src\Test7.cpp" 
    958                                 > 
    959                         </File> 
    960                         <File 
    961                                 RelativePath="..\src\mil\src\Test8.cpp" 
    962                                 > 
    963                         </File> 
    964                         <File 
    965                                 RelativePath="..\src\mil\src\Test9.cpp" 
    966922                                > 
    967923                        </File> 
     
    978934                                </FileConfiguration> 
    979935                        </File> 
    980                         <File 
    981                                 RelativePath="..\src\mil\src\windows\WindowProcedureTest.cpp" 
    982                                 > 
    983                         </File> 
    984936                </Filter> 
    985937                <Filter 
     
    997949                        </File> 
    998950                        <File 
     951                                RelativePath="..\src\mil\include\mil\os-windows\Debug.h" 
     952                                > 
     953                        </File> 
     954                        <File 
    999955                                RelativePath="..\src\mil\include\mil\Debug.h" 
    1000956                                > 
    1001957                        </File> 
    1002958                        <File 
    1003                                 RelativePath="..\src\mil\include\mil\os-windows\Debug.h" 
    1004                                 > 
    1005                         </File> 
    1006                         <File 
    1007959                                RelativePath="..\src\mil\include\mil\gui-windows\DummyMessageHandler-inl.h" 
    1008960                                > 
     
    1017969                        </File> 
    1018970                        <File 
     971                                RelativePath="..\src\mil\include\mil\gui-windows\GuiModule.h" 
     972                                > 
     973                        </File> 
     974                        <File 
    1019975                                RelativePath="..\src\mil\include\mil\GuiModule.h" 
    1020976                                > 
    1021977                        </File> 
    1022978                        <File 
    1023                                 RelativePath="..\src\mil\include\mil\gui-windows\GuiModule.h" 
    1024                                 > 
    1025                         </File> 
    1026                         <File 
    1027979                                RelativePath="..\src\mil\include\mil\Memory.h" 
    1028980                                > 
     
    10531005                        </File> 
    10541006                        <File 
     1007                                RelativePath="..\src\mil\include\mil\gui-windows\PrecompiledHeaders.h" 
     1008                                > 
     1009                        </File> 
     1010                        <File 
     1011                                RelativePath="..\src\mil\include\mil\os-windows\PrecompiledHeaders.h" 
     1012                                > 
     1013                        </File> 
     1014                        <File 
    10551015                                RelativePath="..\src\mil\include\mil\PrecompiledHeaders.h" 
    10561016                                > 
    10571017                        </File> 
    10581018                        <File 
    1059                                 RelativePath="..\src\mil\include\mil\gui-windows\PrecompiledHeaders.h" 
    1060                                 > 
    1061                         </File> 
    1062                         <File 
    1063                                 RelativePath="..\src\mil\include\mil\os-windows\PrecompiledHeaders.h" 
    1064                                 > 
    1065                         </File> 
    1066                         <File 
    10671019                                RelativePath="..\src\mil\include\quicktest\quicktest.h" 
    10681020                                > 
     
    10811033                        </File> 
    10821034                        <File 
     1035                                RelativePath="..\src\mil\include\mil\Thread.h" 
     1036                                > 
     1037                        </File> 
     1038                        <File 
    10831039                                RelativePath="..\src\mil\include\mil\os-windows\Thread.h" 
    1084                                 > 
    1085                         </File> 
    1086                         <File 
    1087                                 RelativePath="..\src\mil\include\mil\Thread.h" 
    10881040                                > 
    10891041                        </File>