Commit ebcea518 authored by Nicolas Denoyelle's avatar Nicolas Denoyelle

few fixes

parent c907acf1
Pipeline #7373 failed with stages
in 7 minutes and 27 seconds
......@@ -264,12 +264,11 @@ int aml_replicaset_sync(struct aml_replicaset *replicaset,
* Get a copy of data held in replicaset in an area of a specific index.
* @param replicaset[in]: The replicaset holding data copies.
* @param i[in]: The index of replica to retrieve.
* @param data[out]: A pointer where to store the queried replica data pointer.
* @return A negative AML error code.
* @return A pointer to the replica.
* @return NULL on error with aml_errno set to the specific error.
**/
int aml_replicaset_get(struct aml_replicaset *replicaset,
const unsigned int i,
void **data);
void* aml_replicaset_get(struct aml_replicaset *replicaset,
const unsigned int i);
////////////////////////////////////////////////////////////////////////////////
......
......@@ -164,6 +164,18 @@ void aml_replicaset_hwloc_destroy(struct aml_replicaset *replicaset);
**/
void *aml_replicaset_hwloc_get(struct aml_replicaset *replicaset);
/**
* Get good replica index in replicaset according to calling thread binding.
* @param replicaset[in]: The replicaset from which to query a replica.
* @return The replica index on success.
* @return On failure:
* -AML_ENOMEM if there was not enough memory to satisfy this call.
* -AML_FAILURE if it was not possible to get thread binding.
* -AML_EDOM if thread binding is larger than replicaset initiators.
* -AML_SUCCESS.
**/
int aml_replicaset_hwloc_get_index(struct aml_replicaset *replicaset);
/**
* Look for the calling thread binding on topology cpuset then
* select the area which is the closest in term of topology distance
......
......@@ -125,15 +125,20 @@ void aml_area_hwloc_destroy(struct aml_area *area)
void *aml_area_hwloc_mmap(const struct aml_area_data *data,
void *ptr, size_t size)
{
hwloc_const_bitmap_t nodeset;
struct aml_area_hwloc_data *hwloc_data =
(struct aml_area_hwloc_data *)data;
if (hwloc_data->parent != NULL)
return aml_area_hwloc_mmap_mbind(data, ptr, size);
nodeset = hwloc_data->nodeset;
if(nodeset == NULL)
nodeset = hwloc_topology_get_allowed_nodeset(aml_topology);
void *p = hwloc_alloc_membind(aml_topology,
size,
hwloc_data->nodeset,
nodeset,
hwloc_data->policy,
HWLOC_BINDING_FLAGS);
......
......@@ -291,7 +291,6 @@ aml_replicaset_hwloc_data_create(const hwloc_obj_type_t initiator_type,
unsigned int *id;
unsigned int *nid;
size_t nn;
hwloc_membind_policy_t policy;
nid = malloc(d->n_initiator * sizeof(*nid));
if (nid == NULL) {
......@@ -309,12 +308,8 @@ aml_replicaset_hwloc_data_create(const hwloc_obj_type_t initiator_type,
for (i = 0; i < d->n_area; i++) {
target = hwloc_get_obj_by_type(aml_topology, target_type,
nid[i]);
if (hwloc_bitmap_weight(target->nodeset) > 1)
policy = HWLOC_MEMBIND_BIND;
else
policy = HWLOC_MEMBIND_INTERLEAVE;
err = aml_area_hwloc_create(d->area+i, NULL, target->nodeset,
policy);
HWLOC_MEMBIND_BIND);
if (err != AML_SUCCESS) {
d->n_area = i;
aml_errno = err;
......@@ -421,7 +416,13 @@ int aml_replicaset_hwloc_get_index(struct aml_replicaset *replicaset)
err = -AML_EDOM;
goto err_with_cpuset;
}
#ifdef DEBUG
hwloc_obj_t target = d->target[initiator->logical_index];
fprintf(stderr,
"aml_replicaset_hwloc: access from %s:%d to replica on %s:%d\n",
hwloc_obj_type_string(initiator->type), initiator->logical_index,
hwloc_obj_type_string(target->type), target->logical_index);
#endif
err = initiator->logical_index;
err_with_cpuset:
......
......@@ -128,15 +128,13 @@ int aml_replicaset_sync(struct aml_replicaset *replicaset,
replicaset->replica[id], replicaset->size);
}
int aml_replicaset_get(struct aml_replicaset *replicaset,
const unsigned int i,
void **data)
void* aml_replicaset_get(struct aml_replicaset *replicaset,
const unsigned int i)
{
if (replicaset == NULL ||
replicaset->n <= i)
return -AML_EINVAL;
if (data == NULL)
return AML_SUCCESS;
*data = replicaset->replica[i];
return AML_SUCCESS;
replicaset->n <= i){
aml_errno = AML_EINVAL;
return NULL;
}
return replicaset->replica[i];
}
......@@ -32,7 +32,8 @@ void check_replicaset(const unsigned int n,
assert(err == AML_SUCCESS);
for(i = 0; i<n; i++){
assert(aml_replicaset_get(replicaset, i, &replica) == AML_SUCCESS);
replica = aml_replicaset_get(replicaset, i);
assert(replica != NULL);
assert(! memcmp(data, replica, size));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment