小编aru*_*zhi的帖子

多核机器上MPI集合操作的实现细节

在MPI中,每个等级都有一个唯一的地址空间,它们之间的通信通过消息传递发生.

我想知道MPI如何在具有共享内存的多核机器上工作.如果排名在两台不具有共享内存的不同机器上,则MPI必须使用消息进行通信.但如果排名在同一台物理机器上(但每个排名仍有不同的地址空间),MPI调用是否会利用共享内存?

例如,假设我正在发出ALLREDUCE呼叫.我有两台机器M1和M2,每台机器有2个核心.等级R1和R2在机器M1的核心1和核心2上,R3和R4在机器M2的核心1和2上.ALLREDUCE将如何发生?是否会传输超过1条消息?理想情况下,我希望R1和R2使用它们可用的共享内存(类似R3和R4)进行减少,然后在M1和M2之间进行消息交换.

有没有关于MPI集体操作实现细节的文档?

parallel-processing fortran mpi fortran90

2
推荐指数
1
解决办法
425
查看次数

unix`bc`实用程序的格式输出

对于bcunix中的大输出实用程序,以这种格式提供输出:

  $ bc bc 1.06.95 Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.     
    2^1000
    10715086071862673209484250490600018105614048117055336074437503883703\ 
    51051124936122493198378815695858127594672917553146825187145285692314\ 
    04359845775746985748039345677748242309854210746050623711418779541821\ 
    53046474983581941267398767559165543946077062914571196477686542167660\    
    429831652624386837205668069376
Run Code Online (Sandbox Code Playgroud)

是否可以添加格式选项,以便只输出一行输出

unix bc

2
推荐指数
1
解决办法
424
查看次数

杀死GDB中的特定线程

我想在gdb中杀死一个特定的线程.这是我将程序附加到gdb的方法.

(gdb) r ./bin/myProg arg1 arg2
Run Code Online (Sandbox Code Playgroud)

我得到当前运行的线程

(gdb) info threads
    3 Thread 0x7ffff61fe700 (LWP 28549)  0x000000323b6db7ad in foo () from /lib64/libc.so.6
  * 2 Thread 0x7ffff6bff700 (LWP 28548)  bar () at ./src/myProg.c:229
    1 Thread 0x7ffff7506740 (LWP 28547)  0x000000323be0822d in pthread_join () from /lib64/libpthread.so.0
Run Code Online (Sandbox Code Playgroud)

这是我试图杀死一个线程(比如线程3)

(gdb)t 3
[Switching to thread 3 (Thread 0x7ffff61fe700 (LWP 28549))]#0  foo () at ./src/myProg.c:288
(gdb)call raise(3,0)
Run Code Online (Sandbox Code Playgroud)

在这里我假设了raiseas 的签名raise(threadId as displayed in the gdb, signo as 0)

但线程并没有被杀死.我应该使用不同的signo还是线程ID错误?

注意:我在SO中阅读了这个问题,但这对我没有帮助

c debugging multithreading gdb

2
推荐指数
1
解决办法
2767
查看次数

按列分区2D数组并使用allgather

我有一个fortran MPI代码,其中在2D数组的每个元素上调用计算密集型函数.我正在尝试将任务分配给队伍.例如,如果有30列和10个等级,那么每个等级得到3列.以下代码执行此拆分并使用allgather收集结果.但是最终数组没有来自所有排名的值.

        program allgather
    include 'mpif.h'
    !create a 2 x 30 myarray
    integer :: x=2,y=30
    integer :: numprocs,myid
    integer :: i,j,k,myelements,mycolumns,jb,je
    integer*4,dimension(:),allocatable :: displacement,recvcnt
    real :: checksum
    real,dimension(:,:),allocatable :: myarr,combinedarr
    call MPI_INIT(IERR)
    call MPI_COMM_SIZE(MPI_COMM_WORLD,NUMPROCS,IERR)
    call MPI_COMM_RANK(MPI_COMM_WORLD,MYID,IERR)
    mycolumns = y/numprocs
    myelements = x * mycolumns
    allocate(displacement(numprocs),recvcnt(numprocs))
    jb = 1 + ( myid * mycolumns ) 
    je = ( myid + 1 ) * mycolumns
    allocate(myarr(x,mycolumns))
    allocate(combinedarr(x,y))
    myarr(:,:) =0
    do j=jb,je
      do i=1,x
       myarr(i,j) = 1
      enddo
    enddo
    !myarr(:,:)=1 
    if(mod(y,numprocs) > 0) …
Run Code Online (Sandbox Code Playgroud)

parallel-processing fortran mpi fortran90

1
推荐指数
1
解决办法
788
查看次数

二进制搜索树中具有最小值的节点

我想找到最有效的方法来检查二进制搜索树中具有最小值的节点.我现在不打算用某种编程语言来做这件事,我只想想最有效的算法.

你怎么看待这件事:

procedure minBST(t)
if (t = NULL) then return; 
if (t -> left = NULL) then return  t -> inf;  
 *// if the left node is null, then in a BST the smallest value will be the root*
if (t -> left != NULL) then .... 
 *// I need to dig more in the left side until I get the last left node*
Run Code Online (Sandbox Code Playgroud)

我的问题是,在得到最后一个左节点之前,我应该如何深入挖掘.我也尝试解释这些步骤.你认为这是最好的方法吗?

c c++ algorithm tree binary-search-tree

1
推荐指数
1
解决办法
6355
查看次数

Fortran可分配的数组生命周期

说我有以下代码:

program test
  call foo
  call foo
contains
  subroutine foo
    integer(8),dimension(:),allocatable:: var1
    allocate(var1(10))
    ...
    return
  end subroutine foo
end
Run Code Online (Sandbox Code Playgroud)

变量var1会被分配两次吗?(我猜是).如果为每个呼叫分配,第一次呼叫期间分配的内存是否会空闲?

fortran memory-management dynamic-memory-allocation fortran90 fortran95

0
推荐指数
1
解决办法
899
查看次数

将内联函数转换为宏

我有一个1行inline函数,它是我的代码中的热点的一部分.我想看看将此更改为宏是否有益.写作功能我不必担心副作用.但是如何在没有副作用的情况下为此编写宏?

#define FLAG1_BIT 4
struct node
{
    unsigned long key;
    struct node* child[K];      //format <address,flag1,flag2,flag3>
};

static inline bool isFlag1Set(struct node* p)
{
    return ((uintptr_t) p & FLAG1_BIT) != 0;
}
Run Code Online (Sandbox Code Playgroud)

c macros inline-functions c-preprocessor

0
推荐指数
1
解决办法
526
查看次数