Skip to content

Commit 21a5eab

Browse files
committed
x
1 parent ce7ee13 commit 21a5eab

File tree

9 files changed

+58
-108
lines changed

9 files changed

+58
-108
lines changed

.github/workflows/pr_push.yml

Lines changed: 1 addition & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -17,88 +17,6 @@ permissions:
1717
packages: read
1818

1919
jobs:
20-
CodeChecks:
21-
uses: ./.github/workflows/reusable_checks.yml
22-
FastBuild:
23-
name: Fast builds
24-
needs: [CodeChecks]
25-
uses: ./.github/workflows/reusable_fast.yml
26-
Build:
27-
name: Basic builds
28-
needs: [FastBuild]
29-
uses: ./.github/workflows/reusable_basic.yml
30-
DevDax:
31-
needs: [FastBuild]
32-
uses: ./.github/workflows/reusable_dax.yml
33-
MultiNuma:
34-
needs: [FastBuild]
35-
uses: ./.github/workflows/reusable_multi_numa.yml
36-
L0:
37-
needs: [Build]
38-
uses: ./.github/workflows/reusable_gpu.yml
39-
with:
40-
provider: "LEVEL_ZERO"
41-
runner: "L0"
42-
shared_lib: "['ON']"
43-
L0-BMG:
44-
needs: [Build]
45-
uses: ./.github/workflows/reusable_gpu.yml
46-
with:
47-
provider: "LEVEL_ZERO"
48-
runner: "L0-BMG"
49-
shared_lib: "['ON']"
50-
os: "['Ubuntu']"
51-
CUDA:
52-
needs: [Build]
53-
uses: ./.github/workflows/reusable_gpu.yml
54-
with:
55-
provider: "CUDA"
56-
runner: "CUDA"
57-
shared_lib: "['ON']"
58-
Sanitizers:
59-
needs: [FastBuild]
60-
uses: ./.github/workflows/reusable_sanitizers.yml
61-
QEMU:
62-
needs: [FastBuild]
63-
uses: ./.github/workflows/reusable_qemu.yml
64-
with:
65-
short_run: true
6620
ProxyLib:
67-
needs: [Build]
6821
uses: ./.github/workflows/reusable_proxy_lib.yml
69-
Valgrind:
70-
needs: [Build]
71-
uses: ./.github/workflows/reusable_valgrind.yml
72-
Coverage:
73-
# total coverage (on upstream only)
74-
if: github.repository == 'oneapi-src/unified-memory-framework'
75-
needs: [Build, DevDax, L0, CUDA, MultiNuma, QEMU, ProxyLib]
76-
uses: ./.github/workflows/reusable_coverage.yml
77-
secrets: inherit
78-
with:
79-
trigger: "${{github.event_name}}"
80-
Coverage_partial:
81-
# partial coverage (on forks)
82-
if: github.repository != 'oneapi-src/unified-memory-framework'
83-
needs: [Build, QEMU, ProxyLib]
84-
uses: ./.github/workflows/reusable_coverage.yml
85-
CodeQL:
86-
needs: [Build]
87-
permissions:
88-
contents: read
89-
security-events: write
90-
uses: ./.github/workflows/reusable_codeql.yml
91-
Trivy:
92-
needs: [Build]
93-
permissions:
94-
contents: read
95-
security-events: write
96-
uses: ./.github/workflows/reusable_trivy.yml
97-
Compatibility:
98-
needs: [Build]
99-
uses: ./.github/workflows/reusable_compatibility.yml
100-
strategy:
101-
matrix:
102-
tag: ["v1.0.1"]
103-
with:
104-
tag: ${{matrix.tag}}
22+

.github/workflows/reusable_proxy_lib.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ jobs:
5454
- name: Build UMF
5555
run: cmake --build ${{env.BUILD_DIR}} -j $(nproc)
5656

57+
- name: Run "ctest --output-on-failure" without proxy library
58+
working-directory: ${{env.BUILD_DIR}}
59+
run: ctest --output-on-failure
60+
5761
- name: Run "ctest --output-on-failure" with proxy library
5862
working-directory: ${{env.BUILD_DIR}}
5963
run: LD_PRELOAD=./lib/libumf_proxy.so ctest --output-on-failure

