Changeset 54eb1bb3
- Timestamp:
- Dec 15, 2020, 10:26:35 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 13fece5, 42f6e07
- Parents:
- dd92fe9 (diff), 72b1800 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/thierry_delisle_PhD/code/readQ_example/Makefile
rdd92fe9 r54eb1bb3 1 all: gui-proto 1 all: gui-proto-pthread gui-proto-fibre gui-proto-cforall 2 3 PRECIOUS: thrdlib/libthrd-pthread.so thrdlib/libthrd-fibre.so thrdlib/libthrd-cforall.so 2 4 3 5 CXXFLAGS = -fpic -g -O0 -I. 4 6 5 gui-proto: proto-gui/main.o thrdlib/thread.o 6 $(CXX) -pthread -ldl -o ${@} ${^} -ftls-model=initial-exec 7 thrdlib/libthrd-%.so: 8 +${MAKE} -C thrdlib libthrd-$*.so 9 10 gui-proto-%: proto-gui/main.o thrdlib/libthrd-%.so Makefile 11 $(CXX) -Lthrdlib -Wl,--rpath,thrdlib -pthread -o $@ $< -lthrd-$* 12 13 CFAINC=${HOME}/local/include/cfa-dev 14 CFALIB=${HOME}/local/lib/cfa-dev/x64-debug 15 CFAFLAGS=-z execstack -ftls-model=initial-exec -L${CFALIB} -Wl,-rpath,${CFALIB} 16 17 gui-proto-cforall: proto-gui/main.o thrdlib/libthrd-cforall.so Makefile 18 $(CXX) -Lthrdlib -Wl,--rpath,thrdlib ${CFAFLAGS} -pthread -o $@ $< -lthrd-cforall -Wl,--push-state,--no-as-needed -lcfathread -lcfa -ldl -lm -Wl,--pop-state -
doc/theses/thierry_delisle_PhD/code/readQ_example/proto-gui/main.cpp
rdd92fe9 r54eb1bb3 11 11 #include <getopt.h> 12 12 using thrdlib::thread_t; 13 14 15 extern __attribute__((aligned(128))) thread_local struct {16 void * volatile this_thread;17 void * volatile this_processor;18 void * volatile this_stats;19 20 struct {21 volatile unsigned short disable_count;22 volatile bool enabled;23 volatile bool in_progress;24 } preemption_state;25 26 #if defined(__SIZEOF_INT128__)27 __uint128_t rand_seed;28 #else29 uint64_t rand_seed;30 #endif31 struct {32 uint64_t fwd_seed;33 uint64_t bck_seed;34 } ready_rng;35 } kernelTLS __attribute__ ((tls_model ( "initial-exec" )));36 13 37 14 //-------------------- … … 148 125 } 149 126 127 typedef uint64_t __wyhash64_state_t; 128 static inline uint64_t __wyhash64( __wyhash64_state_t & state ) { 129 state += 0x60bee2bee120fc15; 130 __uint128_t tmp; 131 tmp = (__uint128_t) state * 0xa3b195354a39b70d; 132 uint64_t m1 = (tmp >> 64) ^ tmp; 133 tmp = (__uint128_t)m1 * 0x1b03738712fad5c9; 134 uint64_t m2 = (tmp >> 64) ^ tmp; 135 return m2; 136 } 137 150 138 void Simulator( thread_t self ) { 151 139 for(unsigned i = 0; i < nproduce; i++) { … … 156 144 } 157 145 146 __wyhash64_state_t state = 0; 147 158 148 // Write the frame information 159 149 frame.number = i; 160 150 for( unsigned x = 0; x < fsize; x++ ) { 161 frame.data[x] = i;151 frame.data[x] = __wyhash64(state); 162 152 } 163 153 std::cout << "Simulated " << i << std::endl; … … 187 177 188 178 std::cout << "Rendered " << i << std::endl; 189 assert(total == i * fsize);179 // assert(total == i * fsize); 190 180 191 181 // Release … … 201 191 int main(int argc, char * argv[]) { 202 192 nframes = 3; 203 fsize = 1000;193 fsize = 3840 * 2160 * 4 * 4; 204 194 nproduce = 60; 205 206 const char * framework;207 195 208 196 for(;;) { … … 222 210 // Exit Case 223 211 case -1: 224 /* paranoid */ assert(optind <= argc);225 if( optind == argc ) {226 std::cerr << "Must specify a framework" << std::endl;227 goto usage;228 229 }230 framework = argv[optind];231 212 goto run; 232 213 case 'b': … … 261 242 std::cerr << opt << std::endl; 262 243 usage: 263 std::cerr << "Usage: " << argv[0] << " [options] framework" << std::endl;244 std::cerr << "Usage: " << argv[0] << " [options]" << std::endl; 264 245 std::cerr << std::endl; 265 246 std::cerr << " -b, --buff=COUNT Number of frames to buffer" << std::endl; … … 270 251 } 271 252 run: 272 assert( framework );273 274 253 frames.reset(new Frame[nframes]); 275 254 for(unsigned i = 0; i < nframes; i++) { … … 280 259 std::cout << "(Buffering " << nframes << ")" << std::endl; 281 260 282 thrdlib::init( framework,2 );261 thrdlib::init( 2 ); 283 262 284 263 thread_t stats = thrdlib::create( Stats ); -
doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/Makefile
rdd92fe9 r54eb1bb3 1 all: fibre.so pthread.so cforall.so1 all: fibre.so libthrd-pthread.so.so cforall.so 2 2 3 3 clean: 4 rm -rf fibre.so pthread.so4 rm -rf fibre.so libthrd-pthread.so.so cforall.so 5 5 6 6 CXXFLAGS=-Wall -Wextra -O3 -g -fpic -std=c++17 -pthread -ftls-model=initial-exec 7 7 8 pthread.so: pthread.cpp Makefile9 $(CXX) $(CXXFLAGS) -shared -o $ {@} ${<}8 libthrd-pthread.so: thread.cpp thread.hpp Makefile 9 $(CXX) $(CXXFLAGS) -shared -o $@ $< -DWITH_PTHREADS 10 10 11 fibre.so: fibre.cpp Makefile12 $(CXX) $(CXXFLAGS) -shared -o $ {@} ${<}-lfibre11 libthrd-fibre.so: thread.cpp thread.hpp Makefile 12 $(CXX) $(CXXFLAGS) -shared -o $@ $< -DWITH_LIBFIBRE -lfibre 13 13 14 14 CFAINC=${HOME}/local/include/cfa-dev … … 16 16 CFAFLAGS=-z execstack -I${CFAINC} -I${CFAINC}/concurrency -L${CFALIB} -Wl,-rpath,${CFALIB} 17 17 18 cforall.so: cforall.cpp Makefile19 $(CXX) $(CXXFLAGS) $(CFAFLAGS) -shared -o $ {@} ${<} -lcfathread -lcfa -ldl -lm18 libthrd-cforall.so: thread.cpp thread.hpp Makefile 19 $(CXX) $(CXXFLAGS) $(CFAFLAGS) -shared -o $@ $< -DWITH_CFORALL -Wl,--push-state,--no-as-needed -lcfathread -lcfa -ldl -lm -Wl,--pop-state -
doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/pthread.hpp
rdd92fe9 r54eb1bb3 1 #pragma once 2 1 3 #include <pthread.h> 2 4 #include <errno.h> … … 97 99 // Basic kernel features 98 100 void thrdlib_init( int ) {} 101 void thrdlib_clean( void ) {} 99 102 } -
doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/thread.cpp
rdd92fe9 r54eb1bb3 1 #include "thread.hpp" 1 #if !defined(WITH_PTHREADS) && !defined(WITH_LIBFIBRE) && !defined(WITH_CFORALL) 2 #error must define WITH_PTHREADS, WITH_LIBFIBRE or WITH_CFORALL 3 #endif 2 4 3 #i nclude <cstdarg> // va_start, va_end4 #include <cstdio>5 # include <cstring> // strlen6 extern "C" { 7 #include <unistd.h> // _exit, getpid 8 #include <signal.h> 9 #include <dlfcn.h> // dlopen, dlsym 10 #include <execinfo.h> // backtrace, messages 11 } 5 #ifdef WITH_PTHREADS 6 #include "pthread.hpp" 7 #endif 8 #ifdef WITH_LIBFIBRE 9 #include "fibre.hpp" 10 #endif 11 #ifdef WITH_CFORALL 12 #include "cforall.hpp" 13 #endif 12 14 13 #include <iostream> 14 #include <string> 15 namespace thrdlib { 16 //-------------------- 17 // Basic thread support 18 void * create( void (*main)( void * ) ) { return (thread_t)thrdlib_create( (void (*)( thread_t )) main ); } 19 void join ( void * handle ) { thrdlib_join ((thread_t)handle); } 20 void park ( void * handle ) { thrdlib_park ((thread_t)handle); } 21 void unpark( void * handle ) { thrdlib_unpark((thread_t)handle); } 22 void yield( void ) { thrdlib_yield(); } 15 23 16 using thrdlib::thread_t; 17 18 thread_t (*thrdlib::create)( void (*main)( thread_t ) ) = nullptr; 19 void (*thrdlib::join)( thread_t handle ) = nullptr; 20 void (*thrdlib::park)( thread_t handle ) = nullptr; 21 void (*thrdlib::unpark)( thread_t handle ) = nullptr; 22 void (*thrdlib::yield)( void ) = nullptr; 23 void (*lib_clean)(void) = nullptr; 24 25 typedef void (*fptr_t)(); 26 static fptr_t open_symbol( void * library, const char * symbol, bool required ) { 27 void * ptr = dlsym( library, symbol ); 28 29 const char * error = dlerror(); 30 if ( required && error ) { 31 std::cerr << "Fetching symbol '" << symbol << "' failed with error '" << error << "'\n"; 32 std::abort(); 33 } 34 35 return (fptr_t)ptr; 36 } 37 38 //-------------------- 39 // Basic kernel features 40 void thrdlib::init( const char * name, int procs ) { 41 std::string file = __FILE__; 42 std::size_t found = file.find_last_of("/"); 43 std::string libname = file.substr(0,found+1) + name + ".so"; 44 45 std::cout << "Use framework " << name << "(" << libname << ")\n"; 46 47 void * library = dlopen( libname.c_str(), RTLD_NOW ); 48 if ( const char * error = dlerror() ) { 49 std::cerr << "Could not open library '" << libname << "' from name '" << name <<"'\n"; 50 std::cerr << "Error was : '" << error << "'\n"; 51 std::abort(); 52 } 53 54 void (*lib_init)( int ) = (void (*)( int ))open_symbol( library, "thrdlib_init", false ); 55 lib_clean = open_symbol( library, "thrdlib_clean" , false ); 56 57 thrdlib::create = (typeof(thrdlib::create))open_symbol( library, "thrdlib_create", true ); 58 thrdlib::join = (typeof(thrdlib::join ))open_symbol( library, "thrdlib_join" , true ); 59 thrdlib::park = (typeof(thrdlib::park ))open_symbol( library, "thrdlib_park" , true ); 60 thrdlib::unpark = (typeof(thrdlib::unpark))open_symbol( library, "thrdlib_unpark", true ); 61 thrdlib::yield = (typeof(thrdlib::yield ))open_symbol( library, "thrdlib_yield" , true ); 62 63 lib_init( procs ); 64 } 65 66 void thrdlib::clean( void ) { 67 if(lib_clean) lib_clean(); 68 } 24 //-------------------- 25 // Basic kernel features 26 void init( int procs ) { thrdlib_init(procs); } 27 void clean( void ) { thrdlib_clean(); } 28 }; -
doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/thread.hpp
rdd92fe9 r54eb1bb3 6 6 //-------------------- 7 7 // Basic thread support 8 extern thread_t (*create)( void (*main)( thread_t ) );9 extern void (*join)( thread_t handle );10 extern void (*park)( thread_t handle );11 extern void (*unpark)( thread_t handle );12 extern void (*yield)( void ) ;8 extern thread_t create( void (*main)( thread_t ) ); 9 extern void join( thread_t handle ); 10 extern void park( thread_t handle ); 11 extern void unpark( thread_t handle ); 12 extern void yield( void ) ; 13 13 14 14 //-------------------- 15 15 // Basic kernel features 16 extern void init( const char * name,int procs );16 extern void init( int procs ); 17 17 extern void clean( void ); 18 18 };
Note: See TracChangeset
for help on using the changeset viewer.