locked
When to learn to code for multicore processors RRS feed

  • General discussion

  • I hope I'm posting this in the right place. So I recently began learning C++ using VS10 Pro. I suppose writing code that takes advantage of multicore processors is becomming an essential tool to have. Does anyone have any thoughts on when is an appropriate time to begin thinking about this? Is it advisable to begin learning right away at the same time as learning how to program , or is it better to consider only once one has become proficient with the language and familiar with more basic aspects of good programming practices?

    Although not right now, eventually the software will have to be designed to run on a cluster.

    How similar are writing code for a multicore CPU and writing code that may be run on n CPUs that are networked? Further, if one was writing code for a cluster of constant size, is it considerably more involved to write code for a variable sized cluster. I'm not planing to jumping into this anytime soon, just wondering what I should be keeping in mind as I learn.

     

    Saturday, January 1, 2011 5:46 AM

All replies

  • Start thinking about concurrent or parallel coding from Day 2. Day 1 you learn to print "Hello, world" and then the next day you print it in parallel. Part of this depends on the programming language and how parallelism is (can be) implemented. OpenMP in C/C++ is much easier than Java Threads for first-time programmers. However, if you teach/learn parallel programming when such coding is possible, it becomes a natural way to think about algorithms and implementations. You can study a programming language and get good at it before you start studying parallel coding. This will allow you to tackle a more sophisticated method (e.g., Threading Building Blocks, Windows Threads, PPL). This approach is more akin to learning a second programming language. As for distributed coding for clusters, the approaches used for that and for multicore processors are different in how data is shared. For shared memory, threads share data by one thread writing into an agreed upon location and then another thread reading that data. It is up to the programmer to write the code in such a way that the threads write and read in the correct order. For distributed memory, the processes explicitly send and receive messages to/from other processes. Again, the programmer must know when such sharing is needed and add the appropriate logic to the code to ensure the correct swapping of messages is accomplished. Hope that helps. --clay
    Tuesday, January 4, 2011 5:19 PM