2004-10-25 23:53:44 +04:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2004-11-28 23:09:25 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-10-25 23:53:44 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "orte_config.h"
|
2004-10-25 23:53:44 +04:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "orte/orte_constants.h"
|
2005-07-04 03:31:27 +04:00
|
|
|
#include "opal/util/output.h"
|
2005-07-19 16:25:19 +04:00
|
|
|
#include "orte/class/orte_proc_table.h"
|
2004-10-25 23:53:44 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
2005-03-14 23:57:21 +03:00
|
|
|
* orte_process_name_hash_node_t
|
2004-10-25 23:53:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct ompi_proc_hash_node_t
|
|
|
|
{
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t super;
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_process_name_t hn_key;
|
2004-10-25 23:53:44 +04:00
|
|
|
void *hn_value;
|
|
|
|
};
|
|
|
|
typedef struct ompi_proc_hash_node_t ompi_proc_hash_node_t;
|
|
|
|
|
|
|
|
static OBJ_CLASS_INSTANCE(
|
|
|
|
ompi_proc_hash_node_t,
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t,
|
2004-10-25 23:53:44 +04:00
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
2005-07-19 16:25:19 +04:00
|
|
|
void* orte_hash_table_get_proc(opal_hash_table_t* ht,
|
2005-03-14 23:57:21 +03:00
|
|
|
const orte_process_name_t* proc)
|
2004-10-25 23:53:44 +04:00
|
|
|
{
|
|
|
|
uint32_t key = (proc->cellid << 24) + (proc->jobid << 16) + proc->vpid;
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_t* list = ht->ht_table + (key & ht->ht_mask);
|
2004-10-25 23:53:44 +04:00
|
|
|
ompi_proc_hash_node_t *node;
|
|
|
|
|
|
|
|
#if OMPI_ENABLE_DEBUG
|
|
|
|
if(ht->ht_table_size == 0) {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0, "opal_hash_table_get_proc:"
|
2005-07-03 20:52:32 +04:00
|
|
|
"opal_hash_table_init() has not been called");
|
2004-10-25 23:53:44 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
2005-07-03 20:22:16 +04:00
|
|
|
for(node = (ompi_proc_hash_node_t*)opal_list_get_first(list);
|
|
|
|
node != (ompi_proc_hash_node_t*)opal_list_get_end(list);
|
|
|
|
node = (ompi_proc_hash_node_t*)opal_list_get_next(node)) {
|
2005-03-14 23:57:21 +03:00
|
|
|
if (memcmp(&node->hn_key,proc,sizeof(orte_process_name_t)) == 0) {
|
2004-10-25 23:53:44 +04:00
|
|
|
return node->hn_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-19 16:25:19 +04:00
|
|
|
int orte_hash_table_set_proc(
|
2005-07-03 20:52:32 +04:00
|
|
|
opal_hash_table_t* ht,
|
2005-03-14 23:57:21 +03:00
|
|
|
const orte_process_name_t* proc,
|
2004-10-25 23:53:44 +04:00
|
|
|
void* value)
|
|
|
|
{
|
|
|
|
uint32_t key = (proc->cellid << 24) + (proc->jobid << 16) + proc->vpid;
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_t* list = ht->ht_table + (key & ht->ht_mask);
|
2004-10-25 23:53:44 +04:00
|
|
|
ompi_proc_hash_node_t *node;
|
|
|
|
|
|
|
|
#if OMPI_ENABLE_DEBUG
|
|
|
|
if(ht->ht_table_size == 0) {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0, "opal_hash_table_set_value_proc:"
|
2005-07-03 20:52:32 +04:00
|
|
|
"opal_hash_table_init() has not been called");
|
2005-08-15 22:25:35 +04:00
|
|
|
return ORTE_ERR_BAD_PARAM;
|
2004-10-25 23:53:44 +04:00
|
|
|
}
|
|
|
|
#endif
|
2005-07-03 20:22:16 +04:00
|
|
|
for(node = (ompi_proc_hash_node_t*)opal_list_get_first(list);
|
|
|
|
node != (ompi_proc_hash_node_t*)opal_list_get_end(list);
|
|
|
|
node = (ompi_proc_hash_node_t*)opal_list_get_next(node)) {
|
2005-03-14 23:57:21 +03:00
|
|
|
if (memcmp(&node->hn_key,proc,sizeof(orte_process_name_t)) == 0) {
|
2004-10-25 23:53:44 +04:00
|
|
|
node->hn_value = value;
|
2005-08-15 22:25:35 +04:00
|
|
|
return ORTE_SUCCESS;
|
2004-10-25 23:53:44 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
node = (ompi_proc_hash_node_t*)opal_list_remove_first(&ht->ht_nodes);
|
2004-10-25 23:53:44 +04:00
|
|
|
if(NULL == node) {
|
|
|
|
node = OBJ_NEW(ompi_proc_hash_node_t);
|
|
|
|
if(NULL == node)
|
2005-08-15 22:25:35 +04:00
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
2004-10-25 23:53:44 +04:00
|
|
|
}
|
|
|
|
node->hn_key = *proc;
|
|
|
|
node->hn_value = value;
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_append(list, (opal_list_item_t*)node);
|
2004-10-25 23:53:44 +04:00
|
|
|
ht->ht_size++;
|
2005-08-15 22:25:35 +04:00
|
|
|
return ORTE_SUCCESS;
|
2004-10-25 23:53:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-19 16:25:19 +04:00
|
|
|
int orte_hash_table_remove_proc(
|
2005-07-03 20:52:32 +04:00
|
|
|
opal_hash_table_t* ht,
|
2005-03-14 23:57:21 +03:00
|
|
|
const orte_process_name_t* proc)
|
2004-10-25 23:53:44 +04:00
|
|
|
{
|
|
|
|
uint32_t key = (proc->cellid << 24) + (proc->jobid << 16) + proc->vpid;
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_t* list = ht->ht_table + (key & ht->ht_mask);
|
2004-10-25 23:53:44 +04:00
|
|
|
ompi_proc_hash_node_t *node;
|
|
|
|
|
|
|
|
#if OMPI_ENABLE_DEBUG
|
|
|
|
if(ht->ht_table_size == 0) {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0, "opal_hash_table_remove_value_proc:"
|
2005-07-03 20:52:32 +04:00
|
|
|
"opal_hash_table_init() has not been called");
|
2005-08-15 22:25:35 +04:00
|
|
|
return ORTE_ERR_BAD_PARAM;
|
2004-10-25 23:53:44 +04:00
|
|
|
}
|
|
|
|
#endif
|
2005-07-03 20:22:16 +04:00
|
|
|
for(node = (ompi_proc_hash_node_t*)opal_list_get_first(list);
|
|
|
|
node != (ompi_proc_hash_node_t*)opal_list_get_end(list);
|
|
|
|
node = (ompi_proc_hash_node_t*)opal_list_get_next(node)) {
|
2005-03-14 23:57:21 +03:00
|
|
|
if (memcmp(&node->hn_key,proc,sizeof(orte_process_name_t)) == 0) {
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_remove_item(list, (opal_list_item_t*)node);
|
|
|
|
opal_list_append(&ht->ht_nodes, (opal_list_item_t*)node);
|
2004-10-25 23:53:44 +04:00
|
|
|
ht->ht_size--;
|
2005-08-15 22:25:35 +04:00
|
|
|
return ORTE_SUCCESS;
|
2004-10-25 23:53:44 +04:00
|
|
|
}
|
|
|
|
}
|
2005-08-15 22:25:35 +04:00
|
|
|
return ORTE_ERR_NOT_FOUND;
|
2004-10-25 23:53:44 +04:00
|
|
|
}
|
|
|
|
|