我想在我自己的软件的makefile中包含来自外部库的makefile.最简单的方法是找出Makefile等效的CMake代码include ${dir}/makefile.
但也许我应该给出一点背景.我正在尝试将PETSc(和SLEPc)集成到我的代码中.以下是使用SLEPc的示例中的一些代码(尽管PETSc几乎相同):
hello: hello.o chkopts
-${CLINKER} -o hello hello.o ${SLEPC_LIB}
${RM} hello.o
include ${SLEPC_DIR}/conf/slepc_common
Run Code Online (Sandbox Code Playgroud)
如您所见,它需要包含一个特定的makefile,其中包含一堆其他makefile.这有点奇怪,因为看起来只有一个包含目录会更简单,但显然它比我理解的更多.无论如何,我的第一个解决方案是简单地包含它想要的makefile,看看是否有效.
我有一些可以轻松并行化的工作,并且我想使用 Java 线程在我的四核机器上分配工作。这是一种应用于旅行商问题的遗传算法。听起来不容易并行,但第一个循环很容易并行。我谈论实际演变的第二部分可能会也可能不会,但我想知道我是否因为实现线程的方式而变慢,或者是否因为算法本身而变慢。
另外,如果有人对我应该如何实现我想做的事情有更好的想法,我将非常感激。
在 main() 中,我有这个:
final ArrayBlockingQueue<Runnable> queue = new ArrayBlockingQueue<Runnable>(numThreads*numIter);
ThreadPoolExecutor tpool = new ThreadPoolExecutor(numThreads, numThreads, 10, TimeUnit.SECONDS, queue);
barrier = new CyclicBarrier(numThreads);
k.init(tpool);
Run Code Online (Sandbox Code Playgroud)
我有一个在 init() 内部完成的循环,如下所示:
for (int i = 0; i < numCities; i++) {
x[i] = rand.nextInt(width);
y[i] = rand.nextInt(height);
}
Run Code Online (Sandbox Code Playgroud)
我改成这样:
int errorCities = 0, stepCities = 0;
stepCities = numCities/numThreads;
errorCities = numCities - stepCities*numThreads;
// Split up work, assign to threads
for (int i = 1; i <= numThreads; i++) { …Run Code Online (Sandbox Code Playgroud) java concurrency multithreading java.util.concurrent threadpool