Giter VIP home page Giter VIP logo

Comments (2)

jamesaross avatar jamesaross commented on May 18, 2024

I pushed a number of bug fixes today. One or two of them are probably related to your problem. Is this what you were trying to accomplish (try this code)?

#include <host_stdio.h>
#include <shmem.h>

int main(void)
{
	int i, j;
	shmem_init(); 
	int my_pe = shmem_my_pe(); 
	int n_pes = shmem_n_pes(); 

	// vector for broadcast. This is one SHMEM way to put memory at address 0x5000
	int* rk = (int*) shmem_align(0x5000, n_pes*sizeof(int));

	// init vector value for every core
	for (i = 0; i < n_pes; i++) {
		rk[i] = (my_pe == i) ? i : 88;
	}

	shmem_barrier_all();

	// broadcast use shmem_put32() $# can't get crrect answer for all core's rk array
	for (j = 0; j < n_pes; j++) {
		if (my_pe == j) {
			for (i = 0; i < n_pes; i++) {
				if (i != j) shmem_put32(&rk[j], &rk[j], 1, i);	
			}
		}
	}

	phost_printf("%2d: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", my_pe,
		rk[0],rk[1],rk[2],rk[3],rk[4],rk[5],rk[6],rk[7],
		rk[8],rk[9],rk[10],rk[11],rk[12],rk[13],rk[14],rk[15]);

	shmem_barrier_all();

	shmem_finalize();
}

Running this with coprsh -np 16 yields:

 0: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
 1: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
 2: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
 3: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
 4: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
 5: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
 6: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
 7: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
 8: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
 9: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
10: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
11: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
12: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
13: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
14: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
15: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

You should consider using shmem_broadcast32. There is an example in the test code directory.

Good luck~

from openshmem-epiphany.

momokomir avatar momokomir commented on May 18, 2024

It worked! Thank you for your reply!

from openshmem-epiphany.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.