src/coarse/coarse.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@
2222
#include "utils_concurrency.h"
2323
#include "utils_log.h"
2424

25-
#ifdef _WIN32
26-
UTIL_ONCE_FLAG Log_initialized = UTIL_ONCE_FLAG_INIT;
27-
#else
28-
void __attribute__((constructor)) coarse_init(void) { utils_log_init(); }
29-
void __attribute__((destructor)) coarse_destroy(void) {}
30-
#endif /* _WIN32 */
31-
3225
typedef struct coarse_t {
3326
// handle of the memory provider
3427
void *provider;
@@ -883,9 +876,7 @@ static umf_result_t coarse_get_stats_no_lock(coarse_t *coarse,
883876
// PUBLIC API
884877

885878
umf_result_t coarse_new(coarse_params_t *coarse_params, coarse_t **pcoarse) {
886-
#ifdef _WIN32
887-
utils_init_once(&Log_initialized, utils_log_init);
888-
#endif /* _WIN32 */
879+
utils_log_init();
889880

890881
if (coarse_params == NULL || pcoarse == NULL) {
891882
LOG_ERR("coarse parameters or handle is missing");

src/libumf_linux.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,19 @@
99

1010
#include <umf.h>
1111

12-
void __attribute__((constructor)) umfCreate(void) { (void)umfInit(); }
12+
#include <stdio.h>
1313

14-
void __attribute__((destructor)) umfDestroy(void) { (void)umfTearDown(); }
14+
void __attribute__((constructor(102))) umfCreate(void) {
15+
fprintf(stderr, "libumf constructor pre\n");
16+
(void)umfInit();
17+
fprintf(stderr, "libumf constructor post\n");
18+
}
19+
20+
void __attribute__((destructor(102))) umfDestroy(void) {
21+
fprintf(stderr, "libumf destructor pre\n");
22+
(void)umfTearDown();
23+
fprintf(stderr, "libumf destructor post\n");
24+
}
1525

1626
void libumfInit(void) {
1727
// do nothing, additional initialization not needed

src/proxy_lib/proxy_lib_linux.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
/*
22
*
3-
* Copyright (C) 2024 Intel Corporation
3+
* Copyright (C) 2024-2025 Intel Corporation
44
*
55
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
66
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77
*
88
*/
99

10+
#include <stdio.h>
11+
1012
#include "proxy_lib.h"
1113

12-
// The priority 102 is used, because the constructor should be called as the second one
13-
// (just after the first constructor of the base allocator with priority 101)
14-
// and the destructor as the last but one (just before the last destructor
15-
// of the base allocator with priority 101), because this library
16-
// provides the memory allocation API.
17-
void __attribute__((constructor(102))) proxy_lib_create(void) {
14+
void __attribute__((constructor(101))) proxy_lib_create(void) {
15+
fprintf(stderr, "proxy constructor pre\n");
1816
proxy_lib_create_common();
17+
fprintf(stderr, "proxy constructor post\n");
1918
}
2019

21-
void __attribute__((destructor(102))) proxy_lib_destroy(void) {
20+
void __attribute__((destructor(101))) proxy_lib_destroy(void) {
21+
fprintf(stderr, "proxy destructor pre\n");
2222
proxy_lib_destroy_common();
23+
fprintf(stderr, "proxy destructor post\n");
2324
}

src/utils/utils_load_library.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,16 @@ void *utils_open_library(const char *filename, int userFlags) {
7979
LOG_FATAL("dlopen(%s) failed with error: %s", filename, dlerror());
8080
}
8181

82+
LOG_DEBUG("Opened library %s with handle %p", filename, handle);
83+
8284
return handle;
8385
}
8486

85-
int utils_close_library(void *handle) { return dlclose(handle); }
87+
int utils_close_library(void *handle) {
88+
LOG_DEBUG("Closing library handle %p", handle);
89+
90+
return dlclose(handle);
91+
}
8692

8793
void *utils_get_symbol_addr(void *handle, const char *symbol,
8894
const char *libname) {

src/utils/utils_log.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
#include "utils_common.h"
3333
#include "utils_log.h"
3434

35+
#ifndef DISABLE_SINGLE_LOGGER
36+
#include "utils_concurrency.h"
37+
#endif
38+
3539
#define UMF_MAGIC_STR "\x00@(#) "
3640
#define UMF_PREF_STR "Intel(R) "
3741
#define UMF_PREFIX UMF_MAGIC_STR UMF_PREF_STR
@@ -60,6 +64,10 @@ char const __umf_str_1__all_cmake_vars[] =
6064
#define MAX_FILE_PATH 256
6165
#define MAX_ENV_LEN 2048
6266

67+
#ifndef DISABLE_CTL_LOGGER
68+
static UTIL_ONCE_FLAG initOnce = UTIL_ONCE_FLAG_INIT;
69+
#endif
70+
6371
typedef struct {
6472
bool enableTimestamp;
6573
bool enablePid;
@@ -247,7 +255,7 @@ void utils_plog(utils_log_level_t level, const char *func, const char *format,
247255

248256
static const char *bool_to_str(int b) { return b ? "yes" : "no"; }
249257

250-
void utils_log_init(void) {
258+
static void utils_log_init_once(void) {
251259
const char *envVar = getenv("UMF_LOG");
252260

253261
if (!envVar) {
@@ -343,6 +351,12 @@ void utils_log_init(void) {
343351
}
344352

345353
// this is needed for logger unit test
354+
#ifndef DISABLE_SINGLE_LOGGER
355+
void utils_log_init(void) { utils_init_once(&initOnce, utils_log_init_once); }
356+
#else // DISABLE_SINGLE_LOGGER
357+
void utils_log_init(void) { utils_log_init_once(); }
358+
#endif
359+
346360
#ifndef DISABLE_CTL_LOGGER
347361
static umf_result_t
348362
CTL_READ_HANDLER(timestamp)(void *ctx, umf_ctl_query_source_t source, void *arg,

src/utils/utils_log.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ typedef enum {
3737
#define LOG_PFATAL(...) utils_plog(LOG_FATAL, __func__, __VA_ARGS__);
3838

3939
void utils_log_init(void);
40+
41+
// this function is used in tests to initialize the logging system
42+
void utils_log_init_test(void);
43+
4044
#ifdef _WIN32
4145
void utils_log(utils_log_level_t level, const char *func, const char *format,
4246
...);

test/utils/utils_log.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ int mock_strerror_windows(char *buff, size_t s, int errnum) {
9797

9898
extern "C" {
9999
#define DISABLE_CTL_LOGGER 1
100+
#define DISABLE_SINGLE_LOGGER 1
100101
const char *env_variable = "";
101102
#define fopen(A, B) mock_fopen(A, B)
102103
#define fputs(A, B) mock_fputs(A, B)
@@ -161,8 +162,8 @@ TEST_F(test, parseEnv_errors) {
161162
helper_checkConfig(&b, &loggerConfig);
162163
helper_log_init("_level:debug");
163164
helper_checkConfig(&b, &loggerConfig);
164-
expected_message =
165-
"[ERROR UMF] utils_log_init: Cannot open output file - path too long\n";
165+
expected_message = "[ERROR UMF] utils_log_init_once: Cannot open output "
166+
"file - path too long\n";
166167
std::string test_env = "output:file," + std::string(300, 'x');
167168
helper_log_init(test_env.c_str());
168169
}
@@ -247,7 +248,8 @@ TEST_F(test, parseEnv) {
247248
expect_fput_count = 1;
248249
if (expected_filename.size() > MAX_FILE_PATH) {
249250
expected_message =
250-
"[ERROR UMF] utils_log_init: Cannot open "
251+
"[ERROR UMF] utils_log_init_once: Cannot "
252+
"open "
251253
"output file - path too long\n";
252254
}
253255
}

0 commit comments

Comments
 (0)