-
Notifications
You must be signed in to change notification settings - Fork 204
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
Implementation and documentation of multi-threaded routing optimization #64
Conversation
I'll need a few days to test the new parameters and check their results, but it looks good, excellent contribution, thank you @UAV-Pilot! |
Hi
Yes, this looks like an amazing new capability for FreeRouting. Using multiple cores for optimizing would be truly incredible!
Is there any chance to get a 32-bit Windows version so I can help with testing? I would love to see this running in person. I am still using 1.2.43 Extra with Java 8
Much appreciated, Thanks, Andrew Lynch
On Tuesday, September 7, 2021, 06:59:43 AM EDT, Andras Fuchs ***@***.***> wrote:
I'll need a few days to test the new parameters and check their results, but it looks good, excellent contribution, thank you @UAV-Pilot!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
|
@lynchaj I'm not familiar with the build process here on GitHub, so I can't help you with the 32-bit question from the top of my head. We moved to Java 11 so you can't compile it for Java 8, but building a 32-bit version of the Java 11 executable should be possible, I think, but again I'm not an expert. Could you try to clone @UAV-Pilot's freerouting repo, compile the source code and run it on your computer locally? It should work on 32-bit Windows too. @miho, what do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1, I run the same test input .DNS file with various -mt settings:
a, without -mt (effectively using the default -mt 4),
b, -mt 128 and
c, -mt 1.
I got exactly the same .SES files with them and they all completed in 254-255 seconds. That is a little strange, isn't it? I got an 8-core CPU.
The original v1.4.4 run in 612 seconds with the same input, and produced a slightly different .SES file.
Do you know what the reason can be?
2, Freerouter produced some temp files and they are not deleted after the successful run. Could you add a cleanup procedure?
@@ -10,7 +11,10 @@ | |||
import java.util.HashMap; | |||
|
|||
public class FRLogger { | |||
private static Logger logger = LogManager.getLogger(FreeRouting.class); | |||
private static Logger logger = LogManager.getLogger(FR.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see what you did here. Alright, now I understand why you needed that empty class.
Although I fully agree with you that the original name of the class FreeRouting is too long and redundant, there must be a better way to hide it by configuring the logger.
This looks like a quick fix, so please revert it back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name "FreeRouting" alone is not too long, but "eu.mihosoft.freerouting.FreeRouting" was too long in log and made it harder to read log messages on screen. BTW, the original class FreeRouting is also an empty class. I actually have not worked with Java for quite long time except this project, so I'm not sure if it's easy to customize log4j for this behavior. If you're sure log4j can be customized easily for our purpose here, I'll revert it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's reverted anyway. Someone please take care of it later.
With 8-cores, it's likely not meaningful to have more than 16 threads assuming each core is capable of hyperthreading. With such a simple board, the time for each thread to duplicate board is probably a large portion of execution time. Note that in README.md, I mentioned future enhancement about cloning. It's better to use a more complex board to do the comparison test, e.g., a board previously needed more than 10 hours to optimize. |
Hi
I’ve got a good example for you. It’s my Z80 DUART board that’s been running for two days now. I don’t know how many passes it has completed but it’s been well over a hundred. 2 layer PCB, all PTH construction. Old school logic and passives all the way. It solves on its own in the autorouter without any forcing or manual routing.
It’s not done yet but getting there soon. I sometimes run FreeRouting software early as a means to locate problems, to rearrange parts and move them closer together to improve overall trace routing. Please give it a try and post the outcome.
See if you can beat 32 vias and 265.6795 inches of overall trace length
Thanks, Andrew Lynch
PS, I am running FR 1.2.43 Extra
From: UAV Pilot ***@***.***
Sent: Tuesday, September 7, 2021 3:12 PM
To: freerouting/freerouting ***@***.***>
Cc: lynchaj ***@***.***>; Mention ***@***.***>
Subject: Re: [freerouting/freerouting] Implementation and documentation of multi-threaded routing optimization (#64)
With 8-cores, it's likely not meaningful to have more than 16 threads assuming each core is capable of hyperthreading. With such a simple board, the time for each thread to duplicate board is probably a large portion of execution time. Note that in README.md, I mentioned future enhancement about cloning.
It's better to use a more complex board to do the comparison test, e.g., a board previously needed more than 10 hours to optimize.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#64 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AUXGBYYTD4MFWCCQS26YI2DUAZPWPANCNFSM5DRIMDDQ> .
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub> . <https://github.com/notifications/beacon/AUXGBY247IQW6SDEZL7IYHLUAZPWPA5CNFSM5DRIMDD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOG2BQEBY.gif>
|
Argh! it stripped my attachment
On Saturday, September 11, 2021, 11:31:00 AM EDT, lynchaj ***@***.***> wrote:
Hi
I’ve got a good example for you. It’s my Z80 DUART board that’s been running for two days now. I don’t know how many passes it has completed but it’s been well over a hundred. 2 layer PCB, all PTH construction. Old school logic and passives all the way. It solves on its own in the autorouter without any forcing or manual routing.
It’s not done yet but getting there soon. I sometimes run FreeRouting software early as a means to locate problems, to rearrange parts and move them closer together to improve overall trace routing. Please give it a try and post the outcome.
See if you can beat 32 vias and 265.6795 inches of overall trace length
Thanks, Andrew Lynch
PS, I am running FR 1.2.43 Extra
From: UAV Pilot ***@***.***
Sent: Tuesday, September 7, 2021 3:12 PM
To: freerouting/freerouting ***@***.***>
Cc: lynchaj ***@***.***>; Mention ***@***.***>
Subject: Re: [freerouting/freerouting] Implementation and documentation of multi-threaded routing optimization (#64)
With 8-cores, it's likely not meaningful to have more than 16 threads assuming each core is capable of hyperthreading. With such a simple board, the time for each thread to duplicate board is probably a large portion of execution time. Note that in README.md, I mentioned future enhancement about cloning.
It's better to use a more complex board to do the comparison test, e.g., a board previously needed more than 10 hours to optimize.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#64 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AUXGBYYTD4MFWCCQS26YI2DUAZPWPANCNFSM5DRIMDDQ> .
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub> . <https://github.com/notifications/beacon/AUXGBY247IQW6SDEZL7IYHLUAZPWPA5CNFSM5DRIMDD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOG2BQEBY.gif>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
|
An open source example board and documentation of approximate 27 times speedup with this board in README.md were checked in the last commit. |
@UAV-Pilot Thanks for the updates! Could you send me any of those files that had such big improvement in DSN format, so that I can also test them? The strange thing is so far that no matter how much threads I set to use (with the -mt) both the results and the time need are the same with my inputs. @lynchaj Could you somehow send me your Z80 DUART board as a DSN file? I would like to test it. If you still want to join the testing, I would suggest you to use IntelliJ IDEA development environment, it works well for me. I'll continue running some test this week, so let me know if you need any help with the setup. Also, since @miho seems to be not reacting to the 32-bit executable request, could you take a look and try to compile the source into a 32-bit version? I would start with the gradlew.bat, but I might be wrong. |
@andrasfuchs The board file freerouting/tests/smoothieboard-v1.1_preOpt.bin was checked in, so it's available in my repository. As documented in README.md, this file was created in Freerouting v1.4.4, and bin format is native format of Freerouting, so Freerouting v1.4.4 should be able to open this file. |
BTW, memory usage in route optimization of tests/smoothieboard-v1.1_preOpt.bin reached about 10 GB, so performance of route optimization for boards of medium to high complexity with 32-bit version will be affected by limited memory. |
Thanks for the file and the heads up about memory usage! The bin file might be native, yes, but I would like to test it like it was in a normal scenario, passing it as a command line parameter, that's why I would prefer the board as DSN. Don't worry though, if you can't share it with me in that format, I will test the multi-threading functionality with other boards I have. I'll try to make the time for it this week, and get back to you. |
…ard Eagle project for testing
I tried to import Spectra Session file into KiCad and then to export DSN file, but an error prevented the import, so there is an bug somewhere in KiCad or freerouting with regarding importing Spectra Session file. While doing it, I noticed that previously I unintentionally left a ground zone on the top layer, so I went on to further change the imported KiCad project. Here are additional changes to the KiCad project: 1) removed a ground zone on the the top layer. 2) changes to resolve all DRC violations: changed footprints for several solder jumpers, shifted several R, C components, and moved J10, which seems to be in an odd place after the import. Before this pull request, I never used or worked on smoothieboard, so I don't know why some connectors were arranged in that way. In my latest commit, I put the whole KiCad project in zip format into the test folder. Inside it, there is an exported DSN file where majority of connections are not routed. Hopefully this zip file together with the DSN file inside can provide a starting point for anyone who likes to use it for testing. Actually any other publicly available board with enough complexity can also be used in test. |
I just run the following command: As I investigated the process it run only on one core (despite the -mt 32 parameter) and my CPU usage was only 10-12%. Looking at the source code I would have expected to see the "Start to run optimization pass" in the logs, but it looks like the optimization didn't start. I also got an error while I tried to import the SES file: |
As mentioned in my previous comment, "there is an exported DSN file where majority of connections are not routed". You can also verify it via menu Info > Incompletes. It looks like importing from EAGLE to KiCad caused the SES importing issue. I did not encounter this problem with non-imported projects. |
Revised the way to estimate speedup in the last commit. Previously time for Freerouting v1.4.4 to reach final via count and final trace length was used in the calculation. |
DSN file within the zip was also updated |
Excellent, thank you. I'm playing around with the source code right now. Could you get the latest commits in master into your pull request, so I can continue testing? Thank you for your work and patience! |
My latest commit is in the pull request. I just added a routed Smoothieboard (in bin format) which is ready for route optimization. It's smoothieboard-5driver_preOpt.bin in the zip file. After removing " (component |
BTW, I never used the -mp option as all the boards except the smoothieboard that I used with Freerouting are boards designed by myself, and I wanted to get best possible PBC boards, so I did not put limit on passes. |
|
||
/** | ||
* Saves the interactive settings and the design file to disk. | ||
* Returns false, if the save failed. | ||
*/ | ||
boolean save() | ||
public boolean save(String surffix) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a typo, surffix
-> suffix
.
@UAV-Pilot I run some tests and your multi-threaded implementation works fine. I made a few small changes and fixed only a few small bugs. So I just want to thank you again for your contribution! It would be great to see you contribute more, so don't hesitate to contact me if you feel like implementing another good idea of yours as a pull request. (I also fixed the snapshot generator, so you can test the binaries from the Release page) |
@andrasfuchs I was kind of being forced to make this optimization when it seemed impossible to finish route optimization for one of my boards with previous version. Thanks for keeping Freerouting available and improving it! |
Out of curiosity, is there a paper describing the algorithm the multi-threaded optimizations are based on? |
Currently all of document about the multi-threaded optimization are in README.md. Multi-threading is implemented via Java thread pool. Greedy board updating strategy is based on classic greedy algorithm. Prioritized item selection strategy is implemented via priority queue if I remember correctly. PCB routing optimization is complicated, and effectiveness of various implemented algorithms probably varies from board to board. If you're interested, please help improve existing ones and also add new ones. |
The implementation and usage are documented in README.md