2525/* Local Variables */
2626/*******************/
2727
28- static hg_hash_table_t * pvar_table ; /* Internal hash table containing PVAR info */
28+ static hg_hash_table_t * pvar_table ; /* Internal hash table containing all PVAR info */
2929
30- HG_PROF_PVAR_UINT_COUNTER_DECL (hg_pvar_hg_forward_count ); /* Declaring a PVAR */
31-
32- /* Internal routines for the pvar_hash_table data structure */
30+ /* Internal routines for the hash tables */
3331static HG_INLINE int
3432hg_prof_uint_equal (void * vlocation1 , void * vlocation2 )
3533{
@@ -44,14 +42,34 @@ hg_prof_uint_hash(void *vlocation)
4442}
4543
4644/*---------------------------------------------------------------------------*/
47-
4845hg_prof_pvar_data_t *
4946hg_prof_pvar_table_lookup (unsigned int key )
5047{
5148 return hg_hash_table_lookup (pvar_table , (hg_hash_table_key_t )(& key ));
5249}
50+
5351/*---------------------------------------------------------------------------*/
52+ hg_atomic_int32_t *
53+ hg_prof_get_pvar_addr_from_name (const char * name )
54+ {
55+ hg_prof_pvar_data_t * value = NULL ;
56+
57+ for (unsigned int i = 0 ; i < hg_hash_table_num_entries (pvar_table ); i ++ ) {
58+ value = hg_hash_table_lookup (pvar_table , (hg_hash_table_key_t )(& i ));
59+ if (strcmp (value -> name , name )== 0 ) {
60+ break ;
61+ }
62+ value = NULL ;
63+ }
64+
65+ if (value != NULL ) {
66+ return (hg_atomic_int32_t * )value -> addr ;
67+ } else {
68+ return NULL ;
69+ }
70+ }
5471
72+ /*---------------------------------------------------------------------------*/
5573void
5674HG_PROF_PVAR_REGISTER_impl (hg_prof_class_t varclass , hg_prof_datatype_t dtype , const char * name , void * addr , int count ,
5775 hg_prof_bind_t bind , int continuous , const char * desc ) {
@@ -61,6 +79,7 @@ HG_PROF_PVAR_REGISTER_impl(hg_prof_class_t varclass, hg_prof_datatype_t dtype, c
6179 * key = hg_hash_table_num_entries (pvar_table );
6280 hg_prof_pvar_data_t * pvar_info = NULL ;
6381 pvar_info = (hg_prof_pvar_data_t * )malloc (sizeof (hg_prof_pvar_data_t ));
82+
6483 (* pvar_info ).pvar_class = varclass ;
6584 (* pvar_info ).pvar_datatype = dtype ;
6685 (* pvar_info ).pvar_bind = bind ;
@@ -69,6 +88,7 @@ HG_PROF_PVAR_REGISTER_impl(hg_prof_class_t varclass, hg_prof_datatype_t dtype, c
6988 strcpy ((* pvar_info ).name , name );
7089 strcpy ((* pvar_info ).description , desc );
7190 (* pvar_info ).continuous = continuous ;
91+
7292 hg_hash_table_insert (pvar_table , (hg_hash_table_key_t )key , (hg_hash_table_value_t )(pvar_info ));
7393}
7494
@@ -80,7 +100,6 @@ hg_prof_pvar_init() {
80100 pvar_table = hg_hash_table_new (hg_prof_uint_hash , hg_prof_uint_equal );
81101 /* Register available PVARs */
82102 HG_PROF_PVAR_UINT_COUNTER_REGISTER (HG_UINT , HG_PROF_BIND_NO_OBJECT , hg_pvar_hg_forward_count , "Number of times HG_Forward has been invoked" );
83- HG_PROF_PVAR_UINT_COUNTER_REGISTER (HG_UINT , HG_PROF_BIND_NO_OBJECT , hg_pvar_dummy , "Dummy" );
84103
85104return HG_SUCCESS ;
86105}
0 commit comments