Skip to content

Commit

Permalink
UCS/SYS: Added uid header file
Browse files Browse the repository at this point in the history
  • Loading branch information
Lior Paz committed Aug 4, 2021
1 parent 159d43c commit 3300c6b
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 37 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
### Features:
#### UCP
* Added API for querying UCP library attributes
#### UCS
* Added API to Read boot ID value or use machine_guid
### Bugfixes:

## 1.10.1 (May 12, 2021)
Expand Down
2 changes: 2 additions & 0 deletions src/ucs/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ nobase_dist_libucs_la_HEADERS = \
sys/sock.h \
sys/topo.h \
sys/stubs.h \
sys/uid.h \
time/time_def.h \
type/class.h \
type/param.h \
Expand Down Expand Up @@ -175,6 +176,7 @@ libucs_la_SOURCES = \
sys/sock.c \
sys/topo.c \
sys/stubs.c \
sys/uid.c \
time/time.c \
time/timer_wheel.c \
time/timerq.c \
Expand Down
26 changes: 6 additions & 20 deletions src/ucs/sys/sys.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* Copyright (C) Mellanox Technologies Ltd. 2001-2012. ALL RIGHTS RESERVED.
* Copyright (c) UT-Battelle, LLC. 2014-2019. ALL RIGHTS RESERVED.
* Copyright (C) ARM Ltd. 2016-2017. ALL RIGHTS RESERVED.
*
* See file LICENSE for terms.
*/
* Copyright (C) Mellanox Technologies Ltd. 2001-2012. ALL RIGHTS RESERVED.
* Copyright (c) UT-Battelle, LLC. 2014-2019. ALL RIGHTS RESERVED.
* Copyright (C) ARM Ltd. 2016-2017. ALL RIGHTS RESERVED.
*
* See file LICENSE for terms.
*/

#ifdef HAVE_CONFIG_H
# include "config.h"
Expand Down Expand Up @@ -1412,20 +1412,6 @@ ucs_status_t ucs_sys_get_boot_id(uint64_t *high, uint64_t *low)
return status;
}

uint64_t ucs_iface_get_system_id()
{
uint64_t high;
uint64_t low;
ucs_status_t status;

status = ucs_sys_get_boot_id(&high, &low);
if (status == UCS_OK) {
return high ^ low;
}

return ucs_machine_guid();
}

ucs_status_t ucs_sys_readdir(const char *path, ucs_sys_readdir_cb_t cb, void *ctx)
{
ucs_status_t res = UCS_OK;
Expand Down
21 changes: 6 additions & 15 deletions src/ucs/sys/sys.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* Copyright (C) Mellanox Technologies Ltd. 2001-2014. ALL RIGHTS RESERVED.
* Copyright (c) UT-Battelle, LLC. 2014-2019. ALL RIGHTS RESERVED.
* Copyright (C) ARM Ltd. 2016. ALL RIGHTS RESERVED.
*
* See file LICENSE for terms.
*/
* Copyright (C) Mellanox Technologies Ltd. 2001-2014. ALL RIGHTS RESERVED.
* Copyright (c) UT-Battelle, LLC. 2014-2019. ALL RIGHTS RESERVED.
* Copyright (C) ARM Ltd. 2016. ALL RIGHTS RESERVED.
*
* See file LICENSE for terms.
*/

#ifndef UCS_SYS_H
#define UCS_SYS_H
Expand Down Expand Up @@ -561,15 +561,6 @@ int ucs_sys_ns_is_default(ucs_sys_namespace_type_t name);
*/
ucs_status_t ucs_sys_get_boot_id(uint64_t *high, uint64_t *low);


/**
* Read boot ID value or use machine_guid.
*
* @return 64-bit value representing system ID.
*/
uint64_t ucs_iface_get_system_id();


/**
* Read directory
*
Expand Down
30 changes: 30 additions & 0 deletions src/ucs/sys/uid.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright (C) Mellanox Technologies Ltd. 2001-2012. ALL RIGHTS RESERVED.
* Copyright (c) UT-Battelle, LLC. 2014-2019. ALL RIGHTS RESERVED.
* Copyright (C) ARM Ltd. 2016-2017. ALL RIGHTS RESERVED.
*
* See file LICENSE for terms.
*/

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include "uid.h"

#include <ucs/sys/sys.h>


uint64_t ucs_get_system_id()
{
uint64_t high;
uint64_t low;
ucs_status_t status;

status = ucs_sys_get_boot_id(&high, &low);
if (status == UCS_OK) {
return high ^ low;
}

return ucs_machine_guid();
}
28 changes: 28 additions & 0 deletions src/ucs/sys/uid.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Copyright (C) Mellanox Technologies Ltd. 2001-2014. ALL RIGHTS RESERVED.
* Copyright (c) UT-Battelle, LLC. 2014-2019. ALL RIGHTS RESERVED.
* Copyright (C) ARM Ltd. 2016. ALL RIGHTS RESERVED.
*
* See file LICENSE for terms.
*/

#ifndef UCS_UID_H
#define UCS_UID_H

#include <ucs/sys/compiler_def.h>
#include <stdint.h>

BEGIN_C_DECLS

/** @file uid.h */

/**
* Read boot ID value or use machine_guid.
*
* @return 64-bit value representing system ID.
*/
uint64_t ucs_get_system_id();

END_C_DECLS

#endif
2 changes: 1 addition & 1 deletion src/uct/base/uct_iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ uct_ep_keepalive_check(uct_ep_h tl_ep, uct_keepalive_info_t **ka, pid_t pid,
void uct_iface_get_local_address(uct_iface_local_addr_ns_t *addr_ns,
ucs_sys_namespace_type_t sys_ns_type)
{
addr_ns->super.id = ucs_iface_get_system_id() &
addr_ns->super.id = ucs_get_system_id() &
~UCT_IFACE_LOCAL_ADDR_FLAG_NS;

if (!ucs_sys_ns_is_default(sys_ns_type)) {
Expand Down
2 changes: 1 addition & 1 deletion src/uct/base/uct_iface.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <ucs/debug/debug_int.h>
#include <ucs/stats/stats.h>
#include <ucs/sys/compiler.h>
#include <ucs/sys/sys.h>
#include <ucs/sys/uid.h>
#include <ucs/type/class.h>
#include <uct/api/v2/uct_v2.h>
#include <ucs/type/param.h>
Expand Down

0 comments on commit 3300c6b

Please sign in to comment.