Unify the CPU, CUDA and OpenCL math functions API in the device wrapper classes

This PR wraps the math functions as suggested by both [Yangqing](https://github.com/BVLC/caffe/issues/382#issuecomment-42465152) in #382 and [jeffdonahue](https://github.com/BVLC/caffe/issues/408#issuecomment-43035934) in #408 to abstract the device type from the algorithms.
Just a note: I have commits in my working copy that fix all the data getters, and all the tests now work fine for me on my CUDA box.  I can either submit a PR into your branch with those @kloudkl, or I can push them directly if you make me a collaborator.

@shelhamer I like that path forward on mode setting: each layer would have its own method for explicitly setting its mode at any time, and the Net would have a mode setter method that sets all its layers' modes.  Then at computation time, each layer just checks its own mode to determine how to proceed with data access and computation.