diff --git a/_.cpp b/_.cpp index d089037..1df4b06 100644 --- a/_.cpp +++ b/_.cpp @@ -1,18 +1,18 @@ /* Check cf5-opt.vim defs. -VIM: let g:lcppflags="-std=c++11 -O2" -VIM: let g:cppflags=g:boost.g:tbb.g:tbbmalloc.g:tbbmproxy -VIM: let g:ldlibpath=g:boostld.g:tbbld -VIM: let g:cf5output=0 +VIM: let g:lcppflags="-std=c++11 -O2 -pthread" +VIM: let g:wcppflags="/O2 /EHsc /DWIN32" +VIM: let g:cppflags=g:Iboost.g:Itbb +VIM: let g:ldflags=g:Lboost.g:Ltbb.g:tbbmalloc.g:tbbmproxy +VIM: let g:ldlibpath=g:Bboost.g:Btbb +VIM: let g:argv="" +VIM-: let g:cf5output=0 */ #include #include - - int main ( void ) {try{ - return 0; } catch ( const std::exception& e ) diff --git a/cf5-opt.vim b/cf5-opt.vim index 53bebb8..0c9d02c 100644 --- a/cf5-opt.vim +++ b/cf5-opt.vim @@ -6,26 +6,55 @@ function! s:SetUpLibrariesLinux() " " BOOST " - let g:boostdir=g:srcdir . "/boost_1_53_0" + let g:boostdir=g:srcdir."/boost_1_53_0" let g:boostinc=g:boostdir - let g:boostlib=g:boostdir . "/lib-amd64/lib" - let g:boostld=":".g:boostlib - let g:boost=" -I".g:boostinc." -L".g:boostlib" + let g:boostlib=g:boostdir."/lib-amd64/lib" + let g:boostbin=g:boostlib + let g:Bboost=g:boostbin.":" + let g:Iboost=" -I".g:boostinc + let g:Lboost=" -L".g:boostlib " " Intel TBB " - let g:tbbdir=g:srcdir . "/tbb41_20130116oss" - let g:tbbinc=g:tbbdir . "/include" - let g:tbblib=g:tbbdir . "/lib/intel64/cc4.1.0_libc2.4_kernel2.6.16.21" - let g:tbbld=":".g:tbblib - let g:tbb=" -I".g:tbbinc." -L".g:tbblib." -ltbb" + let g:tbbdir=g:srcdir."/tbb41_20130116oss" + let g:tbbinc=g:tbbdir."/include" + let g:tbblib=g:tbbdir."/lib/intel64/cc4.1.0_libc2.4_kernel2.6.16.21" + let g:tbbbin=g:tbblib + let g:Btbb=g:tbbbin.":" + let g:Itbb=" -I".g:tbbinc + let g:Ltbb=" -L".g:tbblib." -ltbb" let g:tbbmalloc=" -ltbbmalloc" let g:tbbmproxy=" -ltbbmalloc_proxy" endfunction function! s:SetUpLibrariesWindows() - call s:SetUpLibrariesLinux() + " + " the root of all 3pty libraries + " + let g:srcdir=$HOME . "\\src" + " + " BOOST + " + let g:boostdir=g:srcdir."\\boost_1_53_0" + let g:boostinc=g:boostdir + let g:boostlib=g:boostdir."\\stage\\win64_vc12\\lib" + let g:boostbin=g:boostlib + let g:Bboost=g:boostbin.";" + let g:Iboost=" /I\"".g:boostinc."\"" + let g:Lboost=" /LIBPATH:\"".g:boostlib."\"" + " + " Intel TBB + " + let g:tbbdir=g:srcdir."\\tbb41_20121003oss" + let g:tbbinc=g:tbbdir."\\include" + let g:tbblib=g:tbbdir."\\lib\\intel64\\vc11" + let g:tbbbin=g:tbbdir."\\bin\\intel64\\vc11" + let g:Btbb=g:tbbbin.";" + let g:Itbb=" /I\"".g:tbbinc."\"" + let g:Ltbb=" /LIBPATH:\"".g:tbblib."\" tbb.lib" + let g:tbbmalloc=" tbbmalloc.lib" + let g:tbbmproxy=" tbbmalloc_proxy.lib" endfunction function! SetUpLibraries() diff --git a/tbb_task_scheduler_init.cpp b/tbb_task_scheduler_init.cpp index c236f39..2c44bd9 100644 --- a/tbb_task_scheduler_init.cpp +++ b/tbb_task_scheduler_init.cpp @@ -1,7 +1,8 @@ /* Check cf5-opt.vim defs. -VIM: let g:lcppflags="-std=c++11 -O2" -VIM: let g:cppflags=g:tbb." -ltbbmalloc -ltbbmalloc_proxy" -VIM: let g:ldlibpath=g:tbbld +VIM: let g:lcppflags="-std=c++11 -O2 -pthread" +VIM: let g:cppflags=g:Iboost.g:Itbb +VIM: let g:ldflags=g:Lboost.g:Ltbb.g:tbbmalloc +VIM: let g:ldlibpath=g:Bboost.g:Btbb */ #include #include @@ -10,11 +11,20 @@ VIM: let g:ldlibpath=g:tbbld #include #include +/* + * Conclusion: + * The first task_sheduler_init is configuring number of threads in + * the thread pool. If the task scheduler initialised implicitly then + * the number of threads is the number of cores. To ensure uncomment + * the commented line below. + */ + int main ( void ) {try{ - std::vector v(1024*1024*1024); - tbb::task_scheduler_init init3(20); + std::vector v(1024*1024); + //tbb::enumerable_thread_specific count; + tbb::task_scheduler_init init3(5); tbb::task_scheduler_init init(10); tbb::task_scheduler_init init2(1); tbb::enumerable_thread_specific count; diff --git a/test_copy_assignement_override.cpp b/test_copy_assignement_override.cpp new file mode 100644 index 0000000..8792aa7 --- /dev/null +++ b/test_copy_assignement_override.cpp @@ -0,0 +1,84 @@ +/* Check cf5-opt.vim defs. +VIM: let g:lcppflags="-std=c++11 -O2 -pthread" +VIM-: let g:cppflags=g:Iboost.g:Itbb +VIM-: let g:ldflags=g:Lboost.g:Ltbb.g:tbbmalloc.g:tbbmproxy +VIM-: let g:ldlibpath=g:boostld.g:tbbld +VIM-: let g:cf5output=0 +*/ + +/* + * Conclusion: + * Per C++ standard since Son doesn't have explicitely defined copy + * assignement operator the an implicite one is generated which call + * Base::operatro = () as a result overriden operator in the Son is not + * called. + */ + +#include +#include + +class Base +{ +public: + int b; + +virtual Base &operator=(const Base & o) +{ std::cout << "Base" << std::endl; b=o.b; return *this; }; +}; + +class Derived : public Base +{ +public: + int d; + +virtual Base &operator=(const Base &) +{ std::cout << "Derived 1" << std::endl; return *this;}; + +virtual Derived &operator=(const Derived &) +{ std::cout << "Derived 2" << std::endl; return *this;}; +}; + +class Son : public Base +{ +public: + int d; + +virtual Base &operator=(const Base &) +{ std::cout << "Son" << std::endl; return *this;}; + +}; + + +int main ( void ) +{try{ + + Derived d1, d2; + d1.b = 0; + d2.b = 1; + d1.d = 0; + d2.d = 1; + Base * b1 = &d1; + Base * b2 = &d2; + *b1 = *b2; + std::cout << d1.b << d1.d << std::endl; + + d1 = d2; + + Son s1, s2; + s1 = s2; + + return 0; +} +catch ( const std::exception& e ) +{ + std::cerr << std::endl + << "std::exception(\"" << e.what() << "\")." << std::endl; + return 2; +} +catch ( ... ) +{ + std::cerr << std::endl + << "unknown exception." << std::endl; + return 1; +}} +