diff --git a/msbuild/kaldi.props b/msbuild/kaldi.props index 46cdc61fa15..77985715f47 100755 --- a/msbuild/kaldi.props +++ b/msbuild/kaldi.props @@ -26,12 +26,12 @@ Disabled Level3 - WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + WIN32;_CONSOLE;_LIB;%(PreprocessorDefinitions) false false $(KaldiCpuInstructionSet) None - true + false ProgramDatabase true @@ -125,6 +125,30 @@ + + + $(VCTargetsPath)/BuildCustomizations + 65 + + + + + + + + + + compute_20,sm_20;compute_30,sm_30;compute_35,sm_35;compute_37,sm_37;compute_50,sm_50; + + + + HAVE_CUDA;%(PreprocessorDefinitions) + + + cublas.lib;cusparse.lib;cudart_static.lib;cuda.lib;%(AdditionalDependencies) + + + diff --git a/msbuild/kaldi.targets b/msbuild/kaldi.targets index 8f6550567a6..426426d7b6a 100755 --- a/msbuild/kaldi.targets +++ b/msbuild/kaldi.targets @@ -6,6 +6,8 @@ Text="Invalid BuildStage. Are you running the top-level build project?"/> + @@ -47,14 +49,22 @@ --> + + + + $(ICInstallDir)bin\ia32\icl.exe + -ccbin "%(CudaCompile.VCBinDir)" [GenerateRelocatableDeviceCode] [Include] [RequiredIncludes] [CInterleavedPTX] [GPUDebugInfo] [GenerateLineInfo] [Keep] [KeepDir] [MaxRegCount] [PtxAsOptionV] [TargetMachinePlatform] [NvccCompilation] [CudaRuntime] [AdditionalOptions] + %(CudaCompile.BaseCommandLineTemplate) [HostDebugInfo] [Emulation] [FastMath] [Defines] %(CudaCompile.HostCommandLineTemplate) [CompileOut] "%(CudaCompile.FullPath)" + + - - + + @@ -97,4 +107,5 @@ + diff --git a/src/base/kaldi-utils.h b/src/base/kaldi-utils.h index 1b2c893b8d6..2c356eaa6bd 100644 --- a/src/base/kaldi-utils.h +++ b/src/base/kaldi-utils.h @@ -30,9 +30,12 @@ # include #endif +#if _MSC_VER < 1400 +#define __restrict__ +#endif + #if defined(_MSC_VER) #pragma warning(disable: 4244 4056 4305 4800 4267 4996 4756 4661) -#define __restrict__ #endif #ifdef HAVE_POSIX_MEMALIGN diff --git a/src/cudamatrix/cu-device.cc b/src/cudamatrix/cu-device.cc index 37d20edf9b0..20cbd2ccaa3 100644 --- a/src/cudamatrix/cu-device.cc +++ b/src/cudamatrix/cu-device.cc @@ -30,13 +30,15 @@ #include #include #include +#ifndef _MSC_VER #include -#include // for sleep +#endif #include "cudamatrix/cu-common.h" #include "cudamatrix/cu-device.h" #include "cudamatrix/cu-matrix.h" #include "base/kaldi-error.h" +#include "base/kaldi-utils.h" #include "util/common-utils.h" namespace kaldi { @@ -105,7 +107,7 @@ void CuDevice::SelectGpuId(std::string use_gpu) { int32 sec_sleep = (use_gpu == "yes" ? 20 : 2); KALDI_WARN << "Will try again to get a GPU after " << sec_sleep << " seconds."; - sleep(sec_sleep); + Sleep(sec_sleep); cudaGetLastError(); // reset the error state e = cudaThreadSynchronize(); //<< 2nd trial to get CUDA context. if (e != cudaSuccess) { @@ -128,7 +130,7 @@ void CuDevice::SelectGpuId(std::string use_gpu) { << " seconds to get a GPU."; num_times++; wait_time += sec_sleep; - sleep(sec_sleep); + Sleep(sec_sleep); cudaGetLastError(); // reset the error state e = cudaThreadSynchronize(); } @@ -377,6 +379,9 @@ std::string CuDevice::GetFreeMemory(int64* free, int64* total) const { //pre-fill ``safe'' values that will not cause problems mem_free = 1; mem_total = 1; //open libcuda.so +#ifdef _MSC_VER + cuMemGetInfo(&mem_free, &mem_total); +#else void* libcuda = dlopen("libcuda.so",RTLD_LAZY); if(NULL == libcuda) { KALDI_WARN << "cannot open libcuda.so"; @@ -399,6 +404,7 @@ std::string CuDevice::GetFreeMemory(int64* free, int64* total) const { //close the library dlclose(libcuda); } +#endif } // copy the output values outside if(NULL != free) *free = mem_free; @@ -416,6 +422,9 @@ std::string CuDevice::GetFreeMemory(int64* free, int64* total) const { void CuDevice::DeviceGetName(char* name, int32 len, int32 dev) { //prefill with something reasonable strncpy(name,"Unknown GPU",len); +#ifdef _MSC_VER + cuDeviceGetName(name, len, dev); +#else //open libcuda.so void* libcuda = dlopen("libcuda.so",RTLD_LAZY); if(NULL == libcuda) { @@ -434,6 +443,7 @@ void CuDevice::DeviceGetName(char* name, int32 len, int32 dev) { //close the library dlclose(libcuda); } +#endif } diff --git a/src/cudamatrix/cu-matrix-speed-test.cc b/src/cudamatrix/cu-matrix-speed-test.cc index ce2cbcc5f12..8cb5d338dcf 100644 --- a/src/cudamatrix/cu-matrix-speed-test.cc +++ b/src/cudamatrix/cu-matrix-speed-test.cc @@ -519,7 +519,7 @@ template void CudaMatrixSpeedTest() { int main() { - for (int32 loop = 1; loop < 2; loop++) { + for (int32 loop = 0; loop < 2; loop++) { #if HAVE_CUDA == 1 if (loop == 0) CuDevice::Instantiate().SelectGpuId("no"); diff --git a/src/util/kaldi-io-test.cc b/src/util/kaldi-io-test.cc index 22740cde650..fb693c9565f 100644 --- a/src/util/kaldi-io-test.cc +++ b/src/util/kaldi-io-test.cc @@ -161,14 +161,9 @@ void UnitTestIoNew(bool binary) { void UnitTestIoPipe(bool binary) { // This is as UnitTestIoNew except with different filenames. { -#ifdef _MSC_VER - const char *filename_out = "|more > tmpf.txt", - *filename_in = "type tmpf.txt |"; -#else const char *filename_out = "|gzip -c > tmpf.gz", *filename_in = "gunzip -c tmpf.gz |"; -#endif - + Output ko(filename_out, binary); std::ostream &outfile = ko.Stream(); if (!binary) outfile << "\t"; @@ -214,10 +209,6 @@ void UnitTestIoPipe(bool binary) { if (!binary && Rand()%2 == 0) outfile << "\t"; bool ans = ko.Close(); KALDI_ASSERT(ans); -#ifndef _MSC_VER - sleep(1); // This test does not work without this sleep: - // seems to be some kind of file-system latency. -#endif { bool binary_in; Input ki(filename_in, &binary_in);