English 中文(简体)
MPI 沥青
原标题:Attribute caching in MPI
  • 时间:2011-10-23 17:20:23
  •  标签:
  • c
  • mpi

我目前正在通过一些基本的公共和政治生活方案实例,来更新我的记忆(将Pacheco的书记作为指南),但我却陷入一个我不理解的问题。 为了证明归属感,我撰写了以下方案:

#include <stdio.h>
#include <mpi.h>

int main(int argc, char *argv[]) {
    int rank, size;
    int key;
    int *value;
    void* extra_arg; /* unused */

    /* Broadcast value for sync */
    int x;

    MPI_Init(&argc,&argv);
    MPI_Comm_rank(MPI_COMM_WORLD,&rank);
    MPI_Comm_size(MPI_COMM_WORLD,&size);
    MPI_Keyval_create(MPI_DUP_FN, MPI_NULL_DELETE_FN,
        &key, extra_arg);

    if (rank==0) {
        *value = 42;
        MPI_Attr_put(MPI_COMM_WORLD, key, value);
        x=17;
        MPI_Bcast(&x,1,MPI_INT,0,MPI_COMM_WORLD);
    } else {
        MPI_Bcast(&x,1,MPI_INT,0,MPI_COMM_WORLD);
        int* newval;
        int flag;
        MPI_Attr_get(MPI_COMM_WORLD,key,&newval,&flag);
        printf("Value = %d 
", *newval);
    }
    MPI_Finalize();
    return 0;
}

(该广播仅能防止MPI_Attr_get在播音之前出现)

This, if I m doing it properly, should result in all processes but rank 0 printing "Value = 42 ". What I get, however, if I do "mpirun -np 2 ./a.out", is

[exp:27936] *** Process received signal ***
[exp:27936] Signal: Segmentation fault (11)
[exp:27936] Signal code: Invalid permissions (2)
[exp:27936] Failing at address: 0xb763aff4
[exp:27936] [ 0] [0xf57fe40c]
[exp:27936] [ 1] ./a.out(main+0x74) [0x80488e8]
[exp:27936] [ 2] /lib/libc.so.6(__libc_start_main+0xdc) [0xb74fbe9c]
[exp:27936] [ 3] ./a.out [0x80487c1]
[exp:27936] *** End of error message ***
--------------------------------------------------------------------------
mpirun noticed that process rank 0 with PID 27936 on node exp exited on signal 11 (Segmentation fault).--------------------------------------------------------------------------

我不理解的是,为什么有人eg! 同样错误的发生是,我宣布“新世纪”为主人或内部的顶端,而且只是在消费物价指数_时。 Attr_get is conducted: commenting this out and practice other with newval isvy.

想法?

最佳回答

指控是因为一件事,而不是一件马普切事件,你需要新瓦尔才能成为一种愤怒,而不是一个点:

#include <stdio.h>
#include <mpi.h>

int main(int argc, char *argv[]) {
    int rank, size;
    int key;
    void* extra_arg; /* unused */

    /* Broadcast value for sync */
    int x;

    MPI_Init(&argc,&argv);
    MPI_Comm_rank(MPI_COMM_WORLD,&rank);
    MPI_Comm_size(MPI_COMM_WORLD,&size);
    MPI_Keyval_create(MPI_DUP_FN, MPI_NULL_DELETE_FN,
        &key, NULL);

    if (rank==0) {
        int value = 42;
        MPI_Attr_put(MPI_COMM_WORLD, key, &value);
        x=17;
        MPI_Bcast(&x,1,MPI_INT,0,MPI_COMM_WORLD);
    } else {
        MPI_Bcast(&x,1,MPI_INT,0,MPI_COMM_WORLD);
        int newval;
        int flag;
        MPI_Attr_get(MPI_COMM_WORLD,key,&newval,&flag);
        if (flag)
            printf("Value = %d 
", newval);
    }
    MPI_Finalize();
    return 0;
}

我认为,正如你所希望的那样,这仍然无所作为;我不敢肯定,这种属性将广播给与共产党有关的所有进程。 (此外,还注意到MPI_Attr_get/put,在MPI2中被折旧,代之以MPI_Comm_get/set_attr())。

问题回答

暂无回答




相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...

热门标签