Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Gargi · Jul 19, 2012 at 06:15 PM · multithreadingcpu

allocate specific cpu-cores for Unity

Hi

Is it possible to allow Unity to run only on specific cpu-cores? (maybe with a 32bit-int Bitmask)

I need that to run some heavy calculations without affect the game itself.

Thanks

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bovine · Jul 23, 2012 at 08:30 PM 0
Share

This is typically no recommended as the OS (i.e. windows) scheduler is better at judging which processors to run processes and threads on. If you bind affinity to only one CPU, or exclude one, you could end up with worse performance.

I would first ask if there was a reason to do this - are you seeing a performance problems? Can you be sure it's because your calculations are starving Unity from running efficiently?

Otherwise you could write a c plugin to set the thread affinity.

If you want to debug on windows, then you could get SysInternals process explorer which allows you to see and set the process affinity of running apps so that you can see what the effect is.

avatar image Gargi · Jul 24, 2012 at 08:23 AM 0
Share

Hi

The reason i ask is the following: I am working on my own AI. The complete AI is running in a separate thread but in the same process ( Unity + DLL). The advantage is, that i can run the thread on a specific core without to affect the 3D-Engine. You can see it as a kind of two main-loops. It worked very good in Torque.

This way, i can run the Engine (for example on a QuadCore) on the first two cores and the AI on cores three and four. The AI is self-balancing.

avatar image Bovine · Jul 24, 2012 at 09:21 AM 0
Share

Please convert this to a comment.

You could do this but I don't know as there is any evidence of it being better. $$anonymous$$y understanding of thread affinity, is that the only benefit is to ensure that you're not thrashing the cache - that your threads are not likely to access main memory as often.

As I said before, the scheduler on a PC at least, is better at deciding which CPU to use. The argument against setting thread affinity is that what you are actually doing is preventing the scheduler from running your code on particular CPUs, which means that if a CPU is available for work but you cannot run on it, then your thread won't get any CPU time.

Rather than threads, you could always use coroutines - but you are of course sharing the CPU with your game loop.

avatar image Gargi · Jul 24, 2012 at 11:23 AM 0
Share

Hi

Thank you very much for the explantation. I have to see how my AI affects the Unity-Engine over the time. The main goal is, that my AI does not directly slow down the main loop of the 3D-Engine.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by cupsster · Aug 02, 2012 at 09:55 AM

Unity Threading Helper is no help to you?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Android - How to force the usage of all mobile CPU cores of the app? 0 Answers

Does the Webplayer support multi-core CPUs? 0 Answers

Multithreading doesn’t improve performance 0 Answers

How can I get the number of physical cores in the CPU (not logical cores) 1 Answer

Using the GPU instead of multiple threads 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges