Skip to content

Commit

Permalink
Refactoring parallel artefacts
Browse files Browse the repository at this point in the history
  • Loading branch information
Damir Dobric committed Jan 17, 2021
1 parent 4164e31 commit 1aebabb
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 39 deletions.
2 changes: 1 addition & 1 deletion NeoCortexApi/HtmAkkaHost/HtmAkkaHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<ItemGroup>
<ProjectReference Include="..\AkkaSb.Net\AkkaSb.Net.csproj" />
<ProjectReference Include="..\DistributedComputeLib\DistributedComputeLib.csproj" />
<ProjectReference Include="..\DistributedComputeLib\NeoCortexApi.Parallel.csproj" />
<ProjectReference Include="..\NeoCortexApi\NeoCortexApi.csproj" />
<ProjectReference Include="..\NeoCortexUtils\NeoCortexUtils.csproj" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion NeoCortexApi/NeoCortexApi.Akka.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NeoCortexApi", "NeoCortexAp
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTestsProject", "UnitTestsProject\UnitTestsProject.csproj", "{A2B0776F-3650-4CE5-98BC-E2B7A2205A23}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DistributedComputeLib", "DistributedComputeLib\DistributedComputeLib.csproj", "{7F75D4D0-408B-4FFE-A450-1D7F647542B5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NeoCortexApi.Parallel", "DistributedComputeLib\NeoCortexApi.Parallel.csproj", "{7F75D4D0-408B-4FFE-A450-1D7F647542B5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NeoCortexUtils", "NeoCortexUtils\NeoCortexUtils.csproj", "{28395BF8-B719-4D93-806B-723A7AF0C56A}"
EndProject
Expand Down
1 change: 0 additions & 1 deletion NeoCortexApi/NeoCortexApi/Entities/SparseObjectMatrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Text;
using System.Linq;
using NeoCortexApi.DistributedComputeLib;

namespace NeoCortexApi.Entities
{
Expand Down
28 changes: 1 addition & 27 deletions NeoCortexApi/NeoCortexApi/Helpers.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) Damir Dobric. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
using AkkaSb.Net;

using NeoCortexApi.Entities;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -161,32 +161,6 @@ public static List<string> DefaultNodeList
// }
//}

/// <summary>
/// Gets default sparse dictionary configuration.
/// </summary>
public static ActorSbConfig DefaultSbConfig
{
get
{
ActorSbConfig cfg = new ActorSbConfig
{
SbConnStr = Environment.GetEnvironmentVariable("SbConnStr"),
ReplyMsgQueue = "actorsystem/rcvlocal",
RequestMsgTopic = "actorsystem/actortopic",
NumOfElementsPerPartition = -1, // This means, number of partitions equals number of nodes.
NumOfPartitions = 35,// Should be uniformly distributed across nodes.
BatchSize = 1000,
ConnectionTimeout = TimeSpan.FromMinutes(5),

//Nodes = new List<string>() { "node1", "node2", "node3" }
Nodes = new List<string>() { "node1"}
};

return cfg;
}
}



public static void F1()
{
Expand Down
3 changes: 1 addition & 2 deletions NeoCortexApi/NeoCortexApi/NeoCortexApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<PackageId>NeoCortexApi</PackageId>
<Version>1.0.11</Version>
<Version>1.0.12</Version>
<Authors>Damir Dobric</Authors>
<Company>daenet GmbH</Company>
<Product>Hierarchical Temporal Framework in C#</Product>
Expand Down Expand Up @@ -70,7 +70,6 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\DistributedComputeLib\DistributedComputeLib.csproj" />
<ProjectReference Include="..\NeoCortexArrayLib\NeoCortexArrayLib.csproj">
<PrivateAssets>all</PrivateAssets>
</ProjectReference>
Expand Down
1 change: 0 additions & 1 deletion NeoCortexApi/NeoCortexApi/SpatialPooler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Threading.Tasks;
using System.Linq;
using System.Diagnostics;
using NeoCortexApi.DistributedComputeLib;
using System.Collections.Concurrent;
using System.Threading;
using System.IO;
Expand Down
4 changes: 2 additions & 2 deletions NeoCortexApi/NeoCortexApi/SpatialPoolerParallel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using System.Linq;
using System.Diagnostics;
using NeoCortexApi.Utility;
using NeoCortexApi.DistributedComputeLib;


namespace NeoCortexApi
{
Expand Down Expand Up @@ -60,7 +60,7 @@ public override void InitMatrices(Connections c, DistributedMemory distMem)
if (distMem != null)
{
//var distHtmCla = distMem.ColumnDictionary as HtmSparseIntDictionary<Column>;
var distHtmCla = distMem.ColumnDictionary as ActorSbDistributedDictionaryBase<Column>;
var distHtmCla = distMem.ColumnDictionary;// as ActorSbDistributedDictionaryBase<Column>;

distHtmCla.HtmConfig = c.HtmConfig;
}
Expand Down
2 changes: 2 additions & 0 deletions NeoCortexApi/NeoCortexEntities/IDistributedDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace NeoCortexApi.Entities
{
public interface IDistributedDictionary<TKey, TValue> : IDictionary<TKey, TValue>, IEnumerator<KeyValuePair<TKey, TValue>>
{
HtmConfig HtmConfig { get; set; }

void AddOrUpdate(ICollection<KeyPair> keyValuePairs);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Linq;
using NeoCortexApi.Entities;

namespace NeoCortexApi.DistributedComputeLib
namespace NeoCortexApi.Entities
{
/// <summary>
/// Distributes huge dictionary across mutliple dictionaries. Used mainly for testing purposes.
Expand Down Expand Up @@ -261,6 +261,10 @@ IEnumerator IEnumerable.GetEnumerator()

KeyValuePair<TKey, TValue> IEnumerator<KeyValuePair<TKey, TValue>>.Current => this.dictList[this.currentDictIndex].ElementAt(currentIndex);

/// <summary>
/// Not used.
/// </summary>
public HtmConfig HtmConfig { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\DistributedComputeLib\DistributedComputeLib.csproj" />
<ProjectReference Include="..\..\DistributedComputeLib\NeoCortexApi.Parallel.csproj" />
<ProjectReference Include="..\..\NeoCortexApi\NeoCortexApi.csproj" />
<ProjectReference Include="..\..\NeoCortexEntities\NeoCortexEntities.csproj" />
<ProjectReference Include="..\..\NeoCortexUtils\NeoCortexUtils.csproj" />
Expand Down
28 changes: 27 additions & 1 deletion NeoCortexApi/UnitTestsProject/UnitTestHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Damir Dobric. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
using AkkaSb.Net;
using LearningFoundation.ImageBinarizer;
using Microsoft.Extensions.Logging;
using NeoCortexApi;
Expand Down Expand Up @@ -39,9 +40,34 @@ public static ILogger GetLogger(string logger="UnitTest")
return factory.CreateLogger(logger);
}

/// <summary>
/// Gets default sparse dictionary configuration.
/// </summary>
public static ActorSbConfig DefaultSbConfig
{
get
{
ActorSbConfig cfg = new ActorSbConfig
{
SbConnStr = Environment.GetEnvironmentVariable("SbConnStr"),
ReplyMsgQueue = "actorsystem/rcvlocal",
RequestMsgTopic = "actorsystem/actortopic",
NumOfElementsPerPartition = -1, // This means, number of partitions equals number of nodes.
NumOfPartitions = 35,// Should be uniformly distributed across nodes.
BatchSize = 1000,
ConnectionTimeout = TimeSpan.FromMinutes(5),

//Nodes = new List<string>() { "node1", "node2", "node3" }
Nodes = new List<string>() { "node1" }
};

return cfg;
}
}

public static DistributedMemory GetDistributedDictionary(HtmConfig htmConfig)
{
var cfg = Helpers.DefaultSbConfig;
var cfg = UnitTestHelpers.DefaultSbConfig;

return new DistributedMemory()
{
Expand Down
2 changes: 1 addition & 1 deletion NeoCortexApi/UnitTestsProject/UnitTestsProject.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

<ItemGroup>
<ProjectReference Include="..\AkkaSb.Net\AkkaSb.Net.csproj" />
<ProjectReference Include="..\DistributedComputeLib\DistributedComputeLib.csproj" />
<ProjectReference Include="..\DistributedComputeLib\NeoCortexApi.Parallel.csproj" />
<ProjectReference Include="..\NeoCortexApi\NeoCortexApi.csproj" />
<ProjectReference Include="..\NeoCortexArrayLib\NeoCortexArrayLib.csproj" />
<ProjectReference Include="..\NeoCortexEntities\NeoCortexEntities.csproj" />
Expand Down

0 comments on commit 1aebabb

Please sign in to comment.