Skip to content

Links array#410

Open
alexei-borissov wants to merge 10 commits into
ludwig-cf:developfrom
alexei-borissov:links_array
Open

Links array#410
alexei-borissov wants to merge 10 commits into
ludwig-cf:developfrom
alexei-borissov:links_array

Conversation

@alexei-borissov

Copy link
Copy Markdown
Collaborator

Use array instead of linked list for storing links.

Comment thread src/colloids.c

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the allocation of rb it should be possible to do something like (schematically):

rb    = (double **) malloc(3);
rb[0] = (double *)  malloc(3*nlinks);
/* ... and initialise pointers ... */
for (int i = 1; i < 3; i++) {
  rb[i] = rb[i-1] + nlinks;
}

which would be dereferenced rb[X][ilink] etc. So two allocations only.

Comment thread src/colloids.c
tdpAssert(tdpMallocManaged((void **) &pc->links->status, pc->links->max_links*sizeof(int), tdpMemAttachGlobal));
tdpAssert(tdpMallocManaged((void **) &pc->links->rb, pc->links->max_links*sizeof(double *), tdpMemAttachGlobal));
for (int i = 0; i < pc->links->max_links; i++) {
tdpAssert(tdpMallocManaged((void **) &pc->links->rb[i], 3*sizeof(double), tdpMemAttachGlobal)); // XXX: change order to reduce number of managed allocations.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See general comment.

Comment thread src/colloids.h

colloid_t * bonded[NBOND_MAX];

colloid_links_array_t * links; /* Arrays of links for this colloid. */ // XXX: Check that this is copied between host and device versions correctly.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check comment.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Device memory test?

Comment thread src/colloid_link.h

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Utility for, e.g,:

/* Copy data from structure to array at index */
void colloid_link_to index(colloid_links_array_t * array, int index, const colloid_link_t * data);

/* Extract boundary vector from internal storage for link index */
void colloid_link_rb(colloid_links_array_t * array, int index, double rb[3]);

/* "Destructor" */

may be useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants