[gmx-developers] rvec x[]
David van der Spoel
spoel at xray.bmc.uu.se
Sat Jun 25 10:45:14 CEST 2005
On Fri, 24 Jun 2005, Nathan Moore wrote:
>Hi All,
>
>Where is the "rvex x[]" class defined? I assumed that it was a flat array
>in the replacement for move_x below and got compiler errors:
include/types/simple.h
>
>"mvxvf.c", line 196.14: 1506-068 (W) Operation between types "double*" and
>"double" is not allowed.
>"mvxvf.c", line 196.9: 1506-025 (S) Operand must be a modifiable lvalue.
>
call your routine with x[0] as an argument.
>Also, What does the "where();" fucntion at the bottom of move_f and
>move_x do?
it's for debugging.
>
>My code snippet follows, all suggestions welcome! I suppose that since X
>isn't flat I'll need to pass it with MPI with a type other that
>MPI_DOUBLE?
are you sure you are using double precision alwyas? It's not a good idea
to hardcode that, use MPI_REAL rather.
>
>thanks again for all the help!
>
>NTM
>
> int i;
> int NT_status; /* Did the send work? */
>
> int array_length; /* length of the whole x array */
> array_length = DIM * (nsb->natoms);
>
> int start_element; /* index of where this node's array begins */
> start_element = nsb->index[nsb->nodeid];
>
> /* The number of elements each node sends */
> int *num_sent = (int *) malloc((nsb->nnodes) * sizeof(int));
> for (i = 0; i < (nsb->nnodes); i++) {
> num_sent[i] = nsb->homenr[i];
> }
>
> /* The starting index of each node's block of elements */
> /* note the obvious redundancy that
>start_element==starting_block[nsb->nodeid] */
> int *starting_block = (int *) malloc((nsb->nnodes) * sizeof(int));
> for (i = 0; i < (nsb->nnodes); i++) {
> starting_block[i] = nsb->index[i];
> }
>
> /* The tempporary array where x elements are gathered to */
> double *temp_x = (double *) malloc(array_length * sizeof(double));
make that real 3 times
>
> /* pass the x array around */
> NT_status = MPI_Allgatherv(&x[start_element],
> num_sent[nsb->nodeid],
> MPI_DOUBLE,
> &temp_x[0],
> &num_sent[0],
> &starting_block[0],
> MPI_DOUBLE, MPI_COMM_WORLD);
make that MPI_REAL 2 times
>
> /* update the x array with the gathered temp_x array */
> for (i = 0; i < array_length; i++) {
> x[i] = temp_x[i];
> }
>
> free(num_sent);
> free(starting_block);
> free(temp_x);
try to avoid extra mallocs thay are extremely expensive.
>
>_______________________________________________
>gmx-developers mailing list
>gmx-developers at gromacs.org
>http://www.gromacs.org/mailman/listinfo/gmx-developers
>Please don't post (un)subscribe requests to the list. Use the
>www interface or send it to gmx-developers-request at gromacs.org.
>
--
David.
________________________________________________________________________
David van der Spoel, PhD, Assoc. Prof., Molecular Biophysics group,
Dept. of Cell and Molecular Biology, Uppsala University.
Husargatan 3, Box 596, 75124 Uppsala, Sweden
phone: 46 18 471 4205 fax: 46 18 511 755
spoel at xray.bmc.uu.se spoel at gromacs.org http://xray.bmc.uu.se/~spoel
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
More information about the gromacs.org_gmx-developers
mailing list