資源簡介
TBB,Thread Building Blocks,線程構(gòu)建模塊,是Intel公司開發(fā)的并行編程開發(fā)的工具。
OSCON 上,Intel 宣布,Threading Building Blocks,Intel 眾多軟件開發(fā)工具中的一個(gè),open source了。協(xié)議是 GPLv2。
TBB 獲得過 17 屆 Jolt Productivity Awards,是一套C++模板庫,和直接利用 OSAPI寫程序的 raw thread 比,在并行編程方面提供了適當(dāng)?shù)某橄螅?dāng)然還包括更多其他內(nèi)容,比如 task 概念,常用算法的成熟實(shí)現(xiàn),自動負(fù)載均衡特性還有不綁定 CPU 數(shù)量的靈活的可擴(kuò)展性等等。STL之父,Alexander Stepanov對此評價(jià)不錯,他說“Threading Building Blocks… could become a basis for the concurrency dimension of the C++ standard library”。其他 TBB 的早期用戶,包括Autodesk,Sun,Red Hat, Turbo Linux 等亦然。現(xiàn)在 O’Reilly 已經(jīng)出版了一本 Intel Threading Building Blocks: Outfitting C++ for Multi-core Processor Parallelism。
TBB 可以在Windows,Linux和 OSX 上運(yùn)行,支持 Intel, Microsoft 和GNU工具,這就覆蓋了絕大多數(shù)需求范圍。
代碼片段和文件信息
/*
????Copyright?2005-2014?Intel?Corporation.??All?Rights?Reserved.
????This?file?is?part?of?Threading?Building?Blocks.?Threading?Building?Blocks?is?free?software;
????you?can?redistribute?it?and/or?modify?it?under?the?terms?of?the?GNU?General?Public?License
????version?2??as??published??by??the??Free?Software?Foundation.??Threading?Building?Blocks?is
????distributed?in?the?hope?that?it?will?be?useful?but?WITHOUT?ANY?WARRANTY;?without?even?the
????implied?warranty?of?MERCHANTABILITY?or?FITNESS?FOR?A?PARTICULAR?PURPOSE.
????See??the?GNU?General?Public?License?for?more?details.???You?should?have?received?a?copy?of
????the??GNU?General?Public?License?along?with?Threading?Building?Blocks;?if?not?write?to?the
????Free?Software?Foundation?Inc.??51?Franklin?St??Fifth?Floor??Boston??MA?02110-1301?USA
????As?a?special?exception??you?may?use?this?file??as?part?of?a?free?software?library?without
????restriction.??Specifically??if?other?files?instantiate?templates??or?use?macros?or?inline
????functions?from?this?file?or?you?compile?this?file?and?link?it?with?other?files?to?produce
????an?executable??this?file?does?not?by?itself?cause?the?resulting?executable?to?be?covered
????by?the?GNU?General?Public?License.?This?exception?does?not?however?invalidate?any?other
????reasons?why?the?executable?file?might?be?covered?by?the?GNU?General?Public?License.
*/
#include?“video.h“
#include?
#include?
unsigned?int?*??????????????g_pImg?=?0;
int?????????????????????????g_sizex?g_sizey;
static?video?*g_video?=?0;
static?int?g_fps?=?0;
#if?_WIN32?||?_WIN64
static?DWORD?g_msec?=?0;
#ifdef?_WINDOWS
HINSTANCE?video::win_hInstance?=?0;
int?video::win_iCmdShow?=?0;
void?video::win_set_class(WNDCLASSEX?&wcex)?{?}
void?video::win_load_accelerators(int?idc)??{?}
#endif?//_WINDOWS
#else
#include?
#include?
struct?timeval?g_time;
#endif?//_WIN32||_WIN64
#define?CALC_FPS_ENABLED?((WINAPI_FAMILY?!=?WINAPI_FAMILY_APP)?&&?(!__ANDROID__))
video::video()
????//?OpenGL*?RGBA?byte?order?for?little-endian?CPU
????:?red_mask(0xff)?red_shift(0)?green_mask(0xff00)
??????green_shift(8)?blue_mask(0xff0000)?blue_shift(16)?depth(24)
{
????assert(g_video?==?0);
????g_video?=?this;?title?=?“Video“;?updating?=?calc_fps?=?false;
}
bool?video::init_window(int?x?int?y)
{
????g_sizex?=?x;?g_sizey?=?y;
????g_pImg?=?new?unsigned?int[x*y];
????running?=?true;
????return?false;
}
bool?video::init_console()
{
????running?=?true;
????return?true;
}
void?video::terminate()
{
#if?CALC_FPS_ENABLED
????if(calc_fps)?{
????????double?fps?=?g_fps;
#if?_WIN32?||?_WIN64
????????fps?/=?(GetTickCount()-g_msec)/1000.0;
#else
????????struct?timezone?tz;?struct?timeval?end_time;?gettimeofday(&end_time?&tz);
????????fps?/=?(end_time.tv_sec+1.0*end_time.tv_usec/1000000.0)?-?(g_time.tv_sec+1.0*g_time.tv_usec/1000000.0);
#endif
????????printf(“%s:?%.1f?fps\n“?title?fps);
????}
#endif
????g_video?=?0;?running?=?false;
????if(g_pImg)?{?delete[]?g_pImg;?g_pIm
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-12-12?11:58??tbb43_20141204oss\
?????目錄???????????0??2014-12-12?12:04??tbb43_20141204oss\lib\
?????目錄???????????0??2014-12-12?12:04??tbb43_20141204oss\lib\ia32\
?????目錄???????????0??2014-12-12?11:56??tbb43_20141204oss\lib\ia32\vc12_ui\
?????目錄???????????0??2014-12-12?11:55??tbb43_20141204oss\lib\ia32\vc12_ui\irml\
?????文件????????2956??2014-12-12?11:55??tbb43_20141204oss\lib\ia32\vc12_ui\irml\irml.lib
?????文件????????3058??2014-12-12?11:55??tbb43_20141204oss\lib\ia32\vc12_ui\irml\irml_debug.lib
?????文件????????1924??2014-12-12?11:55??tbb43_20141204oss\lib\ia32\vc12_ui\tbbmalloc_proxy.lib
?????文件???????93358??2014-12-12?11:55??tbb43_20141204oss\lib\ia32\vc12_ui\tbb_debug.lib
?????文件??????183766??2014-12-12?11:55??tbb43_20141204oss\lib\ia32\vc12_ui\tbbproxy.lib
?????文件???????61440??2014-12-12?11:56??tbb43_20141204oss\lib\ia32\vc12_ui\tbbproxy.pdb
?????文件???????61440??2014-12-12?11:56??tbb43_20141204oss\lib\ia32\vc12_ui\tbbproxy_debug.pdb
?????文件???????98032??2014-12-12?11:55??tbb43_20141204oss\lib\ia32\vc12_ui\tbb_preview_debug.lib
?????文件???????91948??2014-12-12?11:55??tbb43_20141204oss\lib\ia32\vc12_ui\tbb.lib
?????文件??????183766??2014-12-12?11:55??tbb43_20141204oss\lib\ia32\vc12_ui\tbbproxy_debug.lib
?????文件???????16776??2014-12-12?11:55??tbb43_20141204oss\lib\ia32\vc12_ui\tbb.def
?????文件???????96510??2014-12-12?11:55??tbb43_20141204oss\lib\ia32\vc12_ui\tbb_preview.lib
?????文件????????9158??2014-12-12?11:55??tbb43_20141204oss\lib\ia32\vc12_ui\tbbmalloc_debug.lib
?????文件????????1871??2014-12-12?11:55??tbb43_20141204oss\lib\ia32\vc12_ui\tbbmalloc.def
?????文件????????8862??2014-12-12?11:55??tbb43_20141204oss\lib\ia32\vc12_ui\tbbmalloc.lib
?????文件????????2002??2014-12-12?11:55??tbb43_20141204oss\lib\ia32\vc12_ui\tbbmalloc_proxy_debug.lib
?????目錄???????????0??2014-12-12?11:56??tbb43_20141204oss\lib\ia32\vc10\
?????目錄???????????0??2014-12-12?11:56??tbb43_20141204oss\lib\ia32\vc10\irml\
?????文件????????2956??2014-12-12?11:56??tbb43_20141204oss\lib\ia32\vc10\irml\irml.lib
?????文件????????3058??2014-12-12?11:56??tbb43_20141204oss\lib\ia32\vc10\irml\irml_debug.lib
?????文件????????1924??2014-12-12?11:56??tbb43_20141204oss\lib\ia32\vc10\tbbmalloc_proxy.lib
?????文件???????93358??2014-12-12?11:56??tbb43_20141204oss\lib\ia32\vc10\tbb_debug.lib
?????文件??????230516??2014-12-12?11:55??tbb43_20141204oss\lib\ia32\vc10\tbbproxy.lib
?????文件???????53248??2014-12-12?11:56??tbb43_20141204oss\lib\ia32\vc10\tbbproxy.pdb
?????文件???????53248??2014-12-12?11:56??tbb43_20141204oss\lib\ia32\vc10\tbbproxy_debug.pdb
?????文件???????98032??2014-12-12?11:55??tbb43_20141204oss\lib\ia32\vc10\tbb_preview_debug.lib
............此處省略1515個(gè)文件信息
評論
共有 條評論