Skip to content

Commit

Permalink
Prevent multiple invocations of Aardvark.Init
Browse files Browse the repository at this point in the history
  • Loading branch information
hyazinthh committed Sep 11, 2024
1 parent 1f915e6 commit 7324846
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/Aardvark.Base/Introspection/Introspection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2073,8 +2073,12 @@ private static string ArchitectureString(Architecture arch)
}
}

private static bool isInitialized = false;

public static void Init()
{
if (isInitialized) return;

Report.BeginTimed("initializing aardvark");

Report.Begin("System Information:");
Expand Down Expand Up @@ -2188,6 +2192,8 @@ public static void Init()
}

Report.End();

isInitialized = true;
}

private static void LoadAll(IEnumerable<Assembly> xs)
Expand Down
12 changes: 6 additions & 6 deletions src/Tests/Aardvark.Base.FSharp.Tests/Tensors/TensorTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ module ``Tensor Tests`` =
let data = [| 42; 32; 108; -34 |]
let info = Tensor4Info(V4l(2, 2, 1, 1), V4l(1, 2, 4, 4))

pinned data (fun ptr ->
let nv = NativeTensor4.ofNativeInt<int> info ptr
data |> NativePtr.pinArr (fun ptr ->
let nv = NativeTensor4<int>(ptr, info)

let mutable index = 0
nv |> NativeTensor4.iterPtr (fun coord ptr ->
Expand All @@ -226,10 +226,10 @@ module ``Tensor Tests`` =
let dstArray = [| 0L; 0L; 0L; 0L |]
let info = Tensor4Info(V4l(2, 2, 1, 1), V4l(2, 1, 4, 4))

pinned srcArray (fun srcPtr ->
pinned dstArray (fun dstPtr ->
let src = NativeTensor4<int>(NativePtr.ofNativeInt srcPtr, info)
let dst = NativeTensor4<int64>(NativePtr.ofNativeInt dstPtr, info)
srcArray |> NativePtr.pinArr (fun srcPtr ->
dstArray |> NativePtr.pinArr (fun dstPtr ->
let src = NativeTensor4<int>(srcPtr, info)
let dst = NativeTensor4<int64>(dstPtr, info)

(src, dst) ||> NativeTensor4.iterPtr2 (fun coord src dst ->
let value = NativePtr.read src
Expand Down

0 comments on commit 7324846

Please sign in to comment.