HMSBEAGLE
1.0.0
|
00001 /* 00002 * @brief GPU implementation helper functions 00003 * 00004 * Copyright 2009 Phylogenetic Likelihood Working Group 00005 * 00006 * This file is part of BEAGLE. 00007 * 00008 * BEAGLE is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as 00010 * published by the Free Software Foundation, either version 3 of 00011 * the License, or (at your option) any later version. 00012 * 00013 * BEAGLE is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with BEAGLE. If not, see 00020 * <http://www.gnu.org/licenses/>. 00021 * 00022 * @author Marc Suchard 00023 * @author Daniel Ayres 00024 */ 00025 00026 #ifndef __GPUImplHelper__ 00027 #define __GPUImplHelper__ 00028 00029 #ifdef HAVE_CONFIG_H 00030 #include "libhmsbeagle/config.h" 00031 #endif 00032 00033 #include "libhmsbeagle/GPU/GPUImplDefs.h" 00034 00035 void checkHostMemory(void* ptr); 00036 00040 template<typename Real> 00041 void transposeSquareMatrix(Real* mat, 00042 int size) { 00043 for (int i = 0; i < size - 1; i++) { 00044 for (int j = i + 1; j < size; j++) { 00045 Real tmp = mat[i * size + j]; 00046 mat[i * size + j] = mat[j * size + i]; 00047 mat[j * size + i] = tmp; 00048 } 00049 } 00050 } 00051 00052 template<typename Real> 00053 void printfVector(Real* ptr, 00054 int length) { 00055 fprintf(stderr, "[ %1.5e", ptr[0]); 00056 int i; 00057 for (i = 1; i < length; i++) 00058 fprintf(stderr, " %1.5e", ptr[i]); 00059 fprintf(stderr, " ]\n"); 00060 } 00061 00062 void printfInt(int* ptr, 00063 int length); 00064 00065 #endif // __GPUImplHelper__