Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is C good for prallel programming and graphics?

Status
Not open for further replies.

rasgar

Programmer
Aug 17, 2005
17
US
I wanted to embark on making some visual physics software that will run on many cores and was wondering if c was good, and if so, what compilers will be best for it? Also, are there any tips that someone might be able to give me?
 
I'd rather use C++ since it doesn't require as much low level things to worry about and can do a lot of things for your automatically. C is better for things like device drivers.
 
C and C++ have no built-in graphics libraries, so you'll have to go to a third-party source for that. If you compile for more than one OS family, you'll have to have a separate library for each one, and write the graphics function calls based on which OS you're compiling for.

Lee
 
I want to run it solely on a Unix (or perhaps Linux) operating system. The project is mostly something for me to test my metal (and it's something I'm very interested in). My decision to do so came from advice that I received in order to avoid a "deadly embrace" when I'm allocating memory. Anyways, if anyone knows some good graphics libraries, and/or libraries to assist with parallel programming, I'd appreciate it.
 
If you want to run on the most different platforms, and speed isn't the most important factor, I would suggest looking into Java. You'll get to your version 1.0 a lot faster than in C, and it will run almost the same on all platforms.

Probably not a popular suggestion in a C forum, but it's pretty much true. Especially if you are asking this question, you're probably pretty early in your C learning curve. So on that too, I think Java is a better choice.

 
The thing is, time isn't much of an issue. I was thinking of making this into my senior design project (as an EE major), and I'm a sophomore in college. So right now, I just finished with my intro to C class (ending with my knowledge on structures) and I'm going to be starting my some CS courses that are required for electrical engineering. So I'd like to make a basic program in C and then slowly improve on it. Once I get all the techniques worked out, then I can start implementing it onto a integrated circuit. C is mostly my best choice since I haven't worked in Java, VB, or c++ in years now. That, and I can get my professors to help me since they're quite proficient in C. So I guess I should have changed the title to: "need libraries and tips" for parallel programming and graphics.
 
To use per-core parallelism, you need library that supports threading. I recommend SDL:


It is widely used free cross-platform C library that (besides lots of other things) also provides threading and graphics support (native 2D and opengl 3D)

For low-level parallelisation you would have to resort to assembly language - SIMD instructions (MMX,SSE...).
 
There are lots of C++ libraries which will do graphics on multiple platforms eg Fox, FLTK, WxWidgets. Haven't seen any in C. Websites for Fox and FLTK appear to have more questions than answers, so you may be on your own there.

For *nix, X Windows, Motif etc is in C but the books and experts to answer any questions are really difficult to get hold of. I don't know about KDE or Gnome. Qt is C++.

As for parallelism, you're depending on the vendor's API for that processor. Some are scalable, some are not. Again, there are very few experts in these areas. Most people just do it at the start of the project and that is it. If you ask them about it, they'll probably tell you they haven't seen the code since they last debugged it. It is normally the case of "if it works, don't touch it". Debugging parallelism can be quite difficult. You have to be able to tell all processors to stop or wait while you debug one of them.

Make sure you can debug before you venture into those areas.
 
Any suggestions for the best IDE to use?
 
I just took a look at using SDL on pelles c. Is that one of the better choices, or is there a preferable alternative? It looks good so far
 
All IDEs have their own ideosyncracies. There is no best. If you like it, it is best. If you don't like it, even though the rest of the world thinks it is best, you'll think it is crap.

What platform are you working on?
 
I'm currently using windows xp (too lazy to get partitioning software and burning a disk to get linux). I heard that Linux is the best to run SDL on. Anyways I'm quite pleased with the SDL library (just need to learn how to use it effectively). Also thanks for the help. If an admin reads this, please close the thread.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top