[英]What are XCode 8 Environment Variables to run Intel Threading Building Blocks
I installed the Intel Threading Building Blocks.我安装了英特尔线程构建模块。 I am unable to set the environment variables for XCode (lib and include path).
我无法为 XCode 设置环境变量(lib 和包含路径)。
To start with I want to write a simple parallel_for program, I am not able to add even the namespace tbb
in my program.首先,我想编写一个简单的 parallel_for 程序,我什至无法在我的程序中添加命名空间
tbb
。
Can anyone please help?有人可以帮忙吗?
Thats pretty straightforward: best way to install it:这很简单:安装它的最佳方法:
brew install tbb
Requires Homebrew , which is highly recommended for any Mac user wanting to use various open source tools.需要Homebrew ,强烈推荐给任何想要使用各种开源工具的 Mac 用户。
After that do brew info tbb
to see the installation directory, in my case之后执行
brew info tbb
以查看安装目录,在我的情况下
/usr/local/Cellar/tbb/2017_U7
wich results in结果是
/usr/local/Cellar/tbb/2017_U7/include/
/usr/local/Cellar/tbb/2017_U7/lib/
for the respective project settings, Header Search Paths
and Library Search Paths
.对于各自的项目设置,
Header Search Paths
和Library Search Paths
。
In Other Linker Flags
enter -ltbb
and there you are.在
Other Linker Flags
中输入-ltbb
就可以了。
I´ve verified this example with the aforementioned settings in Xcode 8.3我已经用 Xcode 8.3 中的上述设置验证了这个例子
#include "tbb/parallel_for.h"
#include "tbb/task_scheduler_init.h"
#include <iostream>
#include <vector>
struct mytask {
mytask(size_t n)
:_n(n)
{}
void operator()() {
for (int i=0;i<1000000;++i) {} // Deliberately run slow
std::cerr << "[" << _n << "]";
}
size_t _n;
};
int main(int,char**) {
//tbb::task_scheduler_init init; // Automatic number of threads
tbb::task_scheduler_init init(tbb::task_scheduler_init::default_num_threads()); // Explicit number of threads
std::vector<mytask> tasks;
for (int i=0;i<1000;++i)
tasks.push_back(mytask(i));
tbb::parallel_for(
tbb::blocked_range<size_t>(0,tasks.size()),
[&tasks](const tbb::blocked_range<size_t>& r) {
for (size_t i=r.begin();i<r.end();++i) tasks[i]();
}
);
std::cerr << std::endl;
return 0;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.