From 6ad81eeea1e26f1842f56e399826b80ad6694bd8 Mon Sep 17 00:00:00 2001 From: Aleksandrs Pavlenko Date: Thu, 6 Dec 2018 13:34:11 +0200 Subject: [PATCH 01/21] added Visual Studio solution that become a basis for next changes --- .gitignore | 340 ++++++++++++++++++ kmcudaVS/kmcudaCUDA9.2/kernel.cu | 121 +++++++ kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj | 86 +++++ kmcudaVS/kmcudaCore/kmcudaCore.vcxproj | 164 +++++++++ .../kmcudaCore/kmcudaCore.vcxproj.filters | 30 ++ kmcudaVS/kmcudaCore/stdafx.cpp | 1 + kmcudaVS/kmcudaCore/stdafx.h | 14 + kmcudaVS/kmcudaCore/targetver.h | 8 + kmcudaVS/kmcudaVS.sln | 39 ++ 9 files changed, 803 insertions(+) create mode 100644 kmcudaVS/kmcudaCUDA9.2/kernel.cu create mode 100644 kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj create mode 100644 kmcudaVS/kmcudaCore/kmcudaCore.vcxproj create mode 100644 kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters create mode 100644 kmcudaVS/kmcudaCore/stdafx.cpp create mode 100644 kmcudaVS/kmcudaCore/stdafx.h create mode 100644 kmcudaVS/kmcudaCore/targetver.h create mode 100644 kmcudaVS/kmcudaVS.sln diff --git a/.gitignore b/.gitignore index 5323a25..2090057 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,343 @@ cmake-build-* *.exe *.out *.app + + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ +# ASP.NET Core default setup: bower directory is configured as wwwroot/lib/ and bower restore is true +**/wwwroot/lib/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ \ No newline at end of file diff --git a/kmcudaVS/kmcudaCUDA9.2/kernel.cu b/kmcudaVS/kmcudaCUDA9.2/kernel.cu new file mode 100644 index 0000000..90d489d --- /dev/null +++ b/kmcudaVS/kmcudaCUDA9.2/kernel.cu @@ -0,0 +1,121 @@ + +#include "cuda_runtime.h" +#include "device_launch_parameters.h" + +#include + +cudaError_t addWithCuda(int *c, const int *a, const int *b, unsigned int size); + +__global__ void addKernel(int *c, const int *a, const int *b) +{ + int i = threadIdx.x; + c[i] = a[i] + b[i]; +} + +int main() +{ + const int arraySize = 5; + const int a[arraySize] = { 1, 2, 3, 4, 5 }; + const int b[arraySize] = { 10, 20, 30, 40, 50 }; + int c[arraySize] = { 0 }; + + // Add vectors in parallel. + cudaError_t cudaStatus = addWithCuda(c, a, b, arraySize); + if (cudaStatus != cudaSuccess) { + fprintf(stderr, "addWithCuda failed!"); + return 1; + } + + printf("{1,2,3,4,5} + {10,20,30,40,50} = {%d,%d,%d,%d,%d}\n", + c[0], c[1], c[2], c[3], c[4]); + + // cudaDeviceReset must be called before exiting in order for profiling and + // tracing tools such as Nsight and Visual Profiler to show complete traces. + cudaStatus = cudaDeviceReset(); + if (cudaStatus != cudaSuccess) { + fprintf(stderr, "cudaDeviceReset failed!"); + return 1; + } + + return 0; +} + +// Helper function for using CUDA to add vectors in parallel. +cudaError_t addWithCuda(int *c, const int *a, const int *b, unsigned int size) +{ + int *dev_a = 0; + int *dev_b = 0; + int *dev_c = 0; + cudaError_t cudaStatus; + + // Choose which GPU to run on, change this on a multi-GPU system. + cudaStatus = cudaSetDevice(0); + if (cudaStatus != cudaSuccess) { + fprintf(stderr, "cudaSetDevice failed! Do you have a CUDA-capable GPU installed?"); + goto Error; + } + + // Allocate GPU buffers for three vectors (two input, one output) . + cudaStatus = cudaMalloc((void**)&dev_c, size * sizeof(int)); + if (cudaStatus != cudaSuccess) { + fprintf(stderr, "cudaMalloc failed!"); + goto Error; + } + + cudaStatus = cudaMalloc((void**)&dev_a, size * sizeof(int)); + if (cudaStatus != cudaSuccess) { + fprintf(stderr, "cudaMalloc failed!"); + goto Error; + } + + cudaStatus = cudaMalloc((void**)&dev_b, size * sizeof(int)); + if (cudaStatus != cudaSuccess) { + fprintf(stderr, "cudaMalloc failed!"); + goto Error; + } + + // Copy input vectors from host memory to GPU buffers. + cudaStatus = cudaMemcpy(dev_a, a, size * sizeof(int), cudaMemcpyHostToDevice); + if (cudaStatus != cudaSuccess) { + fprintf(stderr, "cudaMemcpy failed!"); + goto Error; + } + + cudaStatus = cudaMemcpy(dev_b, b, size * sizeof(int), cudaMemcpyHostToDevice); + if (cudaStatus != cudaSuccess) { + fprintf(stderr, "cudaMemcpy failed!"); + goto Error; + } + + // Launch a kernel on the GPU with one thread for each element. + addKernel<<<1, size>>>(dev_c, dev_a, dev_b); + + // Check for any errors launching the kernel + cudaStatus = cudaGetLastError(); + if (cudaStatus != cudaSuccess) { + fprintf(stderr, "addKernel launch failed: %s\n", cudaGetErrorString(cudaStatus)); + goto Error; + } + + // cudaDeviceSynchronize waits for the kernel to finish, and returns + // any errors encountered during the launch. + cudaStatus = cudaDeviceSynchronize(); + if (cudaStatus != cudaSuccess) { + fprintf(stderr, "cudaDeviceSynchronize returned error code %d after launching addKernel!\n", cudaStatus); + goto Error; + } + + // Copy output vector from GPU buffer to host memory. + cudaStatus = cudaMemcpy(c, dev_c, size * sizeof(int), cudaMemcpyDeviceToHost); + if (cudaStatus != cudaSuccess) { + fprintf(stderr, "cudaMemcpy failed!"); + goto Error; + } + +Error: + cudaFree(dev_c); + cudaFree(dev_a); + cudaFree(dev_b); + + return cudaStatus; +} diff --git a/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj b/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj new file mode 100644 index 0000000..222666f --- /dev/null +++ b/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj @@ -0,0 +1,86 @@ + + + + + Debug + x64 + + + Release + x64 + + + + {6EAF493C-6099-4E01-A7EB-8A357791C6D3} + kmcudaCUDA9_2 + + + + Application + true + MultiByte + v141 + + + Application + false + true + MultiByte + v141 + + + + + + + + + + + + + + true + + + + Level3 + Disabled + WIN32;WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + true + Console + cudart_static.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + 64 + + + + + Level3 + MaxSpeed + true + true + WIN32;WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + true + true + true + Console + cudart_static.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + 64 + + + + + + + + + + \ No newline at end of file diff --git a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj new file mode 100644 index 0000000..27cfff3 --- /dev/null +++ b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj @@ -0,0 +1,164 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {D9C22C15-38FA-40C8-9B1C-E3097321F70B} + Win32Proj + kmcudaCore + 10.0.17763.0 + + + + StaticLibrary + true + v141 + Unicode + + + StaticLibrary + false + v141 + true + Unicode + + + StaticLibrary + true + v141 + Unicode + + + StaticLibrary + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + Disabled + true + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Use + Level3 + Disabled + true + _DEBUG;_LIB;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Use + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + Use + Level3 + MaxSpeed + true + true + true + NDEBUG;_LIB;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + + + + + Create + Create + Create + Create + + + + + + \ No newline at end of file diff --git a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters new file mode 100644 index 0000000..782ac4b --- /dev/null +++ b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + + + Source Files + + + \ No newline at end of file diff --git a/kmcudaVS/kmcudaCore/stdafx.cpp b/kmcudaVS/kmcudaCore/stdafx.cpp new file mode 100644 index 0000000..fd4f341 --- /dev/null +++ b/kmcudaVS/kmcudaCore/stdafx.cpp @@ -0,0 +1 @@ +#include "stdafx.h" diff --git a/kmcudaVS/kmcudaCore/stdafx.h b/kmcudaVS/kmcudaCore/stdafx.h new file mode 100644 index 0000000..69f8872 --- /dev/null +++ b/kmcudaVS/kmcudaCore/stdafx.h @@ -0,0 +1,14 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#include "targetver.h" + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + + + +// reference additional headers your program requires here diff --git a/kmcudaVS/kmcudaCore/targetver.h b/kmcudaVS/kmcudaCore/targetver.h new file mode 100644 index 0000000..87c0086 --- /dev/null +++ b/kmcudaVS/kmcudaCore/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// Including SDKDDKVer.h defines the highest available Windows platform. + +// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and +// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. + +#include diff --git a/kmcudaVS/kmcudaVS.sln b/kmcudaVS/kmcudaVS.sln new file mode 100644 index 0000000..3da1b59 --- /dev/null +++ b/kmcudaVS/kmcudaVS.sln @@ -0,0 +1,39 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.136 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kmcudaCore", "kmcudaCore\kmcudaCore.vcxproj", "{D9C22C15-38FA-40C8-9B1C-E3097321F70B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kmcudaCUDA9.2", "kmcudaCUDA9.2\kmcudaCUDA9.2.vcxproj", "{6EAF493C-6099-4E01-A7EB-8A357791C6D3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D9C22C15-38FA-40C8-9B1C-E3097321F70B}.Debug|x64.ActiveCfg = Debug|x64 + {D9C22C15-38FA-40C8-9B1C-E3097321F70B}.Debug|x64.Build.0 = Debug|x64 + {D9C22C15-38FA-40C8-9B1C-E3097321F70B}.Debug|x86.ActiveCfg = Debug|Win32 + {D9C22C15-38FA-40C8-9B1C-E3097321F70B}.Debug|x86.Build.0 = Debug|Win32 + {D9C22C15-38FA-40C8-9B1C-E3097321F70B}.Release|x64.ActiveCfg = Release|x64 + {D9C22C15-38FA-40C8-9B1C-E3097321F70B}.Release|x64.Build.0 = Release|x64 + {D9C22C15-38FA-40C8-9B1C-E3097321F70B}.Release|x86.ActiveCfg = Release|Win32 + {D9C22C15-38FA-40C8-9B1C-E3097321F70B}.Release|x86.Build.0 = Release|Win32 + {6EAF493C-6099-4E01-A7EB-8A357791C6D3}.Debug|x64.ActiveCfg = Debug|x64 + {6EAF493C-6099-4E01-A7EB-8A357791C6D3}.Debug|x64.Build.0 = Debug|x64 + {6EAF493C-6099-4E01-A7EB-8A357791C6D3}.Debug|x86.ActiveCfg = Debug|x64 + {6EAF493C-6099-4E01-A7EB-8A357791C6D3}.Release|x64.ActiveCfg = Release|x64 + {6EAF493C-6099-4E01-A7EB-8A357791C6D3}.Release|x64.Build.0 = Release|x64 + {6EAF493C-6099-4E01-A7EB-8A357791C6D3}.Release|x86.ActiveCfg = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {AAC44696-CE91-4B13-A6F8-2602E58CA144} + EndGlobalSection +EndGlobal From 4a5d640e055eaed6ad5f635b420ed246f454a4fb Mon Sep 17 00:00:00 2001 From: Aleksandrs Pavlenko Date: Thu, 6 Dec 2018 13:42:06 +0200 Subject: [PATCH 02/21] rearrenged files to correct projects --- kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj | 7 +++++- kmcudaVS/kmcudaCore/kmcudaCore.vcxproj | 22 +++++++++---------- .../kmcudaCore/kmcudaCore.vcxproj.filters | 15 ++++++++++--- kmcudaVS/kmcudaCore/stdafx.cpp | 1 - kmcudaVS/kmcudaCore/stdafx.h | 14 ------------ kmcudaVS/kmcudaCore/targetver.h | 8 ------- 6 files changed, 28 insertions(+), 39 deletions(-) delete mode 100644 kmcudaVS/kmcudaCore/stdafx.cpp delete mode 100644 kmcudaVS/kmcudaCore/stdafx.h delete mode 100644 kmcudaVS/kmcudaCore/targetver.h diff --git a/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj b/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj index 222666f..348d2c4 100644 --- a/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj +++ b/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj @@ -77,7 +77,12 @@ - + + + + + + diff --git a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj index 27cfff3..21ef163 100644 --- a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj +++ b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj @@ -18,6 +18,16 @@ x64 + + + + + + + + + + 15.0 {D9C22C15-38FA-40C8-9B1C-E3097321F70B} @@ -146,18 +156,6 @@ true - - - - - - - Create - Create - Create - Create - - diff --git a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters index 782ac4b..8356e63 100644 --- a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters +++ b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters @@ -15,15 +15,24 @@ - + Header Files - + + Header Files + + + Header Files + + + Header Files + + Header Files - + Source Files diff --git a/kmcudaVS/kmcudaCore/stdafx.cpp b/kmcudaVS/kmcudaCore/stdafx.cpp deleted file mode 100644 index fd4f341..0000000 --- a/kmcudaVS/kmcudaCore/stdafx.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "stdafx.h" diff --git a/kmcudaVS/kmcudaCore/stdafx.h b/kmcudaVS/kmcudaCore/stdafx.h deleted file mode 100644 index 69f8872..0000000 --- a/kmcudaVS/kmcudaCore/stdafx.h +++ /dev/null @@ -1,14 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include "targetver.h" - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - - - -// reference additional headers your program requires here diff --git a/kmcudaVS/kmcudaCore/targetver.h b/kmcudaVS/kmcudaCore/targetver.h deleted file mode 100644 index 87c0086..0000000 --- a/kmcudaVS/kmcudaCore/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include From 2f79ba5c107e1b12b832b791f8068d0a40edf88e Mon Sep 17 00:00:00 2001 From: Aleksandrs Pavlenko Date: Thu, 6 Dec 2018 14:07:03 +0200 Subject: [PATCH 03/21] solution reorganization --- kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj | 6 +++++- .../kmcudaCUDA9.2.vcxproj.filters | 19 +++++++++++++++++++ kmcudaVS/kmcudaCore/kmcudaCore.vcxproj | 2 -- .../kmcudaCore/kmcudaCore.vcxproj.filters | 6 ------ 4 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj.filters diff --git a/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj b/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj index 348d2c4..f587d30 100644 --- a/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj +++ b/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj @@ -13,10 +13,11 @@ {6EAF493C-6099-4E01-A7EB-8A357791C6D3} kmcudaCUDA9_2 + 8.1 - Application + DynamicLibrary true MultiByte v141 @@ -55,6 +56,7 @@ 64 + compute_60,sm_60;%(CodeGeneration) @@ -82,6 +84,8 @@ + + diff --git a/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj.filters b/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj.filters new file mode 100644 index 0000000..c11a3d8 --- /dev/null +++ b/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj.filters @@ -0,0 +1,19 @@ + + + + + {1d26e331-f993-4ab8-ab7d-76524a2e421a} + + + + + Headers + + + Headers + + + Headers + + + \ No newline at end of file diff --git a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj index 21ef163..3424e69 100644 --- a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj +++ b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj @@ -21,8 +21,6 @@ - - diff --git a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters index 8356e63..9edad2b 100644 --- a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters +++ b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters @@ -21,12 +21,6 @@ Header Files - - Header Files - - - Header Files - Header Files From 0feeb607bec807b47a9d5bbd75b4a75f91de06e2 Mon Sep 17 00:00:00 2001 From: Aleksandrs Pavlenko Date: Thu, 6 Dec 2018 14:08:31 +0200 Subject: [PATCH 04/21] solution reorganization --- kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj | 1 + kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj.filters | 3 +++ kmcudaVS/kmcudaCore/kmcudaCore.vcxproj | 1 - kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters | 3 --- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj b/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj index f587d30..593b4f6 100644 --- a/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj +++ b/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj @@ -84,6 +84,7 @@ + diff --git a/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj.filters b/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj.filters index c11a3d8..46c4b51 100644 --- a/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj.filters +++ b/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj.filters @@ -15,5 +15,8 @@ Headers + + Headers + \ No newline at end of file diff --git a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj index 3424e69..68f0080 100644 --- a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj +++ b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj @@ -19,7 +19,6 @@ - diff --git a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters index 9edad2b..a3814de 100644 --- a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters +++ b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters @@ -15,9 +15,6 @@ - - Header Files - Header Files From 229b4949e3a16d2eb453600e7f0c90ca8caea486 Mon Sep 17 00:00:00 2001 From: Aleksandrs Pavlenko Date: Thu, 6 Dec 2018 14:34:08 +0200 Subject: [PATCH 05/21] Revert "solution reorganization" This reverts commit 0feeb607bec807b47a9d5bbd75b4a75f91de06e2. --- kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj | 1 - kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj.filters | 3 --- kmcudaVS/kmcudaCore/kmcudaCore.vcxproj | 1 + kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters | 3 +++ 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj b/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj index 593b4f6..f587d30 100644 --- a/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj +++ b/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj @@ -84,7 +84,6 @@ - diff --git a/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj.filters b/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj.filters index 46c4b51..c11a3d8 100644 --- a/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj.filters +++ b/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj.filters @@ -15,8 +15,5 @@ Headers - - Headers - \ No newline at end of file diff --git a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj index 68f0080..3424e69 100644 --- a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj +++ b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj @@ -19,6 +19,7 @@ + diff --git a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters index a3814de..9edad2b 100644 --- a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters +++ b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters @@ -15,6 +15,9 @@ + + Header Files + Header Files From a63db999a385e0ee2aa22e5b051a5418516cbe12 Mon Sep 17 00:00:00 2001 From: Aleksandrs Pavlenko Date: Thu, 6 Dec 2018 14:34:30 +0200 Subject: [PATCH 06/21] Revert "solution reorganization" This reverts commit 2f79ba5c107e1b12b832b791f8068d0a40edf88e. --- kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj | 6 +----- .../kmcudaCUDA9.2.vcxproj.filters | 19 ------------------- kmcudaVS/kmcudaCore/kmcudaCore.vcxproj | 2 ++ .../kmcudaCore/kmcudaCore.vcxproj.filters | 6 ++++++ 4 files changed, 9 insertions(+), 24 deletions(-) delete mode 100644 kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj.filters diff --git a/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj b/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj index f587d30..348d2c4 100644 --- a/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj +++ b/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj @@ -13,11 +13,10 @@ {6EAF493C-6099-4E01-A7EB-8A357791C6D3} kmcudaCUDA9_2 - 8.1 - DynamicLibrary + Application true MultiByte v141 @@ -56,7 +55,6 @@ 64 - compute_60,sm_60;%(CodeGeneration) @@ -84,8 +82,6 @@ - - diff --git a/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj.filters b/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj.filters deleted file mode 100644 index c11a3d8..0000000 --- a/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj.filters +++ /dev/null @@ -1,19 +0,0 @@ - - - - - {1d26e331-f993-4ab8-ab7d-76524a2e421a} - - - - - Headers - - - Headers - - - Headers - - - \ No newline at end of file diff --git a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj index 3424e69..21ef163 100644 --- a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj +++ b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj @@ -21,6 +21,8 @@ + + diff --git a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters index 9edad2b..8356e63 100644 --- a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters +++ b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters @@ -21,6 +21,12 @@ Header Files + + Header Files + + + Header Files + Header Files From ace13d795db7cb42aac15aac3beab8dce75d8e39 Mon Sep 17 00:00:00 2001 From: Aleksandrs Pavlenko Date: Thu, 6 Dec 2018 14:35:06 +0200 Subject: [PATCH 07/21] Revert "rearrenged files to correct projects" This reverts commit 4a5d640e055eaed6ad5f635b420ed246f454a4fb. --- kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj | 7 +----- kmcudaVS/kmcudaCore/kmcudaCore.vcxproj | 22 ++++++++++--------- .../kmcudaCore/kmcudaCore.vcxproj.filters | 15 +++---------- kmcudaVS/kmcudaCore/stdafx.cpp | 1 + kmcudaVS/kmcudaCore/stdafx.h | 14 ++++++++++++ kmcudaVS/kmcudaCore/targetver.h | 8 +++++++ 6 files changed, 39 insertions(+), 28 deletions(-) create mode 100644 kmcudaVS/kmcudaCore/stdafx.cpp create mode 100644 kmcudaVS/kmcudaCore/stdafx.h create mode 100644 kmcudaVS/kmcudaCore/targetver.h diff --git a/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj b/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj index 348d2c4..222666f 100644 --- a/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj +++ b/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj @@ -77,12 +77,7 @@ - - - - - - + diff --git a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj index 21ef163..27cfff3 100644 --- a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj +++ b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj @@ -18,16 +18,6 @@ x64 - - - - - - - - - - 15.0 {D9C22C15-38FA-40C8-9B1C-E3097321F70B} @@ -156,6 +146,18 @@ true + + + + + + + Create + Create + Create + Create + + diff --git a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters index 8356e63..782ac4b 100644 --- a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters +++ b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters @@ -15,24 +15,15 @@ - + Header Files - - Header Files - - - Header Files - - - Header Files - - + Header Files - + Source Files diff --git a/kmcudaVS/kmcudaCore/stdafx.cpp b/kmcudaVS/kmcudaCore/stdafx.cpp new file mode 100644 index 0000000..fd4f341 --- /dev/null +++ b/kmcudaVS/kmcudaCore/stdafx.cpp @@ -0,0 +1 @@ +#include "stdafx.h" diff --git a/kmcudaVS/kmcudaCore/stdafx.h b/kmcudaVS/kmcudaCore/stdafx.h new file mode 100644 index 0000000..69f8872 --- /dev/null +++ b/kmcudaVS/kmcudaCore/stdafx.h @@ -0,0 +1,14 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#include "targetver.h" + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + + + +// reference additional headers your program requires here diff --git a/kmcudaVS/kmcudaCore/targetver.h b/kmcudaVS/kmcudaCore/targetver.h new file mode 100644 index 0000000..87c0086 --- /dev/null +++ b/kmcudaVS/kmcudaCore/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// Including SDKDDKVer.h defines the highest available Windows platform. + +// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and +// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. + +#include From ff01ede1c24d2a1246de568936dd0a7cffc63951 Mon Sep 17 00:00:00 2001 From: Aleksandrs Pavlenko Date: Thu, 6 Dec 2018 14:35:38 +0200 Subject: [PATCH 08/21] Revert "added Visual Studio solution that become a basis for next changes" This reverts commit 6ad81eeea1e26f1842f56e399826b80ad6694bd8. --- .gitignore | 340 ------------------ kmcudaVS/kmcudaCUDA9.2/kernel.cu | 121 ------- kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj | 86 ----- kmcudaVS/kmcudaCore/kmcudaCore.vcxproj | 164 --------- .../kmcudaCore/kmcudaCore.vcxproj.filters | 30 -- kmcudaVS/kmcudaCore/stdafx.cpp | 1 - kmcudaVS/kmcudaCore/stdafx.h | 14 - kmcudaVS/kmcudaCore/targetver.h | 8 - kmcudaVS/kmcudaVS.sln | 39 -- 9 files changed, 803 deletions(-) delete mode 100644 kmcudaVS/kmcudaCUDA9.2/kernel.cu delete mode 100644 kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj delete mode 100644 kmcudaVS/kmcudaCore/kmcudaCore.vcxproj delete mode 100644 kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters delete mode 100644 kmcudaVS/kmcudaCore/stdafx.cpp delete mode 100644 kmcudaVS/kmcudaCore/stdafx.h delete mode 100644 kmcudaVS/kmcudaCore/targetver.h delete mode 100644 kmcudaVS/kmcudaVS.sln diff --git a/.gitignore b/.gitignore index 2090057..5323a25 100644 --- a/.gitignore +++ b/.gitignore @@ -37,343 +37,3 @@ cmake-build-* *.exe *.out *.app - - -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - -# User-specific files -*.rsuser -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -[Aa][Rr][Mm]/ -[Aa][Rr][Mm]64/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_h.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*_wpftmp.csproj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ -# ASP.NET Core default setup: bower directory is configured as wwwroot/lib/ and bower restore is true -**/wwwroot/lib/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# JetBrains Rider -.idea/ -*.sln.iml - -# CodeRush personal settings -.cr/personal - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ - -# Local History for Visual Studio -.localhistory/ \ No newline at end of file diff --git a/kmcudaVS/kmcudaCUDA9.2/kernel.cu b/kmcudaVS/kmcudaCUDA9.2/kernel.cu deleted file mode 100644 index 90d489d..0000000 --- a/kmcudaVS/kmcudaCUDA9.2/kernel.cu +++ /dev/null @@ -1,121 +0,0 @@ - -#include "cuda_runtime.h" -#include "device_launch_parameters.h" - -#include - -cudaError_t addWithCuda(int *c, const int *a, const int *b, unsigned int size); - -__global__ void addKernel(int *c, const int *a, const int *b) -{ - int i = threadIdx.x; - c[i] = a[i] + b[i]; -} - -int main() -{ - const int arraySize = 5; - const int a[arraySize] = { 1, 2, 3, 4, 5 }; - const int b[arraySize] = { 10, 20, 30, 40, 50 }; - int c[arraySize] = { 0 }; - - // Add vectors in parallel. - cudaError_t cudaStatus = addWithCuda(c, a, b, arraySize); - if (cudaStatus != cudaSuccess) { - fprintf(stderr, "addWithCuda failed!"); - return 1; - } - - printf("{1,2,3,4,5} + {10,20,30,40,50} = {%d,%d,%d,%d,%d}\n", - c[0], c[1], c[2], c[3], c[4]); - - // cudaDeviceReset must be called before exiting in order for profiling and - // tracing tools such as Nsight and Visual Profiler to show complete traces. - cudaStatus = cudaDeviceReset(); - if (cudaStatus != cudaSuccess) { - fprintf(stderr, "cudaDeviceReset failed!"); - return 1; - } - - return 0; -} - -// Helper function for using CUDA to add vectors in parallel. -cudaError_t addWithCuda(int *c, const int *a, const int *b, unsigned int size) -{ - int *dev_a = 0; - int *dev_b = 0; - int *dev_c = 0; - cudaError_t cudaStatus; - - // Choose which GPU to run on, change this on a multi-GPU system. - cudaStatus = cudaSetDevice(0); - if (cudaStatus != cudaSuccess) { - fprintf(stderr, "cudaSetDevice failed! Do you have a CUDA-capable GPU installed?"); - goto Error; - } - - // Allocate GPU buffers for three vectors (two input, one output) . - cudaStatus = cudaMalloc((void**)&dev_c, size * sizeof(int)); - if (cudaStatus != cudaSuccess) { - fprintf(stderr, "cudaMalloc failed!"); - goto Error; - } - - cudaStatus = cudaMalloc((void**)&dev_a, size * sizeof(int)); - if (cudaStatus != cudaSuccess) { - fprintf(stderr, "cudaMalloc failed!"); - goto Error; - } - - cudaStatus = cudaMalloc((void**)&dev_b, size * sizeof(int)); - if (cudaStatus != cudaSuccess) { - fprintf(stderr, "cudaMalloc failed!"); - goto Error; - } - - // Copy input vectors from host memory to GPU buffers. - cudaStatus = cudaMemcpy(dev_a, a, size * sizeof(int), cudaMemcpyHostToDevice); - if (cudaStatus != cudaSuccess) { - fprintf(stderr, "cudaMemcpy failed!"); - goto Error; - } - - cudaStatus = cudaMemcpy(dev_b, b, size * sizeof(int), cudaMemcpyHostToDevice); - if (cudaStatus != cudaSuccess) { - fprintf(stderr, "cudaMemcpy failed!"); - goto Error; - } - - // Launch a kernel on the GPU with one thread for each element. - addKernel<<<1, size>>>(dev_c, dev_a, dev_b); - - // Check for any errors launching the kernel - cudaStatus = cudaGetLastError(); - if (cudaStatus != cudaSuccess) { - fprintf(stderr, "addKernel launch failed: %s\n", cudaGetErrorString(cudaStatus)); - goto Error; - } - - // cudaDeviceSynchronize waits for the kernel to finish, and returns - // any errors encountered during the launch. - cudaStatus = cudaDeviceSynchronize(); - if (cudaStatus != cudaSuccess) { - fprintf(stderr, "cudaDeviceSynchronize returned error code %d after launching addKernel!\n", cudaStatus); - goto Error; - } - - // Copy output vector from GPU buffer to host memory. - cudaStatus = cudaMemcpy(c, dev_c, size * sizeof(int), cudaMemcpyDeviceToHost); - if (cudaStatus != cudaSuccess) { - fprintf(stderr, "cudaMemcpy failed!"); - goto Error; - } - -Error: - cudaFree(dev_c); - cudaFree(dev_a); - cudaFree(dev_b); - - return cudaStatus; -} diff --git a/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj b/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj deleted file mode 100644 index 222666f..0000000 --- a/kmcudaVS/kmcudaCUDA9.2/kmcudaCUDA9.2.vcxproj +++ /dev/null @@ -1,86 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {6EAF493C-6099-4E01-A7EB-8A357791C6D3} - kmcudaCUDA9_2 - - - - Application - true - MultiByte - v141 - - - Application - false - true - MultiByte - v141 - - - - - - - - - - - - - - true - - - - Level3 - Disabled - WIN32;WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - - - true - Console - cudart_static.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - 64 - - - - - Level3 - MaxSpeed - true - true - WIN32;WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - - - true - true - true - Console - cudart_static.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - 64 - - - - - - - - - - \ No newline at end of file diff --git a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj deleted file mode 100644 index 27cfff3..0000000 --- a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj +++ /dev/null @@ -1,164 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {D9C22C15-38FA-40C8-9B1C-E3097321F70B} - Win32Proj - kmcudaCore - 10.0.17763.0 - - - - StaticLibrary - true - v141 - Unicode - - - StaticLibrary - false - v141 - true - Unicode - - - StaticLibrary - true - v141 - Unicode - - - StaticLibrary - false - v141 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - true - - - false - - - false - - - - Use - Level3 - Disabled - true - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - true - - - Windows - true - - - - - Use - Level3 - Disabled - true - _DEBUG;_LIB;%(PreprocessorDefinitions) - true - - - Windows - true - - - - - Use - Level3 - MaxSpeed - true - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - true - - - Windows - true - true - true - - - - - Use - Level3 - MaxSpeed - true - true - true - NDEBUG;_LIB;%(PreprocessorDefinitions) - true - - - Windows - true - true - true - - - - - - - - - Create - Create - Create - Create - - - - - - \ No newline at end of file diff --git a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters b/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters deleted file mode 100644 index 782ac4b..0000000 --- a/kmcudaVS/kmcudaCore/kmcudaCore.vcxproj.filters +++ /dev/null @@ -1,30 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Header Files - - - Header Files - - - - - Source Files - - - \ No newline at end of file diff --git a/kmcudaVS/kmcudaCore/stdafx.cpp b/kmcudaVS/kmcudaCore/stdafx.cpp deleted file mode 100644 index fd4f341..0000000 --- a/kmcudaVS/kmcudaCore/stdafx.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "stdafx.h" diff --git a/kmcudaVS/kmcudaCore/stdafx.h b/kmcudaVS/kmcudaCore/stdafx.h deleted file mode 100644 index 69f8872..0000000 --- a/kmcudaVS/kmcudaCore/stdafx.h +++ /dev/null @@ -1,14 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include "targetver.h" - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - - - -// reference additional headers your program requires here diff --git a/kmcudaVS/kmcudaCore/targetver.h b/kmcudaVS/kmcudaCore/targetver.h deleted file mode 100644 index 87c0086..0000000 --- a/kmcudaVS/kmcudaCore/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include diff --git a/kmcudaVS/kmcudaVS.sln b/kmcudaVS/kmcudaVS.sln deleted file mode 100644 index 3da1b59..0000000 --- a/kmcudaVS/kmcudaVS.sln +++ /dev/null @@ -1,39 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.136 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kmcudaCore", "kmcudaCore\kmcudaCore.vcxproj", "{D9C22C15-38FA-40C8-9B1C-E3097321F70B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kmcudaCUDA9.2", "kmcudaCUDA9.2\kmcudaCUDA9.2.vcxproj", "{6EAF493C-6099-4E01-A7EB-8A357791C6D3}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D9C22C15-38FA-40C8-9B1C-E3097321F70B}.Debug|x64.ActiveCfg = Debug|x64 - {D9C22C15-38FA-40C8-9B1C-E3097321F70B}.Debug|x64.Build.0 = Debug|x64 - {D9C22C15-38FA-40C8-9B1C-E3097321F70B}.Debug|x86.ActiveCfg = Debug|Win32 - {D9C22C15-38FA-40C8-9B1C-E3097321F70B}.Debug|x86.Build.0 = Debug|Win32 - {D9C22C15-38FA-40C8-9B1C-E3097321F70B}.Release|x64.ActiveCfg = Release|x64 - {D9C22C15-38FA-40C8-9B1C-E3097321F70B}.Release|x64.Build.0 = Release|x64 - {D9C22C15-38FA-40C8-9B1C-E3097321F70B}.Release|x86.ActiveCfg = Release|Win32 - {D9C22C15-38FA-40C8-9B1C-E3097321F70B}.Release|x86.Build.0 = Release|Win32 - {6EAF493C-6099-4E01-A7EB-8A357791C6D3}.Debug|x64.ActiveCfg = Debug|x64 - {6EAF493C-6099-4E01-A7EB-8A357791C6D3}.Debug|x64.Build.0 = Debug|x64 - {6EAF493C-6099-4E01-A7EB-8A357791C6D3}.Debug|x86.ActiveCfg = Debug|x64 - {6EAF493C-6099-4E01-A7EB-8A357791C6D3}.Release|x64.ActiveCfg = Release|x64 - {6EAF493C-6099-4E01-A7EB-8A357791C6D3}.Release|x64.Build.0 = Release|x64 - {6EAF493C-6099-4E01-A7EB-8A357791C6D3}.Release|x86.ActiveCfg = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {AAC44696-CE91-4B13-A6F8-2602E58CA144} - EndGlobalSection -EndGlobal From 3f941919822f93903cbcd0edae464981148f5958 Mon Sep 17 00:00:00 2001 From: Aleksandrs Pavlenko Date: Thu, 6 Dec 2018 14:54:22 +0200 Subject: [PATCH 09/21] added solution to support further changes --- .gitattributes | 63 ++++ .gitignore | 340 ++++++++++++++++++ kmcudaWinVS/kmcudaCore/kernel.cu | 121 +++++++ kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj | 103 ++++++ .../kmcudaCore/kmcudaCore.vcxproj.filters | 51 +++ kmcudaWinVS/kmcudaWinVS.sln | 25 ++ 6 files changed, 703 insertions(+) create mode 100644 .gitattributes create mode 100644 kmcudaWinVS/kmcudaCore/kernel.cu create mode 100644 kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj create mode 100644 kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj.filters create mode 100644 kmcudaWinVS/kmcudaWinVS.sln diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore index 5323a25..cd26df3 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,343 @@ cmake-build-* *.exe *.out *.app + + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ +# ASP.NET Core default setup: bower directory is configured as wwwroot/lib/ and bower restore is true +**/wwwroot/lib/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ diff --git a/kmcudaWinVS/kmcudaCore/kernel.cu b/kmcudaWinVS/kmcudaCore/kernel.cu new file mode 100644 index 0000000..90d489d --- /dev/null +++ b/kmcudaWinVS/kmcudaCore/kernel.cu @@ -0,0 +1,121 @@ + +#include "cuda_runtime.h" +#include "device_launch_parameters.h" + +#include + +cudaError_t addWithCuda(int *c, const int *a, const int *b, unsigned int size); + +__global__ void addKernel(int *c, const int *a, const int *b) +{ + int i = threadIdx.x; + c[i] = a[i] + b[i]; +} + +int main() +{ + const int arraySize = 5; + const int a[arraySize] = { 1, 2, 3, 4, 5 }; + const int b[arraySize] = { 10, 20, 30, 40, 50 }; + int c[arraySize] = { 0 }; + + // Add vectors in parallel. + cudaError_t cudaStatus = addWithCuda(c, a, b, arraySize); + if (cudaStatus != cudaSuccess) { + fprintf(stderr, "addWithCuda failed!"); + return 1; + } + + printf("{1,2,3,4,5} + {10,20,30,40,50} = {%d,%d,%d,%d,%d}\n", + c[0], c[1], c[2], c[3], c[4]); + + // cudaDeviceReset must be called before exiting in order for profiling and + // tracing tools such as Nsight and Visual Profiler to show complete traces. + cudaStatus = cudaDeviceReset(); + if (cudaStatus != cudaSuccess) { + fprintf(stderr, "cudaDeviceReset failed!"); + return 1; + } + + return 0; +} + +// Helper function for using CUDA to add vectors in parallel. +cudaError_t addWithCuda(int *c, const int *a, const int *b, unsigned int size) +{ + int *dev_a = 0; + int *dev_b = 0; + int *dev_c = 0; + cudaError_t cudaStatus; + + // Choose which GPU to run on, change this on a multi-GPU system. + cudaStatus = cudaSetDevice(0); + if (cudaStatus != cudaSuccess) { + fprintf(stderr, "cudaSetDevice failed! Do you have a CUDA-capable GPU installed?"); + goto Error; + } + + // Allocate GPU buffers for three vectors (two input, one output) . + cudaStatus = cudaMalloc((void**)&dev_c, size * sizeof(int)); + if (cudaStatus != cudaSuccess) { + fprintf(stderr, "cudaMalloc failed!"); + goto Error; + } + + cudaStatus = cudaMalloc((void**)&dev_a, size * sizeof(int)); + if (cudaStatus != cudaSuccess) { + fprintf(stderr, "cudaMalloc failed!"); + goto Error; + } + + cudaStatus = cudaMalloc((void**)&dev_b, size * sizeof(int)); + if (cudaStatus != cudaSuccess) { + fprintf(stderr, "cudaMalloc failed!"); + goto Error; + } + + // Copy input vectors from host memory to GPU buffers. + cudaStatus = cudaMemcpy(dev_a, a, size * sizeof(int), cudaMemcpyHostToDevice); + if (cudaStatus != cudaSuccess) { + fprintf(stderr, "cudaMemcpy failed!"); + goto Error; + } + + cudaStatus = cudaMemcpy(dev_b, b, size * sizeof(int), cudaMemcpyHostToDevice); + if (cudaStatus != cudaSuccess) { + fprintf(stderr, "cudaMemcpy failed!"); + goto Error; + } + + // Launch a kernel on the GPU with one thread for each element. + addKernel<<<1, size>>>(dev_c, dev_a, dev_b); + + // Check for any errors launching the kernel + cudaStatus = cudaGetLastError(); + if (cudaStatus != cudaSuccess) { + fprintf(stderr, "addKernel launch failed: %s\n", cudaGetErrorString(cudaStatus)); + goto Error; + } + + // cudaDeviceSynchronize waits for the kernel to finish, and returns + // any errors encountered during the launch. + cudaStatus = cudaDeviceSynchronize(); + if (cudaStatus != cudaSuccess) { + fprintf(stderr, "cudaDeviceSynchronize returned error code %d after launching addKernel!\n", cudaStatus); + goto Error; + } + + // Copy output vector from GPU buffer to host memory. + cudaStatus = cudaMemcpy(c, dev_c, size * sizeof(int), cudaMemcpyDeviceToHost); + if (cudaStatus != cudaSuccess) { + fprintf(stderr, "cudaMemcpy failed!"); + goto Error; + } + +Error: + cudaFree(dev_c); + cudaFree(dev_a); + cudaFree(dev_b); + + return cudaStatus; +} diff --git a/kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj b/kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj new file mode 100644 index 0000000..a98551d --- /dev/null +++ b/kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj @@ -0,0 +1,103 @@ + + + + + Debug + x64 + + + Release + x64 + + + + {628BF41E-BC0A-4FFB-BC5A-BA88A9AEB055} + kmcudaCore + 10.0.17763.0 + + + + StaticLibrary + true + MultiByte + v140 + + + StaticLibrary + false + true + MultiByte + v140 + + + + + + + + + + + + + + true + + + + Level3 + Disabled + WIN32;WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + true + Console + cudart_static.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + 64 + compute_60,sm_60;%(CodeGeneration) + + + + + Level3 + MaxSpeed + true + true + WIN32;WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + true + true + true + Console + cudart_static.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + 64 + compute_60,sm_60;%(CodeGeneration) + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj.filters b/kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj.filters new file mode 100644 index 0000000..533d383 --- /dev/null +++ b/kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj.filters @@ -0,0 +1,51 @@ + + + + + + CUDA files + + + CUDA files + + + CUDA files + + + + + {81809b38-8835-4c69-abd7-2880fe1ae2f8} + + + {8c5e4679-4969-4098-ab62-b8e94bed91ba} + + + {3dedfa35-1870-478f-9f6b-d0c4dd00e09d} + + + + + Header files + + + Header files + + + Header files + + + Header files + + + Header files + + + Header files + + + + + Source files + + + \ No newline at end of file diff --git a/kmcudaWinVS/kmcudaWinVS.sln b/kmcudaWinVS/kmcudaWinVS.sln new file mode 100644 index 0000000..435abb2 --- /dev/null +++ b/kmcudaWinVS/kmcudaWinVS.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.136 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kmcudaCore", "kmcudaCore\kmcudaCore.vcxproj", "{628BF41E-BC0A-4FFB-BC5A-BA88A9AEB055}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {628BF41E-BC0A-4FFB-BC5A-BA88A9AEB055}.Debug|x64.ActiveCfg = Release|x64 + {628BF41E-BC0A-4FFB-BC5A-BA88A9AEB055}.Debug|x64.Build.0 = Release|x64 + {628BF41E-BC0A-4FFB-BC5A-BA88A9AEB055}.Release|x64.ActiveCfg = Release|x64 + {628BF41E-BC0A-4FFB-BC5A-BA88A9AEB055}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1DDAC52A-68B6-4669-AFF2-5B7A7B50734B} + EndGlobalSection +EndGlobal From 88f8beb3ab023c11a8855ede866ae66a634110cd Mon Sep 17 00:00:00 2001 From: Aleksandrs Pavlenko Date: Thu, 6 Dec 2018 15:04:12 +0200 Subject: [PATCH 10/21] added fix for blockIdx being an invalid identifier --- src/kmcuda.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/kmcuda.h b/src/kmcuda.h index 8b013b9..72f2bf2 100644 --- a/src/kmcuda.h +++ b/src/kmcuda.h @@ -37,6 +37,8 @@ #include +#include + /// All possible error codes in public API. typedef enum { /// Everything's all right. From 8adc482f18ffb38f5db73a884c68b27a463d6e4e Mon Sep 17 00:00:00 2001 From: Aleksandrs Pavlenko Date: Thu, 6 Dec 2018 15:38:45 +0200 Subject: [PATCH 11/21] removed " __attribute__((unused))" as it is not being supported on Win --- src/metric_abstraction.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/metric_abstraction.h b/src/metric_abstraction.h index 38ea3e8..bc339f7 100644 --- a/src/metric_abstraction.h +++ b/src/metric_abstraction.h @@ -169,7 +169,7 @@ struct METRIC { } FPATTR static typename HALF::type distance( - F sqr1 __attribute__((unused)), F sqr2 __attribute__((unused)), F prod) { + F sqr1, F sqr2, F prod) { float fp = _float(_fin(prod)); if (fp >= 1.f) return _half(0.f); if (fp <= -1.f) return _half(M_PI); @@ -252,7 +252,7 @@ struct METRIC { return acos(partial); } - FPATTR static void normalize(uint32_t count __attribute__((unused)), float *vec) { + FPATTR static void normalize(uint32_t count, float *vec) { // Kahan summation with inverted c float norm = 0, corr = 0; #pragma unroll 4 @@ -272,7 +272,7 @@ struct METRIC { } #if CUDA_ARCH >= 60 - FPATTR static void normalize(uint32_t count __attribute__((unused)), half2 *vec) { + FPATTR static void normalize(uint32_t count, half2 *vec) { // We really have to calculate norm in 32-bit floats because the maximum // value which 16-bit float may represent is 2^16. float norm = 0, corr = 0; From f2d24c5529f367a9c22e02e869fa05124065f8fb Mon Sep 17 00:00:00 2001 From: Aleksandrs Pavlenko Date: Thu, 6 Dec 2018 15:40:06 +0200 Subject: [PATCH 12/21] adde fix for ternary operator, which is not being compiled on Win --- src/wrappers.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/wrappers.h b/src/wrappers.h index cec03e1..d083160 100644 --- a/src/wrappers.h +++ b/src/wrappers.h @@ -17,7 +17,10 @@ template class unique_devptr : public unique_devptr_parent { public: explicit unique_devptr(T *ptr, bool fake = false) : unique_devptr_parent( - ptr, fake? [](T*){} : [](T *p){ cudaFree(p); }) {} + ptr, + (fake == true) + ? (std::function)([](T*) {}) + : [](T *p) { cudaFree(p); }) {} }; /// std::vector of unique_devptr-s. Used to pass device arrays inside .cu From b2eca8723a0543af60dd217e5d1f17f0bc01290a Mon Sep 17 00:00:00 2001 From: Aleksandrs Pavlenko Date: Thu, 6 Dec 2018 16:46:41 +0200 Subject: [PATCH 13/21] applied a fix for Pi math function --- src/metric_abstraction.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/metric_abstraction.h b/src/metric_abstraction.h index bc339f7..7668a95 100644 --- a/src/metric_abstraction.h +++ b/src/metric_abstraction.h @@ -2,6 +2,9 @@ // distance and normalization functions. // +#define _USE_MATH_DEFINES +#include + #ifndef KMCUDA_METRIC_ABSTRACTION_H #define KMCUDA_METRIC_ABSTRACTION_H From 4675d4313aa871767683b9fb70ed91546c0202ea Mon Sep 17 00:00:00 2001 From: Aleksandrs Pavlenko Date: Thu, 6 Dec 2018 17:01:29 +0200 Subject: [PATCH 14/21] fix for "min" not being a part of std --- src/knn.cu | 1 + 1 file changed, 1 insertion(+) diff --git a/src/knn.cu b/src/knn.cu index a25c7b1..c26b1da 100644 --- a/src/knn.cu +++ b/src/knn.cu @@ -1,4 +1,5 @@ #include +#include #include "private.h" #include "metric_abstraction.h" From 2cab6baff3d1313c1d9c38edb992e425536373d0 Mon Sep 17 00:00:00 2001 From: Aleksandrs Pavlenko Date: Thu, 6 Dec 2018 17:20:45 +0200 Subject: [PATCH 15/21] added a fix (temporary?), for cases when CUDA_ARCH variable is not being defined on host hence causing the build to fail. p.s. this variable is never defined on host. --- src/kmcuda.cc | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/kmcuda.cc b/src/kmcuda.cc index df8cbbe..46b32b2 100644 --- a/src/kmcuda.cc +++ b/src/kmcuda.cc @@ -51,7 +51,7 @@ static KMCUDAResult check_kmeans_args( if (yinyang_t < 0 || yinyang_t > 0.5) { return kmcudaInvalidArguments; } -#if CUDA_ARCH < 60 +#if defined(__CUDA_ARCH__) && CUDA_ARCH < 60 if (fp16x2) { INFO("CUDA device arch %d does not support fp16\n", CUDA_ARCH); return kmcudaInvalidArguments; @@ -83,14 +83,18 @@ static std::vector setup_devices(uint32_t device, int device_ptrs, int verb dev, cudaGetErrorString(err)); devs.pop_back(); } - if (props.major != (CUDA_ARCH / 10) || props.minor != (CUDA_ARCH % 10)) { - INFO("compute capability mismatch for device %d: wanted %d.%d, have " - "%d.%d\n>>>> you may want to build kmcuda with -DCUDA_ARCH=%d " - "(refer to \"Building\" in README.md)\n", - dev, CUDA_ARCH / 10, CUDA_ARCH % 10, props.major, props.minor, - props.major * 10 + props.minor); - devs.pop_back(); - } + +#if defined(__CUDA_ARCH__) + if (props.major != (CUDA_ARCH / 10) || props.minor != (CUDA_ARCH % 10)) { + INFO("compute capability mismatch for device %d: wanted %d.%d, have " + "%d.%d\n>>>> you may want to build kmcuda with -DCUDA_ARCH=%d " + "(refer to \"Building\" in README.md)\n", + dev, CUDA_ARCH / 10, CUDA_ARCH % 10, props.major, props.minor, + props.major * 10 + props.minor); + devs.pop_back(); + } +#endif + } device >>= 1; } @@ -559,7 +563,7 @@ static KMCUDAResult check_knn_args( neighbors == nullptr) { return kmcudaInvalidArguments; } -#if CUDA_ARCH < 60 +#if defined(__CUDA_ARCH__) && CUDA_ARCH < 60 if (fp16x2) { INFO("CUDA device arch %d does not support fp16\n", CUDA_ARCH); return kmcudaInvalidArguments; From 024b6300c1dd25aae0927a4006ada67658725fe8 Mon Sep 17 00:00:00 2001 From: Aleksandrs Pavlenko Date: Thu, 6 Dec 2018 17:27:07 +0200 Subject: [PATCH 16/21] remove obsolete files --- kmcudaWinVS/kmcudaCore/kernel.cu | 121 ------------------------------- 1 file changed, 121 deletions(-) delete mode 100644 kmcudaWinVS/kmcudaCore/kernel.cu diff --git a/kmcudaWinVS/kmcudaCore/kernel.cu b/kmcudaWinVS/kmcudaCore/kernel.cu deleted file mode 100644 index 90d489d..0000000 --- a/kmcudaWinVS/kmcudaCore/kernel.cu +++ /dev/null @@ -1,121 +0,0 @@ - -#include "cuda_runtime.h" -#include "device_launch_parameters.h" - -#include - -cudaError_t addWithCuda(int *c, const int *a, const int *b, unsigned int size); - -__global__ void addKernel(int *c, const int *a, const int *b) -{ - int i = threadIdx.x; - c[i] = a[i] + b[i]; -} - -int main() -{ - const int arraySize = 5; - const int a[arraySize] = { 1, 2, 3, 4, 5 }; - const int b[arraySize] = { 10, 20, 30, 40, 50 }; - int c[arraySize] = { 0 }; - - // Add vectors in parallel. - cudaError_t cudaStatus = addWithCuda(c, a, b, arraySize); - if (cudaStatus != cudaSuccess) { - fprintf(stderr, "addWithCuda failed!"); - return 1; - } - - printf("{1,2,3,4,5} + {10,20,30,40,50} = {%d,%d,%d,%d,%d}\n", - c[0], c[1], c[2], c[3], c[4]); - - // cudaDeviceReset must be called before exiting in order for profiling and - // tracing tools such as Nsight and Visual Profiler to show complete traces. - cudaStatus = cudaDeviceReset(); - if (cudaStatus != cudaSuccess) { - fprintf(stderr, "cudaDeviceReset failed!"); - return 1; - } - - return 0; -} - -// Helper function for using CUDA to add vectors in parallel. -cudaError_t addWithCuda(int *c, const int *a, const int *b, unsigned int size) -{ - int *dev_a = 0; - int *dev_b = 0; - int *dev_c = 0; - cudaError_t cudaStatus; - - // Choose which GPU to run on, change this on a multi-GPU system. - cudaStatus = cudaSetDevice(0); - if (cudaStatus != cudaSuccess) { - fprintf(stderr, "cudaSetDevice failed! Do you have a CUDA-capable GPU installed?"); - goto Error; - } - - // Allocate GPU buffers for three vectors (two input, one output) . - cudaStatus = cudaMalloc((void**)&dev_c, size * sizeof(int)); - if (cudaStatus != cudaSuccess) { - fprintf(stderr, "cudaMalloc failed!"); - goto Error; - } - - cudaStatus = cudaMalloc((void**)&dev_a, size * sizeof(int)); - if (cudaStatus != cudaSuccess) { - fprintf(stderr, "cudaMalloc failed!"); - goto Error; - } - - cudaStatus = cudaMalloc((void**)&dev_b, size * sizeof(int)); - if (cudaStatus != cudaSuccess) { - fprintf(stderr, "cudaMalloc failed!"); - goto Error; - } - - // Copy input vectors from host memory to GPU buffers. - cudaStatus = cudaMemcpy(dev_a, a, size * sizeof(int), cudaMemcpyHostToDevice); - if (cudaStatus != cudaSuccess) { - fprintf(stderr, "cudaMemcpy failed!"); - goto Error; - } - - cudaStatus = cudaMemcpy(dev_b, b, size * sizeof(int), cudaMemcpyHostToDevice); - if (cudaStatus != cudaSuccess) { - fprintf(stderr, "cudaMemcpy failed!"); - goto Error; - } - - // Launch a kernel on the GPU with one thread for each element. - addKernel<<<1, size>>>(dev_c, dev_a, dev_b); - - // Check for any errors launching the kernel - cudaStatus = cudaGetLastError(); - if (cudaStatus != cudaSuccess) { - fprintf(stderr, "addKernel launch failed: %s\n", cudaGetErrorString(cudaStatus)); - goto Error; - } - - // cudaDeviceSynchronize waits for the kernel to finish, and returns - // any errors encountered during the launch. - cudaStatus = cudaDeviceSynchronize(); - if (cudaStatus != cudaSuccess) { - fprintf(stderr, "cudaDeviceSynchronize returned error code %d after launching addKernel!\n", cudaStatus); - goto Error; - } - - // Copy output vector from GPU buffer to host memory. - cudaStatus = cudaMemcpy(c, dev_c, size * sizeof(int), cudaMemcpyDeviceToHost); - if (cudaStatus != cudaSuccess) { - fprintf(stderr, "cudaMemcpy failed!"); - goto Error; - } - -Error: - cudaFree(dev_c); - cudaFree(dev_a); - cudaFree(dev_b); - - return cudaStatus; -} From 1d3ec12013f7f600bc8f36e3136e44581bfa8df7 Mon Sep 17 00:00:00 2001 From: Aleksandrs Pavlenko Date: Thu, 6 Dec 2018 17:33:46 +0200 Subject: [PATCH 17/21] applied VisualStudio solution related changes --- kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj | 3 +-- kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj.filters | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj b/kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj index a98551d..c7e4f38 100644 --- a/kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj +++ b/kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj @@ -27,7 +27,7 @@ false true MultiByte - v140 + v141 @@ -83,7 +83,6 @@ - diff --git a/kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj.filters b/kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj.filters index 533d383..edc8a66 100644 --- a/kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj.filters +++ b/kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj.filters @@ -1,7 +1,6 @@  - CUDA files From d4525d611881fe9158206441b198185c1aee2a02 Mon Sep 17 00:00:00 2001 From: Aleksandrs Pavlenko Date: Thu, 6 Dec 2018 18:06:02 +0200 Subject: [PATCH 18/21] undone chnages to files, which are irrelevant to kmcuda patch for windows --- .gitattributes | 63 ---- .gitignore | 340 ------------------ kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj | 102 ------ .../kmcudaCore/kmcudaCore.vcxproj.filters | 50 --- kmcudaWinVS/kmcudaWinVS.sln | 25 -- 5 files changed, 580 deletions(-) delete mode 100644 .gitattributes delete mode 100644 kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj delete mode 100644 kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj.filters delete mode 100644 kmcudaWinVS/kmcudaWinVS.sln diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1ff0c42..0000000 --- a/.gitattributes +++ /dev/null @@ -1,63 +0,0 @@ -############################################################################### -# Set default behavior to automatically normalize line endings. -############################################################################### -* text=auto - -############################################################################### -# Set default behavior for command prompt diff. -# -# This is need for earlier builds of msysgit that does not have it on by -# default for csharp files. -# Note: This is only used by command line -############################################################################### -#*.cs diff=csharp - -############################################################################### -# Set the merge driver for project and solution files -# -# Merging from the command prompt will add diff markers to the files if there -# are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following -# file extensions to fail to load in VS. An alternative would be to treat -# these files as binary and thus will always conflict and require user -# intervention with every merge. To do so, just uncomment the entries below -############################################################################### -#*.sln merge=binary -#*.csproj merge=binary -#*.vbproj merge=binary -#*.vcxproj merge=binary -#*.vcproj merge=binary -#*.dbproj merge=binary -#*.fsproj merge=binary -#*.lsproj merge=binary -#*.wixproj merge=binary -#*.modelproj merge=binary -#*.sqlproj merge=binary -#*.wwaproj merge=binary - -############################################################################### -# behavior for image files -# -# image files are treated as binary by default. -############################################################################### -#*.jpg binary -#*.png binary -#*.gif binary - -############################################################################### -# diff behavior for common document formats -# -# Convert binary document formats to text before diffing them. This feature -# is only available from the command line. Turn it on by uncommenting the -# entries below. -############################################################################### -#*.doc diff=astextplain -#*.DOC diff=astextplain -#*.docx diff=astextplain -#*.DOCX diff=astextplain -#*.dot diff=astextplain -#*.DOT diff=astextplain -#*.pdf diff=astextplain -#*.PDF diff=astextplain -#*.rtf diff=astextplain -#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore index cd26df3..5323a25 100644 --- a/.gitignore +++ b/.gitignore @@ -37,343 +37,3 @@ cmake-build-* *.exe *.out *.app - - -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - -# User-specific files -*.rsuser -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -[Aa][Rr][Mm]/ -[Aa][Rr][Mm]64/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_h.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*_wpftmp.csproj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ -# ASP.NET Core default setup: bower directory is configured as wwwroot/lib/ and bower restore is true -**/wwwroot/lib/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# JetBrains Rider -.idea/ -*.sln.iml - -# CodeRush personal settings -.cr/personal - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ - -# Local History for Visual Studio -.localhistory/ diff --git a/kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj b/kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj deleted file mode 100644 index c7e4f38..0000000 --- a/kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj +++ /dev/null @@ -1,102 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {628BF41E-BC0A-4FFB-BC5A-BA88A9AEB055} - kmcudaCore - 10.0.17763.0 - - - - StaticLibrary - true - MultiByte - v140 - - - StaticLibrary - false - true - MultiByte - v141 - - - - - - - - - - - - - - true - - - - Level3 - Disabled - WIN32;WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - - - true - Console - cudart_static.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - 64 - compute_60,sm_60;%(CodeGeneration) - - - - - Level3 - MaxSpeed - true - true - WIN32;WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - - - true - true - true - Console - cudart_static.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - 64 - compute_60,sm_60;%(CodeGeneration) - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj.filters b/kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj.filters deleted file mode 100644 index edc8a66..0000000 --- a/kmcudaWinVS/kmcudaCore/kmcudaCore.vcxproj.filters +++ /dev/null @@ -1,50 +0,0 @@ - - - - - CUDA files - - - CUDA files - - - CUDA files - - - - - {81809b38-8835-4c69-abd7-2880fe1ae2f8} - - - {8c5e4679-4969-4098-ab62-b8e94bed91ba} - - - {3dedfa35-1870-478f-9f6b-d0c4dd00e09d} - - - - - Header files - - - Header files - - - Header files - - - Header files - - - Header files - - - Header files - - - - - Source files - - - \ No newline at end of file diff --git a/kmcudaWinVS/kmcudaWinVS.sln b/kmcudaWinVS/kmcudaWinVS.sln deleted file mode 100644 index 435abb2..0000000 --- a/kmcudaWinVS/kmcudaWinVS.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.136 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kmcudaCore", "kmcudaCore\kmcudaCore.vcxproj", "{628BF41E-BC0A-4FFB-BC5A-BA88A9AEB055}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {628BF41E-BC0A-4FFB-BC5A-BA88A9AEB055}.Debug|x64.ActiveCfg = Release|x64 - {628BF41E-BC0A-4FFB-BC5A-BA88A9AEB055}.Debug|x64.Build.0 = Release|x64 - {628BF41E-BC0A-4FFB-BC5A-BA88A9AEB055}.Release|x64.ActiveCfg = Release|x64 - {628BF41E-BC0A-4FFB-BC5A-BA88A9AEB055}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {1DDAC52A-68B6-4669-AFF2-5B7A7B50734B} - EndGlobalSection -EndGlobal From 6235c4b42627df18628a701b875a9d73605f1987 Mon Sep 17 00:00:00 2001 From: Aleksandrs Pavlenko Date: Mon, 10 Dec 2018 12:26:41 +0200 Subject: [PATCH 19/21] added support for building solution on Windows Signed-off-by: Aleksandrs Pavlenko --- src/kmcuda.cc | 24 ++++++++++++++---------- src/kmcuda.h | 2 ++ src/knn.cu | 1 + src/metric_abstraction.h | 9 ++++++--- src/wrappers.h | 5 ++++- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/kmcuda.cc b/src/kmcuda.cc index df8cbbe..46b32b2 100644 --- a/src/kmcuda.cc +++ b/src/kmcuda.cc @@ -51,7 +51,7 @@ static KMCUDAResult check_kmeans_args( if (yinyang_t < 0 || yinyang_t > 0.5) { return kmcudaInvalidArguments; } -#if CUDA_ARCH < 60 +#if defined(__CUDA_ARCH__) && CUDA_ARCH < 60 if (fp16x2) { INFO("CUDA device arch %d does not support fp16\n", CUDA_ARCH); return kmcudaInvalidArguments; @@ -83,14 +83,18 @@ static std::vector setup_devices(uint32_t device, int device_ptrs, int verb dev, cudaGetErrorString(err)); devs.pop_back(); } - if (props.major != (CUDA_ARCH / 10) || props.minor != (CUDA_ARCH % 10)) { - INFO("compute capability mismatch for device %d: wanted %d.%d, have " - "%d.%d\n>>>> you may want to build kmcuda with -DCUDA_ARCH=%d " - "(refer to \"Building\" in README.md)\n", - dev, CUDA_ARCH / 10, CUDA_ARCH % 10, props.major, props.minor, - props.major * 10 + props.minor); - devs.pop_back(); - } + +#if defined(__CUDA_ARCH__) + if (props.major != (CUDA_ARCH / 10) || props.minor != (CUDA_ARCH % 10)) { + INFO("compute capability mismatch for device %d: wanted %d.%d, have " + "%d.%d\n>>>> you may want to build kmcuda with -DCUDA_ARCH=%d " + "(refer to \"Building\" in README.md)\n", + dev, CUDA_ARCH / 10, CUDA_ARCH % 10, props.major, props.minor, + props.major * 10 + props.minor); + devs.pop_back(); + } +#endif + } device >>= 1; } @@ -559,7 +563,7 @@ static KMCUDAResult check_knn_args( neighbors == nullptr) { return kmcudaInvalidArguments; } -#if CUDA_ARCH < 60 +#if defined(__CUDA_ARCH__) && CUDA_ARCH < 60 if (fp16x2) { INFO("CUDA device arch %d does not support fp16\n", CUDA_ARCH); return kmcudaInvalidArguments; diff --git a/src/kmcuda.h b/src/kmcuda.h index 8b013b9..72f2bf2 100644 --- a/src/kmcuda.h +++ b/src/kmcuda.h @@ -37,6 +37,8 @@ #include +#include + /// All possible error codes in public API. typedef enum { /// Everything's all right. diff --git a/src/knn.cu b/src/knn.cu index a25c7b1..c26b1da 100644 --- a/src/knn.cu +++ b/src/knn.cu @@ -1,4 +1,5 @@ #include +#include #include "private.h" #include "metric_abstraction.h" diff --git a/src/metric_abstraction.h b/src/metric_abstraction.h index 38ea3e8..7668a95 100644 --- a/src/metric_abstraction.h +++ b/src/metric_abstraction.h @@ -2,6 +2,9 @@ // distance and normalization functions. // +#define _USE_MATH_DEFINES +#include + #ifndef KMCUDA_METRIC_ABSTRACTION_H #define KMCUDA_METRIC_ABSTRACTION_H @@ -169,7 +172,7 @@ struct METRIC { } FPATTR static typename HALF::type distance( - F sqr1 __attribute__((unused)), F sqr2 __attribute__((unused)), F prod) { + F sqr1, F sqr2, F prod) { float fp = _float(_fin(prod)); if (fp >= 1.f) return _half(0.f); if (fp <= -1.f) return _half(M_PI); @@ -252,7 +255,7 @@ struct METRIC { return acos(partial); } - FPATTR static void normalize(uint32_t count __attribute__((unused)), float *vec) { + FPATTR static void normalize(uint32_t count, float *vec) { // Kahan summation with inverted c float norm = 0, corr = 0; #pragma unroll 4 @@ -272,7 +275,7 @@ struct METRIC { } #if CUDA_ARCH >= 60 - FPATTR static void normalize(uint32_t count __attribute__((unused)), half2 *vec) { + FPATTR static void normalize(uint32_t count, half2 *vec) { // We really have to calculate norm in 32-bit floats because the maximum // value which 16-bit float may represent is 2^16. float norm = 0, corr = 0; diff --git a/src/wrappers.h b/src/wrappers.h index cec03e1..d083160 100644 --- a/src/wrappers.h +++ b/src/wrappers.h @@ -17,7 +17,10 @@ template class unique_devptr : public unique_devptr_parent { public: explicit unique_devptr(T *ptr, bool fake = false) : unique_devptr_parent( - ptr, fake? [](T*){} : [](T *p){ cudaFree(p); }) {} + ptr, + (fake == true) + ? (std::function)([](T*) {}) + : [](T *p) { cudaFree(p); }) {} }; /// std::vector of unique_devptr-s. Used to pass device arrays inside .cu From 4f6deca3bb4bb476bdaca5668dfaf45a26d25182 Mon Sep 17 00:00:00 2001 From: pavlexander Date: Mon, 10 Dec 2018 15:11:43 +0200 Subject: [PATCH 20/21] added support for building solution on Windows Signed-off-by: pavlexander --- src/kmcuda.cc | 24 ++++++++++++++---------- src/kmcuda.h | 2 ++ src/knn.cu | 1 + src/metric_abstraction.h | 9 ++++++--- src/wrappers.h | 5 ++++- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/kmcuda.cc b/src/kmcuda.cc index df8cbbe..46b32b2 100644 --- a/src/kmcuda.cc +++ b/src/kmcuda.cc @@ -51,7 +51,7 @@ static KMCUDAResult check_kmeans_args( if (yinyang_t < 0 || yinyang_t > 0.5) { return kmcudaInvalidArguments; } -#if CUDA_ARCH < 60 +#if defined(__CUDA_ARCH__) && CUDA_ARCH < 60 if (fp16x2) { INFO("CUDA device arch %d does not support fp16\n", CUDA_ARCH); return kmcudaInvalidArguments; @@ -83,14 +83,18 @@ static std::vector setup_devices(uint32_t device, int device_ptrs, int verb dev, cudaGetErrorString(err)); devs.pop_back(); } - if (props.major != (CUDA_ARCH / 10) || props.minor != (CUDA_ARCH % 10)) { - INFO("compute capability mismatch for device %d: wanted %d.%d, have " - "%d.%d\n>>>> you may want to build kmcuda with -DCUDA_ARCH=%d " - "(refer to \"Building\" in README.md)\n", - dev, CUDA_ARCH / 10, CUDA_ARCH % 10, props.major, props.minor, - props.major * 10 + props.minor); - devs.pop_back(); - } + +#if defined(__CUDA_ARCH__) + if (props.major != (CUDA_ARCH / 10) || props.minor != (CUDA_ARCH % 10)) { + INFO("compute capability mismatch for device %d: wanted %d.%d, have " + "%d.%d\n>>>> you may want to build kmcuda with -DCUDA_ARCH=%d " + "(refer to \"Building\" in README.md)\n", + dev, CUDA_ARCH / 10, CUDA_ARCH % 10, props.major, props.minor, + props.major * 10 + props.minor); + devs.pop_back(); + } +#endif + } device >>= 1; } @@ -559,7 +563,7 @@ static KMCUDAResult check_knn_args( neighbors == nullptr) { return kmcudaInvalidArguments; } -#if CUDA_ARCH < 60 +#if defined(__CUDA_ARCH__) && CUDA_ARCH < 60 if (fp16x2) { INFO("CUDA device arch %d does not support fp16\n", CUDA_ARCH); return kmcudaInvalidArguments; diff --git a/src/kmcuda.h b/src/kmcuda.h index 8b013b9..72f2bf2 100644 --- a/src/kmcuda.h +++ b/src/kmcuda.h @@ -37,6 +37,8 @@ #include +#include + /// All possible error codes in public API. typedef enum { /// Everything's all right. diff --git a/src/knn.cu b/src/knn.cu index a25c7b1..c26b1da 100644 --- a/src/knn.cu +++ b/src/knn.cu @@ -1,4 +1,5 @@ #include +#include #include "private.h" #include "metric_abstraction.h" diff --git a/src/metric_abstraction.h b/src/metric_abstraction.h index 38ea3e8..7668a95 100644 --- a/src/metric_abstraction.h +++ b/src/metric_abstraction.h @@ -2,6 +2,9 @@ // distance and normalization functions. // +#define _USE_MATH_DEFINES +#include + #ifndef KMCUDA_METRIC_ABSTRACTION_H #define KMCUDA_METRIC_ABSTRACTION_H @@ -169,7 +172,7 @@ struct METRIC { } FPATTR static typename HALF::type distance( - F sqr1 __attribute__((unused)), F sqr2 __attribute__((unused)), F prod) { + F sqr1, F sqr2, F prod) { float fp = _float(_fin(prod)); if (fp >= 1.f) return _half(0.f); if (fp <= -1.f) return _half(M_PI); @@ -252,7 +255,7 @@ struct METRIC { return acos(partial); } - FPATTR static void normalize(uint32_t count __attribute__((unused)), float *vec) { + FPATTR static void normalize(uint32_t count, float *vec) { // Kahan summation with inverted c float norm = 0, corr = 0; #pragma unroll 4 @@ -272,7 +275,7 @@ struct METRIC { } #if CUDA_ARCH >= 60 - FPATTR static void normalize(uint32_t count __attribute__((unused)), half2 *vec) { + FPATTR static void normalize(uint32_t count, half2 *vec) { // We really have to calculate norm in 32-bit floats because the maximum // value which 16-bit float may represent is 2^16. float norm = 0, corr = 0; diff --git a/src/wrappers.h b/src/wrappers.h index cec03e1..d083160 100644 --- a/src/wrappers.h +++ b/src/wrappers.h @@ -17,7 +17,10 @@ template class unique_devptr : public unique_devptr_parent { public: explicit unique_devptr(T *ptr, bool fake = false) : unique_devptr_parent( - ptr, fake? [](T*){} : [](T *p){ cudaFree(p); }) {} + ptr, + (fake == true) + ? (std::function)([](T*) {}) + : [](T *p) { cudaFree(p); }) {} }; /// std::vector of unique_devptr-s. Used to pass device arrays inside .cu From ff707ab9a11f67429fbee07260375f4a1da7d235 Mon Sep 17 00:00:00 2001 From: pavlexander Date: Mon, 10 Dec 2018 15:11:43 +0200 Subject: [PATCH 21/21] added support for building solution on Windows (3) Signed-off-by: Aleksandrs Pavlenko --- src/kmcuda.cc | 24 ++++++++++++++---------- src/kmcuda.h | 2 ++ src/knn.cu | 1 + src/metric_abstraction.h | 9 ++++++--- src/wrappers.h | 5 ++++- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/kmcuda.cc b/src/kmcuda.cc index df8cbbe..46b32b2 100644 --- a/src/kmcuda.cc +++ b/src/kmcuda.cc @@ -51,7 +51,7 @@ static KMCUDAResult check_kmeans_args( if (yinyang_t < 0 || yinyang_t > 0.5) { return kmcudaInvalidArguments; } -#if CUDA_ARCH < 60 +#if defined(__CUDA_ARCH__) && CUDA_ARCH < 60 if (fp16x2) { INFO("CUDA device arch %d does not support fp16\n", CUDA_ARCH); return kmcudaInvalidArguments; @@ -83,14 +83,18 @@ static std::vector setup_devices(uint32_t device, int device_ptrs, int verb dev, cudaGetErrorString(err)); devs.pop_back(); } - if (props.major != (CUDA_ARCH / 10) || props.minor != (CUDA_ARCH % 10)) { - INFO("compute capability mismatch for device %d: wanted %d.%d, have " - "%d.%d\n>>>> you may want to build kmcuda with -DCUDA_ARCH=%d " - "(refer to \"Building\" in README.md)\n", - dev, CUDA_ARCH / 10, CUDA_ARCH % 10, props.major, props.minor, - props.major * 10 + props.minor); - devs.pop_back(); - } + +#if defined(__CUDA_ARCH__) + if (props.major != (CUDA_ARCH / 10) || props.minor != (CUDA_ARCH % 10)) { + INFO("compute capability mismatch for device %d: wanted %d.%d, have " + "%d.%d\n>>>> you may want to build kmcuda with -DCUDA_ARCH=%d " + "(refer to \"Building\" in README.md)\n", + dev, CUDA_ARCH / 10, CUDA_ARCH % 10, props.major, props.minor, + props.major * 10 + props.minor); + devs.pop_back(); + } +#endif + } device >>= 1; } @@ -559,7 +563,7 @@ static KMCUDAResult check_knn_args( neighbors == nullptr) { return kmcudaInvalidArguments; } -#if CUDA_ARCH < 60 +#if defined(__CUDA_ARCH__) && CUDA_ARCH < 60 if (fp16x2) { INFO("CUDA device arch %d does not support fp16\n", CUDA_ARCH); return kmcudaInvalidArguments; diff --git a/src/kmcuda.h b/src/kmcuda.h index 8b013b9..72f2bf2 100644 --- a/src/kmcuda.h +++ b/src/kmcuda.h @@ -37,6 +37,8 @@ #include +#include + /// All possible error codes in public API. typedef enum { /// Everything's all right. diff --git a/src/knn.cu b/src/knn.cu index a25c7b1..c26b1da 100644 --- a/src/knn.cu +++ b/src/knn.cu @@ -1,4 +1,5 @@ #include +#include #include "private.h" #include "metric_abstraction.h" diff --git a/src/metric_abstraction.h b/src/metric_abstraction.h index 38ea3e8..7668a95 100644 --- a/src/metric_abstraction.h +++ b/src/metric_abstraction.h @@ -2,6 +2,9 @@ // distance and normalization functions. // +#define _USE_MATH_DEFINES +#include + #ifndef KMCUDA_METRIC_ABSTRACTION_H #define KMCUDA_METRIC_ABSTRACTION_H @@ -169,7 +172,7 @@ struct METRIC { } FPATTR static typename HALF::type distance( - F sqr1 __attribute__((unused)), F sqr2 __attribute__((unused)), F prod) { + F sqr1, F sqr2, F prod) { float fp = _float(_fin(prod)); if (fp >= 1.f) return _half(0.f); if (fp <= -1.f) return _half(M_PI); @@ -252,7 +255,7 @@ struct METRIC { return acos(partial); } - FPATTR static void normalize(uint32_t count __attribute__((unused)), float *vec) { + FPATTR static void normalize(uint32_t count, float *vec) { // Kahan summation with inverted c float norm = 0, corr = 0; #pragma unroll 4 @@ -272,7 +275,7 @@ struct METRIC { } #if CUDA_ARCH >= 60 - FPATTR static void normalize(uint32_t count __attribute__((unused)), half2 *vec) { + FPATTR static void normalize(uint32_t count, half2 *vec) { // We really have to calculate norm in 32-bit floats because the maximum // value which 16-bit float may represent is 2^16. float norm = 0, corr = 0; diff --git a/src/wrappers.h b/src/wrappers.h index cec03e1..d083160 100644 --- a/src/wrappers.h +++ b/src/wrappers.h @@ -17,7 +17,10 @@ template class unique_devptr : public unique_devptr_parent { public: explicit unique_devptr(T *ptr, bool fake = false) : unique_devptr_parent( - ptr, fake? [](T*){} : [](T *p){ cudaFree(p); }) {} + ptr, + (fake == true) + ? (std::function)([](T*) {}) + : [](T *p) { cudaFree(p); }) {} }; /// std::vector of unique_devptr-s. Used to pass device arrays inside .cu