aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile6
-rw-r--r--embed_cuda.h29
2 files changed, 23 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index e118f68..ec3c77f 100644
--- a/Makefile
+++ b/Makefile
@@ -136,7 +136,7 @@ cuda:
# -arch=native targets the GPU present at build time (we always build CUDA
# on the machine that runs it), avoiding first-load PTX JIT.
embed_cuda.o: embed_cuda.cu embed_cuda.h embed_internal.h embed.h
- $(NVCC) -O3 -std=c++17 -arch=native -Xcompiler -fPIC -DUSE_BLAS -DUSE_OPENBLAS -DUSE_CUDA -I/usr/include/openblas -I$(CUDA_HOME)/include -x cu -c -o $@ $<
+ $(NVCC) -O3 -std=c++17 -arch=native -Xcompiler -fPIC,-fvisibility=hidden -DUSE_BLAS -DUSE_OPENBLAS -DUSE_CUDA -I/usr/include/openblas -I$(CUDA_HOME)/include -x cu -c -o $@ $<
# =============================================================================
# Shared library (built by every backend target from the same objects)
@@ -197,7 +197,7 @@ test:
./tests/test_late
$(CC) $(TEST_CC_FLAGS) $(TEST_BLAS_CFLAGS) -o tests/cli_under_test \
$(TEST_CLI_BIN_SRCS) -lm -lpthread $(TEST_BLAS_LDFLAGS)
- $(CC) $(TEST_CC_FLAGS) -o tests/test_cli tests/test_cli.c
+ $(CC) $(TEST_CC_FLAGS) -o tests/test_cli tests/test_cli.c -lm
./tests/test_cli ./tests/cli_under_test
$(CC) $(TEST_CC_FLAGS) $(TEST_BLAS_CFLAGS) $(CJSON_CFLAGS) -Ideps/ae \
-o tests/test_server $(TEST_SERVER_SRCS) \
@@ -255,7 +255,7 @@ coverage:
LLVM_PROFILE_FILE=$(COV_DIR)/late.profraw ./tests/test_late
$(CC) $(TEST_CC_FLAGS) $(COV_FLAGS) $(TEST_BLAS_CFLAGS) -o tests/cli_under_test \
$(TEST_CLI_BIN_SRCS) -lm -lpthread $(TEST_BLAS_LDFLAGS)
- $(CC) $(TEST_CC_FLAGS) -o tests/test_cli tests/test_cli.c
+ $(CC) $(TEST_CC_FLAGS) -o tests/test_cli tests/test_cli.c -lm
LLVM_PROFILE_FILE=$(COV_DIR)/cli_%p.profraw ./tests/test_cli ./tests/cli_under_test
$(CC) $(TEST_CC_FLAGS) $(COV_FLAGS) $(TEST_BLAS_CFLAGS) $(CJSON_CFLAGS) -Ideps/ae \
-o tests/test_server $(TEST_SERVER_SRCS) \
diff --git a/embed_cuda.h b/embed_cuda.h
index 8ebe6e2..3c9011d 100644
--- a/embed_cuda.h
+++ b/embed_cuda.h
@@ -5,25 +5,36 @@
#ifndef PPLX_EMBED_CUDA_H
#define PPLX_EMBED_CUDA_H
+/* Public-API export annotation. The libraries are built with
+ * -fvisibility=hidden, so only declarations carrying PPLX_API are exported
+ * from the shared library; everything else stays internal. */
+#ifndef PPLX_API
+#if defined(__GNUC__)
+#define PPLX_API __attribute__((visibility("default")))
+#else
+#define PPLX_API
+#endif
+#endif
+
#include "embed.h"
typedef struct pplx_cuda_ctx pplx_cuda_ctx_t;
-int pplx_cuda_set_fast_gemm(const char *mode);
-int pplx_cuda_set_weights_bf16(int on);
+PPLX_API int pplx_cuda_set_fast_gemm(const char *mode);
+PPLX_API int pplx_cuda_set_weights_bf16(int on);
-pplx_cuda_ctx_t *pplx_cuda_load(const char *model_dir);
-void pplx_cuda_free(pplx_cuda_ctx_t *ctx);
+PPLX_API pplx_cuda_ctx_t *pplx_cuda_load(const char *model_dir);
+PPLX_API void pplx_cuda_free(pplx_cuda_ctx_t *ctx);
-const pplx_config_t *pplx_cuda_config(const pplx_cuda_ctx_t *ctx);
+PPLX_API const pplx_config_t *pplx_cuda_config(const pplx_cuda_ctx_t *ctx);
-int pplx_cuda_embed_into(pplx_cuda_ctx_t *ctx, const int *token_ids,
+PPLX_API int pplx_cuda_embed_into(pplx_cuda_ctx_t *ctx, const int *token_ids,
int n_tokens, float *out_embedding);
-float *pplx_cuda_embed(pplx_cuda_ctx_t *ctx, const int *token_ids,
+PPLX_API float *pplx_cuda_embed(pplx_cuda_ctx_t *ctx, const int *token_ids,
int n_tokens);
-int pplx_cuda_embed_batch(pplx_cuda_ctx_t *ctx, const pplx_input_t *inputs,
+PPLX_API int pplx_cuda_embed_batch(pplx_cuda_ctx_t *ctx, const pplx_input_t *inputs,
int batch, float *out_embeddings);
-int pplx_cuda_embed_spans_batch(pplx_cuda_ctx_t *ctx,
+PPLX_API int pplx_cuda_embed_spans_batch(pplx_cuda_ctx_t *ctx,
const pplx_context_input_t *inputs,
int batch, float *out_embeddings);