From e69694138d3decac38cceafb12f7cf26a58db676 Mon Sep 17 00:00:00 2001 From: Gera Shegalov Date: Wed, 29 Nov 2023 07:10:12 -0800 Subject: [PATCH] Make DefaultHostMemoryAllocator settable (#14523) Authors: - Gera Shegalov (https://github.com/gerashegalov) Approvers: - Robert (Bobby) Evans (https://github.com/revans2) - Jim Brennan (https://github.com/jbrennan333) URL: https://github.com/rapidsai/cudf/pull/14523 --- .../cudf/DefaultHostMemoryAllocator.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/java/src/main/java/ai/rapids/cudf/DefaultHostMemoryAllocator.java b/java/src/main/java/ai/rapids/cudf/DefaultHostMemoryAllocator.java index 98a5b00cf85..469c8d16fe4 100644 --- a/java/src/main/java/ai/rapids/cudf/DefaultHostMemoryAllocator.java +++ b/java/src/main/java/ai/rapids/cudf/DefaultHostMemoryAllocator.java @@ -19,9 +19,23 @@ package ai.rapids.cudf; public class DefaultHostMemoryAllocator implements HostMemoryAllocator { - private static final HostMemoryAllocator INSTANCE = new DefaultHostMemoryAllocator(); + private static volatile HostMemoryAllocator instance = new DefaultHostMemoryAllocator(); + + /** + * Retrieve current host memory allocator used by default if not passed directly to API + * + * @return current default HostMemoryAllocator implementation + */ public static HostMemoryAllocator get() { - return INSTANCE; + return instance; + } + + /** + * Sets a new default host memory allocator implementation by default. + * @param hostMemoryAllocator + */ + public static void set(HostMemoryAllocator hostMemoryAllocator) { + instance = hostMemoryAllocator; } @Override