使用GNU make,是否可以创建一组在使用"--jobs"选项时永远不会同时安排的目标?
为了使这更具体,请考虑表单的makefile
p1: ...deps... # no parallelization conflicts (can run at the same time as p*, e*)
...rules...
p2: ...deps... # no parallelization conflicts (can run at the same time as p*, e*)
...rules...
p3: ...deps... # no parallelization conflicts (can run at the same time as p*, e*)
...rules...
e1: ...deps... # cannot run at same time as any other e*
...rules...
e2: ...deps... # cannot run at same time as any other e*
...rules...
e3: ...deps... …Run Code Online (Sandbox Code Playgroud) 我有一个插件项目,我已经开发了几年,插件与[主应用程序版本,第三方库版本,32位与64位]的多种组合一起工作.是否有一种(干净的)方法来使用autotools来创建构建插件的所有版本的单个makefile.
从浏览autotools文档我可以看出,与我想要的最接近的是拥有项目的N个独立副本,每个副本都有自己的makefile.这对于测试和开发来说似乎有点不理想,因为(a)我需要在所有不同的副本中不断传播代码更改,并且(b)在复制项目时有很多浪费的空间.有没有更好的办法?
编辑:
我已经推出了自己的解决方案一段时间,我有一个花哨的makefile和一些perl脚本来搜索各种第三方库版本等.因此,我对其他非autotools解决方案持开放态度.对于其他构建工具,我希望它们对于最终用户来说非常容易安装.这些工具还需要足够智能,以便在没有大量麻烦的情况下搜索各种第三方库和标题.我主要是在寻找一个Linux解决方案,但也适用于Windows和/或Mac的解决方案.
使用两者来分析一些C++数字运算代码,gprof并kcachegrind为对执行时间贡献最大的函数(取决于输入的50-80%)给出类似的结果,但对于10-30%之间的函数,这些工具都给出不同的结果.这是否意味着其中一个不可靠?你会怎么做?
我试图在 C 中加载一个共享库两次:
lib1 = dlopen("mylib.so", RTLD_LAZY | RTLD_LOCAL | RTLD_DEEPBIND);
lib2 = dlopen("mylib.so", RTLD_LAZY | RTLD_LOCAL | RTLD_DEEPBIND);
Run Code Online (Sandbox Code Playgroud)
我想要的是 lib1 和 lib2 具有单独的地址空间,以便它们可以做不同的事情。目前,我可以实现这一点的唯一方法是复制 mylib 使代码如下所示:
lib1 = dlopen("mylib.so", RTLD_LAZY | RTLD_LOCAL | RTLD_DEEPBIND);
lib2 = dlopen("mylib2.so", RTLD_LAZY | RTLD_LOCAL | RTLD_DEEPBIND);
Run Code Online (Sandbox Code Playgroud)
在有限的范围内,这对我来说很好用。但是,我有一个应用程序,它使用库的次数一般,这使得复制库很麻烦。
每次加载库时,有没有更好的方法来拥有单独的地址空间?
编辑:
我想多次加载库,因为我的应用程序正在处理一种消息队列。消息队列中的项引用共享库(例如 mylib)的名称,并包含一组应由库处理的数据。我想在多线程环境中处理 MQ,在自己的线程中运行对库方法的每次调用。只要 MQ 只包含一次对库的调用,一切都会按预期进行。但是,当我有两个项目使用同一个库时,事情开始变得奇怪。
随着以下琐碎的删除
struct CudaDeleter{ void operator()(void * ptr) { cudaFree( ptr ); } };
Run Code Online (Sandbox Code Playgroud)
在使用nvcc编译的代码中使用删除器时出现以下错误.相同的删除程序与vs2012编译器一起工作正常
warning : "std::unique_ptr<_Ty, _Dx>::unique_ptr(
const std::unique_ptr<_Ty, _Dx>::_Myt &)
[with _Ty=const int, _Dx=cuda::CudaDeleter]"
error : function "cuda::CudaDeleter::operator()"
cannot be called with the given argument list
warning : "std::unique_ptr<_Ty, _Dx>::unique_ptr(
const std::unique_ptr<_Ty, _Dx>::_Myt &)
[with _Ty=float, _Dx=cuda::CudaDeleter]"
Run Code Online (Sandbox Code Playgroud)
@talonmies:智能指针仅使用此功能构建
template <typename T>
std::unique_ptr<T, CudaDeleter> make_unique(size_t size)
{
void * pMemory = nullptr;
check( cudaMalloc(&pMemory, size) );
return std::unique_ptr<T, CudaDeleter>( static_cast<T*>(pMemory) );
}
Run Code Online (Sandbox Code Playgroud) 这段代码来自一本名为cuda的书
#include "../common/book.h"
#define N (33 * 1024)
__global__ void add( int *a, int *b, int *c ) {
int tid = threadIdx.x + blockIdx.x * blockDim.x;
while (tid < N) {
c[tid] = a[tid] + b[tid];
tid += blockDim.x * gridDim.x;
}
}
.
.
.
add<<<128,128>>>( dev_a, dev_b, dev_c );
Run Code Online (Sandbox Code Playgroud)
33*1024 = 33792
128*128 = 16384
33792> 16384
那么,在这种情况下,我是否可以增加每个块的线程数来运行?