Skip to content

Commit c94a772

Browse files
authored
[CPU][Runtime] Set some CPURuntime funcs visibility to default
Addresses #293.
1 parent d9bbc85 commit c94a772

File tree

6 files changed

+46
-24
lines changed

6 files changed

+46
-24
lines changed

include/gc/ExecutionEngine/CPURuntime/Microkernel/BrgemmInterface.h

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
#include <cmath>
1313

14+
#include "gc/Utils.h"
15+
1416
extern "C" {
1517
// Runtime interfaces
1618

@@ -26,24 +28,25 @@ extern "C" {
2628
* given in dnnl type value.
2729
* Output: A handle of dispatched kernel.
2830
*/
29-
int64_t dnnl_brgemm_dispatch(int64_t M, int64_t N, int64_t K, int64_t LDA,
30-
int64_t LDB, int64_t LDC, int64_t stride_a,
31-
int64_t stride_b, float beta, int64_t dtypeA,
32-
int64_t dtypeB);
31+
GC_DLL_EXPORT int64_t dnnl_brgemm_dispatch(int64_t M, int64_t N, int64_t K,
32+
int64_t LDA, int64_t LDB,
33+
int64_t LDC, int64_t stride_a,
34+
int64_t stride_b, float beta,
35+
int64_t dtypeA, int64_t dtypeB);
3336

3437
/**
3538
* Config the AMX tile context for given kernel.
3639
* Inputs: A handle of dispatched kernel.
3740
* Output: None.
3841
*/
39-
void dnnl_brgemm_tileconfig(int64_t kernel);
42+
GC_DLL_EXPORT void dnnl_brgemm_tileconfig(int64_t kernel);
4043

4144
/**
4245
* Release the current AMX tile context.
4346
* Inputs: None.
4447
* Output: None.
4548
*/
46-
void dnnl_brgemm_tilerelease();
49+
GC_DLL_EXPORT void dnnl_brgemm_tilerelease();
4750

4851
/**
4952
* Execute the given kernel with given parameters.
@@ -54,9 +57,10 @@ void dnnl_brgemm_tilerelease();
5457
* num: Batch size of Brgemm.
5558
* Output: None.
5659
*/
57-
void dnnl_brgemm_execute(int64_t kernel, void *A, uint64_t A_offset, void *B,
58-
uint64_t B_offset, void *C, uint64_t C_offset,
59-
int num);
60+
GC_DLL_EXPORT void dnnl_brgemm_execute(int64_t kernel, void *A,
61+
uint64_t A_offset, void *B,
62+
uint64_t B_offset, void *C,
63+
uint64_t C_offset, int num);
6064
}
6165

6266
struct bf16_t {

include/gc/Utils.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===-- Utils.h - Common utility functions and macros -----------*- C++ -*-===//
2+
//
3+
// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef GC_UTILS_H
10+
#define GC_UTILS_H
11+
12+
#if defined _WIN32 || defined __CYGWIN__
13+
#define GC_DLL_EXPORT __declspec(dllexport)
14+
#else
15+
#define GC_DLL_EXPORT __attribute__((visibility("default")))
16+
#endif
17+
18+
#endif

lib/gc/ExecutionEngine/CPURuntime/MemoryPool.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <unistd.h>
2222
#endif
2323

24+
#include "gc/Utils.h"
25+
2426
#ifdef _MSC_VER
2527
#define __builtin_expect(EXP_, C) (EXP_)
2628
#endif
@@ -239,16 +241,18 @@ static thread_local FILOMemoryPool mainMemoryPool_{mainChunkSize};
239241
// if the current thread is a worker thread, use this pool
240242
static thread_local FILOMemoryPool threadMemoryPool_{threadlocalChunkSize};
241243

242-
extern "C" void *gcAlignedMalloc(size_t sz) noexcept {
244+
extern "C" GC_DLL_EXPORT void *gcAlignedMalloc(size_t sz) noexcept {
243245
return mainMemoryPool_.alloc(sz);
244246
}
245247

246-
extern "C" void gcAlignedFree(void *p) noexcept { mainMemoryPool_.dealloc(p); }
248+
extern "C" GC_DLL_EXPORT void gcAlignedFree(void *p) noexcept {
249+
mainMemoryPool_.dealloc(p);
250+
}
247251

248-
extern "C" void *gcThreadAlignedMalloc(size_t sz) noexcept {
252+
extern "C" GC_DLL_EXPORT void *gcThreadAlignedMalloc(size_t sz) noexcept {
249253
return threadMemoryPool_.alloc(sz);
250254
}
251255

252-
extern "C" void gcThreadAlignedFree(void *p) noexcept {
256+
extern "C" GC_DLL_EXPORT void gcThreadAlignedFree(void *p) noexcept {
253257
threadMemoryPool_.dealloc(p);
254258
}

lib/gc/ExecutionEngine/OpenCLRuntime/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ gc_add_mlir_library(GcOpenclRuntime
44
SHARED
55
OpenCLRuntimeWrappers.cpp
66

7+
LINK_LIBS PUBLIC
8+
GcInterface
9+
710
EXCLUDE_FROM_LIBMLIR
811
)
912

lib/gc/ExecutionEngine/OpenCLRuntime/OpenCLRuntimeWrappers.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
#include <stdexcept>
1919
#include <vector>
2020

21-
#ifdef _WIN32
22-
#define OCL_RUNTIME_EXPORT __declspec(dllexport)
23-
#else
24-
#define OCL_RUNTIME_EXPORT __attribute__((visibility("default")))
25-
#endif // _WIN32
21+
#include "gc/Utils.h"
22+
23+
#define OCL_RUNTIME_EXPORT GC_DLL_EXPORT
2624

2725
namespace {
2826

src/dnnl/dnnl_graph_compiler.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include "JsonParser.h"
2424
#include "gc/ExecutionEngine/Driver/Driver.h"
25+
#include "gc/Utils.h"
2526
#include "gc_version.h"
2627

2728
#include "mlir/ExecutionEngine/MemRefUtils.h"
@@ -33,12 +34,6 @@
3334

3435
#include "graph/backend/elyzor/include/dnnl_graph_compiler.h"
3536

36-
#if defined _WIN32 || defined __CYGWIN__
37-
#define GC_DLL_EXPORT __declspec(dllexport)
38-
#else
39-
#define GC_DLL_EXPORT __attribute__((visibility("default")))
40-
#endif
41-
4237
// dnnl_graph_compiler.h interface implementation.
4338

4439
using namespace mlir;

0 commit comments

Comments
 (0)