简体   繁体   中英

Running the program with logical threads

I have a multi-core which hyper-threading is enabled. Each physical core has two logical core. Now can i run my program with 1 core and its logical cores? means our program run with 2 logical core's of this one core but other cores are idle.

Now can i run my program with 1 core and its logical cores?

Yes, but to utilize more cores than 1 you must execute your app in multiple threads. Ie. if you are using pthreads then use pthread_setaffinity_np to specify on which core your thread should execute.

If you want to make your agorithms run in parallel then consider using OpenMP or TBB (Threading Building Blocks). Those libraries allow to quite easily convert sequentially executed application into parallel one. Ie. instead of using for you use parallel_for . Also your code will automatically use all available (or cofigured) number of cores - whether CPU has 2 cores or 16 of them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM