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.
To unify the data getters of different devices, cpu/gpu_data and mutable_cpu/gpu_data of the Blob were replaced by const_data and mutable_data respectively. Dynamically choosing the mode makes the data from different devices memory interact in unpredictable ways. That's why I wanted to fix the layers to be in a single mode (https://github.com/BVLC/caffe/pull/415#issuecomment-43186824).  The crashed caused by the SyncedMemory is also an example of this symptom. 

Due to lack of access to GPU, all the GPU tests were ignored in https://github.com/BVLC/caffe/pull/415#issuecomment-44829969. Thanks for your tests to expose the problems again! SyncedMemory data getters were on the to do list and I will fix them today.