refactoring src/channel.cpp and add synchronization CUDA resources