CUDA coding on Titan black and Tesla K40

I have a simple question: our lab plan to work on parallel computation with CUDA on Tesla k40, while one of our collaborator are doing similiar work on Titan black. So could the code with Titan black used directly with Tesla k40?
Thanks

Yes, both the GTX Titan Black and the Tesla K40 are GPUs with compute capability 3.5 (i.e. sm_35), so if you build with -arch=sm_35 you can simply move over the resulting binary. Since the HW specifications are different, you may of course observe some performance differences between the two GPUs.