Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[connect] Optimize the connector about ScaleFreeBA, ScaleFreeBADual, PowerLaw #412

Merged
merged 14 commits into from
Jul 6, 2023

Conversation

Routhleck
Copy link
Collaborator

@Routhleck Routhleck commented Jul 5, 2023

Description

Add new test case for ProbDist in test_random_conn.py

Create test_all_time.py to test the efficiency of all connectors and the results show that the following four connectors need to be optimized: ScaleFreeBA, ScaleFreeBADual, PowerLaw and ProbDist.

Optimize ScaleFreeBA, ScaleFreeBADual, PowerLaw's build_conn function by by preallocating repeated_nodes with array of numpy and Rename their build_conn to build_mat, also their returned values are changed accordingly

Try to optimize ProbDist, but if parallelization is performed, the results will be inconsistent which need to be solved in the future

Create test_optimized_result.py to compare the results and time needed between before and after optimized for GaussianProb, ScaleFreeBA, ScaleFreeBADual and PowerLaw

How Has This Been Tested

Test device

Hardware

  • CPU: Intel Core i5-12490F 6C12T

  • GPU: Nvidia Geforce RTX 2070

  • RAM: 32G DDR4 3200MHz

Software

  • OS: Windows10 20H2

  • Python: 3.10

Below is the test result

<style> </style>
connector name connect matrix size build function other parameter time origin(ms) time optimized(ms) ratio remark
GaussianProb 100x100 build_mat sigma=1 / include_self=False 2.00 1.00 1.00  
GaussianProb 500x500 build_mat sigma=1 / include_self=False 16.00 5.00 2.20  
GaussianProb 2500x2500 build_mat sigma=1 / include_self=False 382.98 86.79 3.41  
GaussianProb 12500x12500 build_mat sigma=1 / include_self=False 6861.67 1682.14 3.08  
GaussianProb 100x100 build_mat sigma=4 2.00 1.00 1.00  
GaussianProb 500x500 build_mat sigma=4 14.00 5.00 1.80  
GaussianProb 2500x2500 build_mat sigma=4 286.29 77.00 2.72  
GaussianProb 12500x12500 build_mat sigma=4 6748.89 1350.49 4.00  
GaussianProb 100x100 build_mat sigma=4 / periodic_boundary=True 2.00 1.00 1.00  
GaussianProb 500x500 build_mat sigma=4 / periodic_boundary=True 16.00 4.00 3.00  
GaussianProb 2500x2500 build_mat sigma=4 / periodic_boundary=True 302.53 72.00 3.20  
GaussianProb 12500x12500 build_mat sigma=4 / periodic_boundary=True 7276.54 1386.13 4.25  
GaussianProb 100x100 build_mat sigma=4 / periodic_boundary=True 2.00 0.99 1.01  
GaussianProb 500x500 build_mat sigma=4 / periodic_boundary=True 16.00 5.00 2.20  
GaussianProb 2500x2500 build_mat sigma=4 / periodic_boundary=True 313.53 71.00 3.42  
GaussianProb 12500x12500 build_mat sigma=4 / periodic_boundary=True 7243.03 1391.71 4.20  
ScaleFreeBA 100x100 build_mat m=2 2.00 1.00 1.00  
ScaleFreeBA 500x500 build_mat m=2 21.00 4.00 4.25  
ScaleFreeBA 2500x2500 build_mat m=2 462.00 18.00 24.67  
ScaleFreeBA 12500x12500 build_mat m=2 11013.49 113.00 96.46  
ScaleFreeBADual 100x100 build_mat m1=2 / m2=3 / p=0.4 2.00 1.00 1.00  
ScaleFreeBADual 500x500 build_mat m1=2 / m2=3 / p=0.4 29.00 4.00 6.25  
ScaleFreeBADual 2500x2500 build_mat m1=2 / m2=3 / p=0.4 618.25 28.00 21.08  
ScaleFreeBADual 12500x12500 build_mat m1=2 / m2=3 / p=0.4 13944.25 132.00 104.64  
PowerLaw 100x100 build_mat m=3 / p=0.4 2.00 2.00 0.00  
PowerLaw 500x500 build_mat m=3 / p=0.4 38.00 7.00 4.43  
PowerLaw 2500x2500 build_mat m=3 / p=0.4 820.53 39.00 20.04  
PowerLaw 12500x12500 build_mat m=3 / p=0.4 18474.92 282.06 64.50  
ProbDist {1000} build_coo dist=1 / prob=0.5 / pre_ratio=0.3 / include_self=True 29.00 17.00 0.71 unparallel, result same
ProbDist {(100, 20)} build_coo dist=1 / prob=0.5 / pre_ratio=0.3 / include_self=True 114.53 118.00 -0.03 unparallel, result same
ProbDist {(4, 20, 20)} build_coo dist=1 / prob=0.5 / pre_ratio=0.3 / include_self=True 75.00 77.00 -0.03 unparallel, result same
ProbDist {(4, 3, 8, 5)} build_coo dist=1 / prob=0.5 / pre_ratio=0.3 / include_self=True 8.00 10.00 -0.20 unparallel, result same
ProbDist {10000} build_coo dist=1 / prob=0.5 / pre_ratio=0.3 / include_self=True 2745.23 461.59 4.95 parallel, result diifferent

Copy link
Collaborator

@chaoming0625 chaoming0625 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Excellent works.

@chaoming0625 chaoming0625 merged commit bcac710 into brainpy:master Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants