ashwin / coursera-heterogeneous

Resources to work offline on the assignments of Heterogenous Parallel Programming course from Coursera.
71 stars 60 forks source link

Mac instructions are incomplete #16

Closed mehaase closed 11 years ago

mehaase commented 11 years ago

Thanks for creating this! I'm looking forward to getting it working. I noticed the Mac instructions are incomplete, it says:

"Select mp0 under targets"

If you do this, then only mp0 will build correctly. mp1 and mp2 will get linker errors. I added it to m1, mp2, and mp3, but I think you can also add it to "ALL BUILD". (I have no idea if that would actually work... I hate XCode and almost never use it.)

mehaase commented 11 years ago

While I was messing around, I tried cleaning my cmake build and starting over. Somehow I ended up without Project.xcodeproj and now I can run "make mpX" instead, which is much nicer... not sure how I did this, but it would be nice to add to the instructions also.

I also think you should add some items to the .gitignore:

diff --git a/.gitignore b/.gitignore
index b922513..180cc87 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,7 @@
 *.cache
 .DS_Store
+CMakeCache.txt
+CMakeFiles/
+Makefile
+cmake_install.cmake
+mp*

That way people can use this repository as the basis for entering their homework and saving it in version control as well.

achille commented 11 years ago

Yeah turns out it needs a special plugin on Xcode. You can still run it on the command line, make sure to install homebrew and cmake.

mehaase commented 11 years ago

I don't think I have any special plugins installed. I just have basic Xcode, the CUDA SDK, and cmake.

achille commented 11 years ago

Are you building and running it on the command line or on Xcode? Can you set debug points?

mehaase commented 11 years ago

The first time I ran cmake, I got a Project.xcodeproj, so I followed the instructions to modify the build targets in Xcode. It didn't work at first though, because the instructions only mention mp0!!! That's when I posted this issue, because the instructions need to mention mp1, mp2, mp3, etc... or else end users will see linker errors when they build those.

After cleaning and re-running cmake, I now have a Makefile instead of Project.xcodeproj. This is better for me, since I don't plan to set any breakpoints in Xcode. (Can I set breakpoints inside the CUDA kernel from Xcode? I'm guessing no.) If I need to debug I'll just use gdb from a shell.

mehaase commented 11 years ago

Also, the instructions should include some details on how to run each assignment after you build it.

I figured out experimentally that the following works:

$ ./mp2 tests/mp2_data/0/*

I think this should be mentioned in the README.md.

iemejia commented 11 years ago

Actually this is a collaborative project created by students of the class. I agree they are still many things to be improved, but this is a chance for you to collaborate with us, actually we all have put a bit of effort to make this better. This is for example the first time i commit to a different project than my personal ones in github, and the first time I use the pull request mechanism, and I'm happy because I've learned lots about git without even expecting to do so, so I encourage you to do a 'git clone' and offer your own pull requests, for example for the .gitignore file, it isn't so hard to do, and i think if your commit makes sense ashwin will be glad to accept it.

andre-orr commented 11 years ago

What version of Xcode are you using? I have a fork of this project with an altered CMakeLists.txt that removes the requirement to manually change the link loader flags in Xcode. It's as simple as Open the Xcode project, select the target, and Run! (Though I've tested it with Xcode 4.5.2, CMake 2.8.9 from MacPorts, and CUDA 5.0; I actually do most of my CUDA development in SublimeText and the shell)

To generate an Xcode project file, type:

cmake CMakeLists.txt -G Xcode

Or if you prefer a Unix Makefile, type:

cmake CMakeLists.txt
mehaase commented 11 years ago

I am also using Xcode 4.5.2.

I finally realized that "-G Xcode" tells Cmake to make an Xcode project instead of Make. I also prefer the Unix makefile.

I think you should submit a pull request that removes the need to change the link loaders flags. The requirement to change the flags for every build target is going to trip a lot of people up! (And if you do submit a pull request, please all submit the changed README.md with your change. Seems to me like the README is already out of date w.r.t. the code.)

achille commented 11 years ago

Andre, are you able to run mp2 under xcode? I've only been able to get it to run on the commandline via make. Does it support setting debug points?

andre-orr commented 11 years ago

Xcode will correctly build and run all of the MPs; however to Run a particular MP you may need to edit that target's Scheme, passing in the command line arguments for the data you wish to test. Unfortunately you can't debug a CUDA file under Xcode, which somewhat limits its utility (there's no integration between Xcode and NVIDIA's cuda-gdb). Xcode-CUDA

ashwin commented 11 years ago

@mehaase I have merged all your requests in. Thanks for that :+1:

As @achille, @iemejia and @andre-orr have pointed out, this is something I shared with the Coursera students and it has turned into a friendly collaborative effort.

I do not have a Mac, so I rely on all of you to feed me pull requests that will work easily for all or most Mac users. :smiley:

mehaase commented 11 years ago

Thanks, Ashwin! This is an amazing project. It has totally turned around my enjoyment of HPP class.