mirror of
https://github.com/NVIDIA/cuda-samples.git
synced 2024-11-24 19:49:19 +08:00
Initial public release for CUDA 9.2.
This commit is contained in:
commit
8bb8c5fac0
470
Common/drvapi_error_string.h
Normal file
470
Common/drvapi_error_string.h
Normal file
|
@ -0,0 +1,470 @@
|
||||||
|
/* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMMON_DRVAPI_ERROR_STRING_H_
|
||||||
|
#define COMMON_DRVAPI_ERROR_STRING_H_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef __cuda_cuda_h__ // check to see if CUDA_H is included above
|
||||||
|
|
||||||
|
// Error Code string definitions here
|
||||||
|
typedef struct {
|
||||||
|
char const *error_string;
|
||||||
|
int error_id;
|
||||||
|
} s_CudaErrorStr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error codes
|
||||||
|
*/
|
||||||
|
static s_CudaErrorStr sCudaDrvErrorString[] = {
|
||||||
|
/**
|
||||||
|
* The API call returned with no errors. In the case of query calls, this
|
||||||
|
* can also mean that the operation being queried is complete (see
|
||||||
|
* ::cuEventQuery() and ::cuStreamQuery()).
|
||||||
|
*/
|
||||||
|
{"CUDA_SUCCESS", 0},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that one or more of the parameters passed to the API call
|
||||||
|
* is not within an acceptable range of values.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_INVALID_VALUE", 1},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The API call failed because it was unable to allocate enough memory to
|
||||||
|
* perform the requested operation.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_OUT_OF_MEMORY", 2},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that the CUDA driver has not been initialized with
|
||||||
|
* ::cuInit() or that initialization has failed.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_NOT_INITIALIZED", 3},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that the CUDA driver is in the process of shutting down.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_DEINITIALIZED", 4},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates profiling APIs are called while application is running
|
||||||
|
* in visual profiler mode.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_PROFILER_DISABLED", 5},
|
||||||
|
/**
|
||||||
|
* This indicates profiling has not been initialized for this context.
|
||||||
|
* Call cuProfilerInitialize() to resolve this.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_PROFILER_NOT_INITIALIZED", 6},
|
||||||
|
/**
|
||||||
|
* This indicates profiler has already been started and probably
|
||||||
|
* cuProfilerStart() is incorrectly called.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_PROFILER_ALREADY_STARTED", 7},
|
||||||
|
/**
|
||||||
|
* This indicates profiler has already been stopped and probably
|
||||||
|
* cuProfilerStop() is incorrectly called.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_PROFILER_ALREADY_STOPPED", 8},
|
||||||
|
/**
|
||||||
|
* This indicates that no CUDA-capable devices were detected by the
|
||||||
|
* installed CUDA driver.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_NO_DEVICE (no CUDA-capable devices were detected)", 100},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that the device ordinal supplied by the user does not
|
||||||
|
* correspond to a valid CUDA device.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_INVALID_DEVICE (device specified is not a valid CUDA device)",
|
||||||
|
101},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that the device kernel image is invalid. This can also
|
||||||
|
* indicate an invalid CUDA module.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_INVALID_IMAGE", 200},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This most frequently indicates that there is no context bound to the
|
||||||
|
* current thread. This can also be returned if the context passed to an
|
||||||
|
* API call is not a valid handle (such as a context that has had
|
||||||
|
* ::cuCtxDestroy() invoked on it). This can also be returned if a user
|
||||||
|
* mixes different API versions (i.e. 3010 context with 3020 API calls).
|
||||||
|
* See ::cuCtxGetApiVersion() for more details.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_INVALID_CONTEXT", 201},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicated that the context being supplied as a parameter to the
|
||||||
|
* API call was already the active context.
|
||||||
|
* \deprecated
|
||||||
|
* This error return is deprecated as of CUDA 3.2. It is no longer an
|
||||||
|
* error to attempt to push the active context via ::cuCtxPushCurrent().
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_CONTEXT_ALREADY_CURRENT", 202},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that a map or register operation has failed.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_MAP_FAILED", 205},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that an unmap or unregister operation has failed.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_UNMAP_FAILED", 206},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that the specified array is currently mapped and thus
|
||||||
|
* cannot be destroyed.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_ARRAY_IS_MAPPED", 207},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that the resource is already mapped.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_ALREADY_MAPPED", 208},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that there is no kernel image available that is suitable
|
||||||
|
* for the device. This can occur when a user specifies code generation
|
||||||
|
* options for a particular CUDA source file that do not include the
|
||||||
|
* corresponding device configuration.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_NO_BINARY_FOR_GPU", 209},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that a resource has already been acquired.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_ALREADY_ACQUIRED", 210},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that a resource is not mapped.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_NOT_MAPPED", 211},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that a mapped resource is not available for access as an
|
||||||
|
* array.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_NOT_MAPPED_AS_ARRAY", 212},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that a mapped resource is not available for access as a
|
||||||
|
* pointer.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_NOT_MAPPED_AS_POINTER", 213},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that an uncorrectable ECC error was detected during
|
||||||
|
* execution.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_ECC_UNCORRECTABLE", 214},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that the ::CUlimit passed to the API call is not
|
||||||
|
* supported by the active device.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_UNSUPPORTED_LIMIT", 215},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that the ::CUcontext passed to the API call can
|
||||||
|
* only be bound to a single CPU thread at a time but is already
|
||||||
|
* bound to a CPU thread.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_CONTEXT_ALREADY_IN_USE", 216},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that peer access is not supported across the given
|
||||||
|
* devices.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_PEER_ACCESS_UNSUPPORTED", 217},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that a PTX JIT compilation failed.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_INVALID_PTX", 218},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates an error with OpenGL or DirectX context.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_INVALID_GRAPHICS_CONTEXT", 219},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that an uncorrectable NVLink error was detected during the
|
||||||
|
* execution.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_NVLINK_UNCORRECTABLE", 220},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that the PTX JIT compiler library was not found.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_JIT_COMPILER_NOT_FOUND", 221},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that the device kernel source is invalid.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_INVALID_SOURCE", 300},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that the file specified was not found.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_FILE_NOT_FOUND", 301},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that a link to a shared object failed to resolve.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND", 302},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that initialization of a shared object failed.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_SHARED_OBJECT_INIT_FAILED", 303},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that an OS call failed.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_OPERATING_SYSTEM", 304},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that a resource handle passed to the API call was not
|
||||||
|
* valid. Resource handles are opaque types like ::CUstream and ::CUevent.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_INVALID_HANDLE", 400},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that a named symbol was not found. Examples of symbols
|
||||||
|
* are global/constant variable names, texture names }, and surface names.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_NOT_FOUND", 500},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that asynchronous operations issued previously have not
|
||||||
|
* completed yet. This result is not actually an error, but must be
|
||||||
|
* indicated differently than ::CUDA_SUCCESS (which indicates completion).
|
||||||
|
* Calls that may return this value include ::cuEventQuery() and
|
||||||
|
* ::cuStreamQuery().
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_NOT_READY", 600},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* While executing a kernel, the device encountered a
|
||||||
|
* load or store instruction on an invalid memory address.
|
||||||
|
* This leaves the process in an inconsistent state and any further CUDA
|
||||||
|
* work will return the same error. To continue using CUDA, the process must
|
||||||
|
* be terminated and relaunched.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_ILLEGAL_ADDRESS", 700},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that a launch did not occur because it did not have
|
||||||
|
* appropriate resources. This error usually indicates that the user has
|
||||||
|
* attempted to pass too many arguments to the device kernel, or the
|
||||||
|
* kernel launch specifies too many threads for the kernel's register
|
||||||
|
* count. Passing arguments of the wrong size (i.e. a 64-bit pointer
|
||||||
|
* when a 32-bit int is expected) is equivalent to passing too many
|
||||||
|
* arguments and can also result in this error.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES", 701},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that the device kernel took too long to execute. This can
|
||||||
|
* only occur if timeouts are enabled - see the device attribute
|
||||||
|
* ::CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT for more information. The
|
||||||
|
* context cannot be used (and must be destroyed similar to
|
||||||
|
* ::CUDA_ERROR_LAUNCH_FAILED). All existing device memory allocations from
|
||||||
|
* this context are invalid and must be reconstructed if the program is to
|
||||||
|
* continue using CUDA.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_LAUNCH_TIMEOUT", 702},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This error indicates a kernel launch that uses an incompatible texturing
|
||||||
|
* mode.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING", 703},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This error indicates that a call to ::cuCtxEnablePeerAccess() is
|
||||||
|
* trying to re-enable peer access to a context which has already
|
||||||
|
* had peer access to it enabled.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED", 704},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This error indicates that ::cuCtxDisablePeerAccess() is
|
||||||
|
* trying to disable peer access which has not been enabled yet
|
||||||
|
* via ::cuCtxEnablePeerAccess().
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_PEER_ACCESS_NOT_ENABLED", 705},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This error indicates that the primary context for the specified device
|
||||||
|
* has already been initialized.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE", 708},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This error indicates that the context current to the calling thread
|
||||||
|
* has been destroyed using ::cuCtxDestroy }, or is a primary context which
|
||||||
|
* has not yet been initialized.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_CONTEXT_IS_DESTROYED", 709},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A device-side assert triggered during kernel execution. The context
|
||||||
|
* cannot be used anymore, and must be destroyed. All existing device
|
||||||
|
* memory allocations from this context are invalid and must be
|
||||||
|
* reconstructed if the program is to continue using CUDA.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_ASSERT", 710},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This error indicates that the hardware resources required to enable
|
||||||
|
* peer access have been exhausted for one or more of the devices
|
||||||
|
* passed to ::cuCtxEnablePeerAccess().
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_TOO_MANY_PEERS", 711},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This error indicates that the memory range passed to
|
||||||
|
* ::cuMemHostRegister() has already been registered.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED", 712},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This error indicates that the pointer passed to ::cuMemHostUnregister()
|
||||||
|
* does not correspond to any currently registered memory region.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED", 713},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* While executing a kernel, the device encountered a stack error.
|
||||||
|
* This can be due to stack corruption or exceeding the stack size limit.
|
||||||
|
* This leaves the process in an inconsistent state and any further CUDA
|
||||||
|
* work will return the same error. To continue using CUDA, the process must
|
||||||
|
* be terminated and relaunched.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_HARDWARE_STACK_ERROR", 714},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* While executing a kernel, the device encountered an illegal instruction.
|
||||||
|
* This leaves the process in an inconsistent state and any further CUDA
|
||||||
|
* work will return the same error. To continue using CUDA, the process must
|
||||||
|
* be terminated and relaunched.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_ILLEGAL_INSTRUCTION", 715},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* While executing a kernel, the device encountered a load or store
|
||||||
|
* instruction on a memory address which is not aligned. This leaves the
|
||||||
|
* process in an inconsistent state and any further CUDA work will return
|
||||||
|
* the same error. To continue using CUDA, the process must be terminated
|
||||||
|
* and relaunched.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_MISALIGNED_ADDRESS", 716},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* While executing a kernel, the device encountered an instruction
|
||||||
|
* which can only operate on memory locations in certain address spaces
|
||||||
|
* (global, shared, or local), but was supplied a memory address not
|
||||||
|
* belonging to an allowed address space.
|
||||||
|
* This leaves the process in an inconsistent state and any further CUDA
|
||||||
|
* work will return the same error. To continue using CUDA, the process must
|
||||||
|
* be terminated and relaunched.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_INVALID_ADDRESS_SPACE", 717},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* While executing a kernel, the device program counter wrapped its address
|
||||||
|
* space. This leaves the process in an inconsistent state and any further
|
||||||
|
* CUDA work will return the same error. To continue using CUDA, the process
|
||||||
|
* must be terminated and relaunched.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_INVALID_PC", 718},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An exception occurred on the device while executing a kernel. Common
|
||||||
|
* causes include dereferencing an invalid device pointer and accessing
|
||||||
|
* out of bounds shared memory. The context cannot be used }, so it must
|
||||||
|
* be destroyed (and a new one should be created). All existing device
|
||||||
|
* memory allocations from this context are invalid and must be
|
||||||
|
* reconstructed if the program is to continue using CUDA.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_LAUNCH_FAILED", 719},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This error indicates that the number of blocks launched per grid for a
|
||||||
|
* kernel that was launched via either ::cuLaunchCooperativeKernel or
|
||||||
|
* ::cuLaunchCooperativeKernelMultiDevice exceeds the maximum number of
|
||||||
|
* blocks as allowed by ::cuOccupancyMaxActiveBlocksPerMultiprocessor or
|
||||||
|
* ::cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags times the number
|
||||||
|
* of multiprocessors as specified by the device attribute
|
||||||
|
* ::CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE", 720},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This error indicates that the attempted operation is not permitted.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_NOT_PERMITTED", 800},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This error indicates that the attempted operation is not supported
|
||||||
|
* on the current system or device.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_NOT_SUPPORTED", 801},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This indicates that an unknown internal error has occurred.
|
||||||
|
*/
|
||||||
|
{"CUDA_ERROR_UNKNOWN", 999},
|
||||||
|
{NULL, -1}};
|
||||||
|
|
||||||
|
// This is just a linear search through the array, since the error_id's are not
|
||||||
|
// always ocurring consecutively
|
||||||
|
inline const char *getCudaDrvErrorString(CUresult error_id) {
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
while (sCudaDrvErrorString[index].error_id != error_id &&
|
||||||
|
sCudaDrvErrorString[index].error_id != -1) {
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sCudaDrvErrorString[index].error_id == error_id)
|
||||||
|
return (const char *)sCudaDrvErrorString[index].error_string;
|
||||||
|
else
|
||||||
|
return (const char *)"CUDA_ERROR not found!";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __cuda_cuda_h__
|
||||||
|
|
||||||
|
#endif // COMMON_DRVAPI_ERROR_STRING_H_
|
151
Common/exception.h
Normal file
151
Common/exception.h
Normal file
|
@ -0,0 +1,151 @@
|
||||||
|
/* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* CUda UTility Library */
|
||||||
|
#ifndef COMMON_EXCEPTION_H_
|
||||||
|
#define COMMON_EXCEPTION_H_
|
||||||
|
|
||||||
|
// includes, system
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <exception>
|
||||||
|
#include <iostream>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
//! Exception wrapper.
|
||||||
|
//! @param Std_Exception Exception out of namespace std for easy typing.
|
||||||
|
template <class Std_Exception>
|
||||||
|
class Exception : public Std_Exception {
|
||||||
|
public:
|
||||||
|
//! @brief Static construction interface
|
||||||
|
//! @return Alwayss throws ( Located_Exception<Exception>)
|
||||||
|
//! @param file file in which the Exception occurs
|
||||||
|
//! @param line line in which the Exception occurs
|
||||||
|
//! @param detailed details on the code fragment causing the Exception
|
||||||
|
static void throw_it(const char *file, const int line,
|
||||||
|
const char *detailed = "-");
|
||||||
|
|
||||||
|
//! Static construction interface
|
||||||
|
//! @return Alwayss throws ( Located_Exception<Exception>)
|
||||||
|
//! @param file file in which the Exception occurs
|
||||||
|
//! @param line line in which the Exception occurs
|
||||||
|
//! @param detailed details on the code fragment causing the Exception
|
||||||
|
static void throw_it(const char *file, const int line,
|
||||||
|
const std::string &detailed);
|
||||||
|
|
||||||
|
//! Destructor
|
||||||
|
virtual ~Exception() throw();
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! Constructor, default (private)
|
||||||
|
Exception();
|
||||||
|
|
||||||
|
//! Constructor, standard
|
||||||
|
//! @param str string returned by what()
|
||||||
|
explicit Exception(const std::string &str);
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Exception handler function for arbitrary exceptions
|
||||||
|
//! @param ex exception to handle
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <class Exception_Typ>
|
||||||
|
inline void handleException(const Exception_Typ &ex) {
|
||||||
|
std::cerr << ex.what() << std::endl;
|
||||||
|
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Convenience macros
|
||||||
|
|
||||||
|
//! Exception caused by dynamic program behavior, e.g. file does not exist
|
||||||
|
#define RUNTIME_EXCEPTION(msg) \
|
||||||
|
Exception<std::runtime_error>::throw_it(__FILE__, __LINE__, msg)
|
||||||
|
|
||||||
|
//! Logic exception in program, e.g. an assert failed
|
||||||
|
#define LOGIC_EXCEPTION(msg) \
|
||||||
|
Exception<std::logic_error>::throw_it(__FILE__, __LINE__, msg)
|
||||||
|
|
||||||
|
//! Out of range exception
|
||||||
|
#define RANGE_EXCEPTION(msg) \
|
||||||
|
Exception<std::range_error>::throw_it(__FILE__, __LINE__, msg)
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Implementation
|
||||||
|
|
||||||
|
// includes, system
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Static construction interface.
|
||||||
|
//! @param Exception causing code fragment (file and line) and detailed infos.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/*static*/ template <class Std_Exception>
|
||||||
|
void Exception<Std_Exception>::throw_it(const char *file, const int line,
|
||||||
|
const char *detailed) {
|
||||||
|
std::stringstream s;
|
||||||
|
|
||||||
|
// Quiet heavy-weight but exceptions are not for
|
||||||
|
// performance / release versions
|
||||||
|
s << "Exception in file '" << file << "' in line " << line << "\n"
|
||||||
|
<< "Detailed description: " << detailed << "\n";
|
||||||
|
|
||||||
|
throw Exception(s.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Static construction interface.
|
||||||
|
//! @param Exception causing code fragment (file and line) and detailed infos.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/*static*/ template <class Std_Exception>
|
||||||
|
void Exception<Std_Exception>::throw_it(const char *file, const int line,
|
||||||
|
const std::string &msg) {
|
||||||
|
throw_it(file, line, msg.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Constructor, default (private).
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <class Std_Exception>
|
||||||
|
Exception<Std_Exception>::Exception() : Std_Exception("Unknown Exception.\n") {}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Constructor, standard (private).
|
||||||
|
//! String returned by what().
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <class Std_Exception>
|
||||||
|
Exception<Std_Exception>::Exception(const std::string &s) : Std_Exception(s) {}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Destructor
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <class Std_Exception>
|
||||||
|
Exception<Std_Exception>::~Exception() throw() {}
|
||||||
|
|
||||||
|
// functions, exported
|
||||||
|
|
||||||
|
#endif // COMMON_EXCEPTION_H_
|
1341
Common/helper_cuda.h
Normal file
1341
Common/helper_cuda.h
Normal file
File diff suppressed because it is too large
Load Diff
419
Common/helper_cuda_drvapi.h
Normal file
419
Common/helper_cuda_drvapi.h
Normal file
|
@ -0,0 +1,419 @@
|
||||||
|
/* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Helper functions for CUDA Driver API error handling (make sure that CUDA_H is
|
||||||
|
// included in your projects)
|
||||||
|
#ifndef COMMON_HELPER_CUDA_DRVAPI_H_
|
||||||
|
#define COMMON_HELPER_CUDA_DRVAPI_H_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <drvapi_error_string.h>
|
||||||
|
#include <helper_string.h>
|
||||||
|
|
||||||
|
#ifndef MAX
|
||||||
|
#define MAX(a, b) (a > b ? a : b)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef COMMON_HELPER_CUDA_H_
|
||||||
|
inline int ftoi(float value) {
|
||||||
|
return (value >= 0 ? static_cast<int>(value + 0.5)
|
||||||
|
: static_cast<int>(value - 0.5));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EXIT_WAIVED
|
||||||
|
#define EXIT_WAIVED 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// These are CUDA Helper functions
|
||||||
|
|
||||||
|
// add a level of protection to the CUDA SDK samples, let's force samples to
|
||||||
|
// explicitly include CUDA.H
|
||||||
|
#ifdef __cuda_cuda_h__
|
||||||
|
// This will output the proper CUDA error strings in the event that a CUDA host
|
||||||
|
// call returns an error
|
||||||
|
#ifndef checkCudaErrors
|
||||||
|
#define checkCudaErrors(err) __checkCudaErrors(err, __FILE__, __LINE__)
|
||||||
|
|
||||||
|
// These are the inline versions for all of the SDK helper functions
|
||||||
|
inline void __checkCudaErrors(CUresult err, const char *file, const int line) {
|
||||||
|
if (CUDA_SUCCESS != err) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"checkCudaErrors() Driver API error = %04d \"%s\" from file <%s>, "
|
||||||
|
"line %i.\n",
|
||||||
|
err, getCudaDrvErrorString(err), file, line);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef getLastCudaDrvErrorMsg
|
||||||
|
#undef getLastCudaDrvErrorMsg
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define getLastCudaDrvErrorMsg(msg) \
|
||||||
|
__getLastCudaDrvErrorMsg(msg, __FILE__, __LINE__)
|
||||||
|
|
||||||
|
inline void __getLastCudaDrvErrorMsg(const char *msg, const char *file,
|
||||||
|
const int line) {
|
||||||
|
CUresult err = cuCtxSynchronize();
|
||||||
|
|
||||||
|
if (CUDA_SUCCESS != err) {
|
||||||
|
fprintf(stderr, "getLastCudaDrvErrorMsg -> %s", msg);
|
||||||
|
fprintf(stderr,
|
||||||
|
"getLastCudaDrvErrorMsg -> cuCtxSynchronize API error = %04d "
|
||||||
|
"\"%s\" in file <%s>, line %i.\n",
|
||||||
|
err, getCudaDrvErrorString(err), file, line);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This function wraps the CUDA Driver API into a template function
|
||||||
|
template <class T>
|
||||||
|
inline void getCudaAttribute(T *attribute, CUdevice_attribute device_attribute,
|
||||||
|
int device) {
|
||||||
|
CUresult error_result =
|
||||||
|
cuDeviceGetAttribute(attribute, device_attribute, device);
|
||||||
|
|
||||||
|
if (error_result != CUDA_SUCCESS) {
|
||||||
|
printf("cuDeviceGetAttribute returned %d\n-> %s\n",
|
||||||
|
static_cast<int>(error_result), getCudaDrvErrorString(error_result));
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Beginning of GPU Architecture definitions
|
||||||
|
inline int _ConvertSMVer2CoresDRV(int major, int minor) {
|
||||||
|
// Defines for GPU Architecture types (using the SM version to determine the #
|
||||||
|
// of cores per SM
|
||||||
|
typedef struct {
|
||||||
|
int SM; // 0xMm (hexidecimal notation), M = SM Major version, and m = SM
|
||||||
|
// minor version
|
||||||
|
int Cores;
|
||||||
|
} sSMtoCores;
|
||||||
|
|
||||||
|
sSMtoCores nGpuArchCoresPerSM[] = {
|
||||||
|
{0x30, 192}, // Kepler Generation (SM 3.0) GK10x class
|
||||||
|
{0x32, 192}, // Kepler Generation (SM 3.2) GK10x class
|
||||||
|
{0x35, 192}, // Kepler Generation (SM 3.5) GK11x class
|
||||||
|
{0x37, 192}, // Kepler Generation (SM 3.7) GK21x class
|
||||||
|
{0x50, 128}, // Maxwell Generation (SM 5.0) GM10x class
|
||||||
|
{0x52, 128}, // Maxwell Generation (SM 5.2) GM20x class
|
||||||
|
{0x53, 128}, // Maxwell Generation (SM 5.3) GM20x class
|
||||||
|
{0x60, 64}, // Pascal Generation (SM 6.0) GP100 class
|
||||||
|
{0x61, 128}, // Pascal Generation (SM 6.1) GP10x class
|
||||||
|
{0x62, 128}, // Pascal Generation (SM 6.2) GP10x class
|
||||||
|
{0x70, 64}, // Volta Generation (SM 7.0) GV100 class
|
||||||
|
{0x72, 64}, // Volta Generation (SM 7.2) GV11b class
|
||||||
|
{-1, -1}};
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
while (nGpuArchCoresPerSM[index].SM != -1) {
|
||||||
|
if (nGpuArchCoresPerSM[index].SM == ((major << 4) + minor)) {
|
||||||
|
return nGpuArchCoresPerSM[index].Cores;
|
||||||
|
}
|
||||||
|
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we don't find the values, we default use the previous one to run
|
||||||
|
// properly
|
||||||
|
printf(
|
||||||
|
"MapSMtoCores for SM %d.%d is undefined. Default to use %d Cores/SM\n",
|
||||||
|
major, minor, nGpuArchCoresPerSM[index - 1].Cores);
|
||||||
|
return nGpuArchCoresPerSM[index - 1].Cores;
|
||||||
|
}
|
||||||
|
// end of GPU Architecture definitions
|
||||||
|
|
||||||
|
#ifdef __cuda_cuda_h__
|
||||||
|
// General GPU Device CUDA Initialization
|
||||||
|
inline int gpuDeviceInitDRV(int ARGC, const char **ARGV) {
|
||||||
|
int cuDevice = 0;
|
||||||
|
int deviceCount = 0;
|
||||||
|
CUresult err = cuInit(0);
|
||||||
|
|
||||||
|
if (CUDA_SUCCESS == err) {
|
||||||
|
checkCudaErrors(cuDeviceGetCount(&deviceCount));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deviceCount == 0) {
|
||||||
|
fprintf(stderr, "cudaDeviceInit error: no devices supporting CUDA\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int dev = 0;
|
||||||
|
dev = getCmdLineArgumentInt(ARGC, (const char **)ARGV, "device=");
|
||||||
|
|
||||||
|
if (dev < 0) {
|
||||||
|
dev = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dev > deviceCount - 1) {
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
fprintf(stderr, ">> %d CUDA capable GPU device(s) detected. <<\n",
|
||||||
|
deviceCount);
|
||||||
|
fprintf(stderr,
|
||||||
|
">> cudaDeviceInit (-device=%d) is not a valid GPU device. <<\n",
|
||||||
|
dev);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
return -dev;
|
||||||
|
}
|
||||||
|
|
||||||
|
checkCudaErrors(cuDeviceGet(&cuDevice, dev));
|
||||||
|
char name[100];
|
||||||
|
cuDeviceGetName(name, 100, cuDevice);
|
||||||
|
|
||||||
|
int computeMode;
|
||||||
|
getCudaAttribute<int>(&computeMode, CU_DEVICE_ATTRIBUTE_COMPUTE_MODE, dev);
|
||||||
|
|
||||||
|
if (computeMode == CU_COMPUTEMODE_PROHIBITED) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Error: device is running in <CU_COMPUTEMODE_PROHIBITED>, no "
|
||||||
|
"threads can use this CUDA Device.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkCmdLineFlag(ARGC, (const char **)ARGV, "quiet") == false) {
|
||||||
|
printf("gpuDeviceInitDRV() Using CUDA Device [%d]: %s\n", dev, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dev;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This function returns the best GPU based on performance
|
||||||
|
inline int gpuGetMaxGflopsDeviceIdDRV() {
|
||||||
|
CUdevice current_device = 0;
|
||||||
|
CUdevice max_perf_device = 0;
|
||||||
|
int device_count = 0;
|
||||||
|
int sm_per_multiproc = 0;
|
||||||
|
unsigned long long max_compute_perf = 0;
|
||||||
|
int best_SM_arch = 0;
|
||||||
|
int major = 0;
|
||||||
|
int minor = 0;
|
||||||
|
int multiProcessorCount;
|
||||||
|
int clockRate;
|
||||||
|
int devices_prohibited = 0;
|
||||||
|
|
||||||
|
cuInit(0);
|
||||||
|
checkCudaErrors(cuDeviceGetCount(&device_count));
|
||||||
|
|
||||||
|
if (device_count == 0) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"gpuGetMaxGflopsDeviceIdDRV error: no devices supporting CUDA\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the best major SM Architecture GPU device
|
||||||
|
while (current_device < device_count) {
|
||||||
|
checkCudaErrors(cuDeviceGetAttribute(
|
||||||
|
&major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, current_device));
|
||||||
|
checkCudaErrors(cuDeviceGetAttribute(
|
||||||
|
&minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, current_device));
|
||||||
|
if (major > 0 && major < 9999) {
|
||||||
|
best_SM_arch = MAX(best_SM_arch, major);
|
||||||
|
}
|
||||||
|
|
||||||
|
current_device++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the best CUDA capable GPU device
|
||||||
|
current_device = 0;
|
||||||
|
|
||||||
|
while (current_device < device_count) {
|
||||||
|
checkCudaErrors(cuDeviceGetAttribute(
|
||||||
|
&multiProcessorCount, CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT,
|
||||||
|
current_device));
|
||||||
|
checkCudaErrors(cuDeviceGetAttribute(
|
||||||
|
&clockRate, CU_DEVICE_ATTRIBUTE_CLOCK_RATE, current_device));
|
||||||
|
checkCudaErrors(cuDeviceGetAttribute(
|
||||||
|
&major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, current_device));
|
||||||
|
checkCudaErrors(cuDeviceGetAttribute(
|
||||||
|
&minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, current_device));
|
||||||
|
|
||||||
|
int computeMode;
|
||||||
|
getCudaAttribute<int>(&computeMode, CU_DEVICE_ATTRIBUTE_COMPUTE_MODE,
|
||||||
|
current_device);
|
||||||
|
|
||||||
|
if (computeMode != CU_COMPUTEMODE_PROHIBITED) {
|
||||||
|
if (major == 9999 && minor == 9999) {
|
||||||
|
sm_per_multiproc = 1;
|
||||||
|
} else {
|
||||||
|
sm_per_multiproc = _ConvertSMVer2CoresDRV(major, minor);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long long compute_perf =
|
||||||
|
(unsigned long long)(multiProcessorCount * sm_per_multiproc *
|
||||||
|
clockRate);
|
||||||
|
|
||||||
|
if (compute_perf > max_compute_perf) {
|
||||||
|
// If we find GPU with SM major > 2, search only these
|
||||||
|
if (best_SM_arch > 2) {
|
||||||
|
// If our device==dest_SM_arch, choose this, or else pass
|
||||||
|
if (major == best_SM_arch) {
|
||||||
|
max_compute_perf = compute_perf;
|
||||||
|
max_perf_device = current_device;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
max_compute_perf = compute_perf;
|
||||||
|
max_perf_device = current_device;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
devices_prohibited++;
|
||||||
|
}
|
||||||
|
|
||||||
|
++current_device;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (devices_prohibited == device_count) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"gpuGetMaxGflopsDeviceIdDRV error: all devices have compute mode "
|
||||||
|
"prohibited.\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return max_perf_device;
|
||||||
|
}
|
||||||
|
|
||||||
|
// General initialization call to pick the best CUDA Device
|
||||||
|
inline CUdevice findCudaDeviceDRV(int argc, const char **argv) {
|
||||||
|
CUdevice cuDevice;
|
||||||
|
int devID = 0;
|
||||||
|
|
||||||
|
// If the command-line has a device number specified, use it
|
||||||
|
if (checkCmdLineFlag(argc, (const char **)argv, "device")) {
|
||||||
|
devID = gpuDeviceInitDRV(argc, argv);
|
||||||
|
|
||||||
|
if (devID < 0) {
|
||||||
|
printf("exiting...\n");
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Otherwise pick the device with highest Gflops/s
|
||||||
|
char name[100];
|
||||||
|
devID = gpuGetMaxGflopsDeviceIdDRV();
|
||||||
|
checkCudaErrors(cuDeviceGet(&cuDevice, devID));
|
||||||
|
cuDeviceGetName(name, 100, cuDevice);
|
||||||
|
printf("> Using CUDA Device [%d]: %s\n", devID, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
cuDeviceGet(&cuDevice, devID);
|
||||||
|
|
||||||
|
return cuDevice;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline CUdevice findIntegratedGPUDrv() {
|
||||||
|
CUdevice current_device = 0;
|
||||||
|
int device_count = 0;
|
||||||
|
int devices_prohibited = 0;
|
||||||
|
int isIntegrated;
|
||||||
|
|
||||||
|
cuInit(0);
|
||||||
|
checkCudaErrors(cuDeviceGetCount(&device_count));
|
||||||
|
|
||||||
|
if (device_count == 0) {
|
||||||
|
fprintf(stderr, "CUDA error: no devices supporting CUDA.\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the integrated GPU which is compute capable
|
||||||
|
while (current_device < device_count) {
|
||||||
|
int computeMode = -1;
|
||||||
|
checkCudaErrors(cuDeviceGetAttribute(
|
||||||
|
&isIntegrated, CU_DEVICE_ATTRIBUTE_INTEGRATED, current_device));
|
||||||
|
checkCudaErrors(cuDeviceGetAttribute(
|
||||||
|
&computeMode, CU_DEVICE_ATTRIBUTE_COMPUTE_MODE, current_device));
|
||||||
|
|
||||||
|
// If GPU is integrated and is not running on Compute Mode prohibited use
|
||||||
|
// that
|
||||||
|
if (isIntegrated && (computeMode != CU_COMPUTEMODE_PROHIBITED)) {
|
||||||
|
int major = 0, minor = 0;
|
||||||
|
char deviceName[256];
|
||||||
|
checkCudaErrors(cuDeviceGetAttribute(
|
||||||
|
&major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR,
|
||||||
|
current_device));
|
||||||
|
checkCudaErrors(cuDeviceGetAttribute(
|
||||||
|
&minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR,
|
||||||
|
current_device));
|
||||||
|
checkCudaErrors(cuDeviceGetName(deviceName, 256, current_device));
|
||||||
|
printf("GPU Device %d: \"%s\" with compute capability %d.%d\n\n",
|
||||||
|
current_device, deviceName, major, minor);
|
||||||
|
|
||||||
|
return current_device;
|
||||||
|
} else {
|
||||||
|
devices_prohibited++;
|
||||||
|
}
|
||||||
|
|
||||||
|
current_device++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (devices_prohibited == device_count) {
|
||||||
|
fprintf(stderr, "CUDA error: No Integrated CUDA capable GPU found.\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// General check for CUDA GPU SM Capabilities
|
||||||
|
inline bool checkCudaCapabilitiesDRV(int major_version, int minor_version,
|
||||||
|
int devID) {
|
||||||
|
CUdevice cuDevice;
|
||||||
|
char name[256];
|
||||||
|
int major = 0, minor = 0;
|
||||||
|
|
||||||
|
checkCudaErrors(cuDeviceGet(&cuDevice, devID));
|
||||||
|
checkCudaErrors(cuDeviceGetName(name, 100, cuDevice));
|
||||||
|
checkCudaErrors(cuDeviceGetAttribute(
|
||||||
|
&major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, cuDevice));
|
||||||
|
checkCudaErrors(cuDeviceGetAttribute(
|
||||||
|
&minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, cuDevice));
|
||||||
|
|
||||||
|
if ((major > major_version) ||
|
||||||
|
(major == major_version && minor >= minor_version)) {
|
||||||
|
printf("> Device %d: <%16s >, Compute SM %d.%d detected\n", devID, name,
|
||||||
|
major, minor);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
printf(
|
||||||
|
"No GPU device was found that can support CUDA compute capability "
|
||||||
|
"%d.%d.\n",
|
||||||
|
major_version, minor_version);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// end of CUDA Helper Functions
|
||||||
|
|
||||||
|
#endif // COMMON_HELPER_CUDA_DRVAPI_H_
|
59
Common/helper_functions.h
Normal file
59
Common/helper_functions.h
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
/* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// These are helper functions for the SDK samples (string parsing,
|
||||||
|
// timers, image helpers, etc)
|
||||||
|
#ifndef COMMON_HELPER_FUNCTIONS_H_
|
||||||
|
#define COMMON_HELPER_FUNCTIONS_H_
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#pragma warning(disable : 4996)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// includes, project
|
||||||
|
#include <assert.h>
|
||||||
|
#include <exception.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
// includes, timer, string parsing, image helpers
|
||||||
|
#include <helper_image.h> // helper functions for image compare, dump, data comparisons
|
||||||
|
#include <helper_string.h> // helper functions for string parsing
|
||||||
|
#include <helper_timer.h> // helper functions for timers
|
||||||
|
|
||||||
|
#ifndef EXIT_WAIVED
|
||||||
|
#define EXIT_WAIVED 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // COMMON_HELPER_FUNCTIONS_H_
|
1001
Common/helper_image.h
Normal file
1001
Common/helper_image.h
Normal file
File diff suppressed because it is too large
Load Diff
699
Common/helper_string.h
Normal file
699
Common/helper_string.h
Normal file
|
@ -0,0 +1,699 @@
|
||||||
|
/* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// These are helper functions for the SDK samples (string parsing, timers, etc)
|
||||||
|
#ifndef COMMON_HELPER_STRING_H_
|
||||||
|
#define COMMON_HELPER_STRING_H_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
|
||||||
|
#ifndef _CRT_SECURE_NO_DEPRECATE
|
||||||
|
#define _CRT_SECURE_NO_DEPRECATE
|
||||||
|
#endif
|
||||||
|
#ifndef STRCASECMP
|
||||||
|
#define STRCASECMP _stricmp
|
||||||
|
#endif
|
||||||
|
#ifndef STRNCASECMP
|
||||||
|
#define STRNCASECMP _strnicmp
|
||||||
|
#endif
|
||||||
|
#ifndef STRCPY
|
||||||
|
#define STRCPY(sFilePath, nLength, sPath) strcpy_s(sFilePath, nLength, sPath)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef FOPEN
|
||||||
|
#define FOPEN(fHandle, filename, mode) fopen_s(&fHandle, filename, mode)
|
||||||
|
#endif
|
||||||
|
#ifndef FOPEN_FAIL
|
||||||
|
#define FOPEN_FAIL(result) (result != 0)
|
||||||
|
#endif
|
||||||
|
#ifndef SSCANF
|
||||||
|
#define SSCANF sscanf_s
|
||||||
|
#endif
|
||||||
|
#ifndef SPRINTF
|
||||||
|
#define SPRINTF sprintf_s
|
||||||
|
#endif
|
||||||
|
#else // Linux Includes
|
||||||
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
|
|
||||||
|
#ifndef STRCASECMP
|
||||||
|
#define STRCASECMP strcasecmp
|
||||||
|
#endif
|
||||||
|
#ifndef STRNCASECMP
|
||||||
|
#define STRNCASECMP strncasecmp
|
||||||
|
#endif
|
||||||
|
#ifndef STRCPY
|
||||||
|
#define STRCPY(sFilePath, nLength, sPath) strcpy(sFilePath, sPath)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef FOPEN
|
||||||
|
#define FOPEN(fHandle, filename, mode) (fHandle = fopen(filename, mode))
|
||||||
|
#endif
|
||||||
|
#ifndef FOPEN_FAIL
|
||||||
|
#define FOPEN_FAIL(result) (result == NULL)
|
||||||
|
#endif
|
||||||
|
#ifndef SSCANF
|
||||||
|
#define SSCANF sscanf
|
||||||
|
#endif
|
||||||
|
#ifndef SPRINTF
|
||||||
|
#define SPRINTF sprintf
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EXIT_WAIVED
|
||||||
|
#define EXIT_WAIVED 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// CUDA Utility Helper Functions
|
||||||
|
inline int stringRemoveDelimiter(char delimiter, const char *string) {
|
||||||
|
int string_start = 0;
|
||||||
|
|
||||||
|
while (string[string_start] == delimiter) {
|
||||||
|
string_start++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string_start >= static_cast<int>(strlen(string) - 1)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return string_start;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int getFileExtension(char *filename, char **extension) {
|
||||||
|
int string_length = static_cast<int>(strlen(filename));
|
||||||
|
|
||||||
|
while (filename[string_length--] != '.') {
|
||||||
|
if (string_length == 0) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string_length > 0) string_length += 2;
|
||||||
|
|
||||||
|
if (string_length == 0)
|
||||||
|
*extension = NULL;
|
||||||
|
else
|
||||||
|
*extension = &filename[string_length];
|
||||||
|
|
||||||
|
return string_length;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool checkCmdLineFlag(const int argc, const char **argv,
|
||||||
|
const char *string_ref) {
|
||||||
|
bool bFound = false;
|
||||||
|
|
||||||
|
if (argc >= 1) {
|
||||||
|
for (int i = 1; i < argc; i++) {
|
||||||
|
int string_start = stringRemoveDelimiter('-', argv[i]);
|
||||||
|
const char *string_argv = &argv[i][string_start];
|
||||||
|
|
||||||
|
const char *equal_pos = strchr(string_argv, '=');
|
||||||
|
int argv_length = static_cast<int>(
|
||||||
|
equal_pos == 0 ? strlen(string_argv) : equal_pos - string_argv);
|
||||||
|
|
||||||
|
int length = static_cast<int>(strlen(string_ref));
|
||||||
|
|
||||||
|
if (length == argv_length &&
|
||||||
|
!STRNCASECMP(string_argv, string_ref, length)) {
|
||||||
|
bFound = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return bFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This function wraps the CUDA Driver API into a template function
|
||||||
|
template <class T>
|
||||||
|
inline bool getCmdLineArgumentValue(const int argc, const char **argv,
|
||||||
|
const char *string_ref, T *value) {
|
||||||
|
bool bFound = false;
|
||||||
|
|
||||||
|
if (argc >= 1) {
|
||||||
|
for (int i = 1; i < argc; i++) {
|
||||||
|
int string_start = stringRemoveDelimiter('-', argv[i]);
|
||||||
|
const char *string_argv = &argv[i][string_start];
|
||||||
|
int length = static_cast<int>(strlen(string_ref));
|
||||||
|
|
||||||
|
if (!STRNCASECMP(string_argv, string_ref, length)) {
|
||||||
|
if (length + 1 <= static_cast<int>(strlen(string_argv))) {
|
||||||
|
int auto_inc = (string_argv[length] == '=') ? 1 : 0;
|
||||||
|
*value = (T)atoi(&string_argv[length + auto_inc]);
|
||||||
|
}
|
||||||
|
|
||||||
|
bFound = true;
|
||||||
|
i = argc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return bFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int getCmdLineArgumentInt(const int argc, const char **argv,
|
||||||
|
const char *string_ref) {
|
||||||
|
bool bFound = false;
|
||||||
|
int value = -1;
|
||||||
|
|
||||||
|
if (argc >= 1) {
|
||||||
|
for (int i = 1; i < argc; i++) {
|
||||||
|
int string_start = stringRemoveDelimiter('-', argv[i]);
|
||||||
|
const char *string_argv = &argv[i][string_start];
|
||||||
|
int length = static_cast<int>(strlen(string_ref));
|
||||||
|
|
||||||
|
if (!STRNCASECMP(string_argv, string_ref, length)) {
|
||||||
|
if (length + 1 <= static_cast<int>(strlen(string_argv))) {
|
||||||
|
int auto_inc = (string_argv[length] == '=') ? 1 : 0;
|
||||||
|
value = atoi(&string_argv[length + auto_inc]);
|
||||||
|
} else {
|
||||||
|
value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bFound = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bFound) {
|
||||||
|
return value;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float getCmdLineArgumentFloat(const int argc, const char **argv,
|
||||||
|
const char *string_ref) {
|
||||||
|
bool bFound = false;
|
||||||
|
float value = -1;
|
||||||
|
|
||||||
|
if (argc >= 1) {
|
||||||
|
for (int i = 1; i < argc; i++) {
|
||||||
|
int string_start = stringRemoveDelimiter('-', argv[i]);
|
||||||
|
const char *string_argv = &argv[i][string_start];
|
||||||
|
int length = static_cast<int>(strlen(string_ref));
|
||||||
|
|
||||||
|
if (!STRNCASECMP(string_argv, string_ref, length)) {
|
||||||
|
if (length + 1 <= static_cast<int>(strlen(string_argv))) {
|
||||||
|
int auto_inc = (string_argv[length] == '=') ? 1 : 0;
|
||||||
|
value = static_cast<float>(atof(&string_argv[length + auto_inc]));
|
||||||
|
} else {
|
||||||
|
value = 0.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
bFound = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bFound) {
|
||||||
|
return value;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool getCmdLineArgumentString(const int argc, const char **argv,
|
||||||
|
const char *string_ref,
|
||||||
|
char **string_retval) {
|
||||||
|
bool bFound = false;
|
||||||
|
|
||||||
|
if (argc >= 1) {
|
||||||
|
for (int i = 1; i < argc; i++) {
|
||||||
|
int string_start = stringRemoveDelimiter('-', argv[i]);
|
||||||
|
char *string_argv = const_cast<char*>(&argv[i][string_start]);
|
||||||
|
int length = static_cast<int>(strlen(string_ref));
|
||||||
|
|
||||||
|
if (!STRNCASECMP(string_argv, string_ref, length)) {
|
||||||
|
*string_retval = &string_argv[length + 1];
|
||||||
|
bFound = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bFound) {
|
||||||
|
*string_retval = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Find the path for a file assuming that
|
||||||
|
//! files are found in the searchPath.
|
||||||
|
//!
|
||||||
|
//! @return the path if succeeded, otherwise 0
|
||||||
|
//! @param filename name of the file
|
||||||
|
//! @param executable_path optional absolute path of the executable
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
inline char *sdkFindFilePath(const char *filename,
|
||||||
|
const char *executable_path) {
|
||||||
|
// <executable_name> defines a variable that is replaced with the name of the
|
||||||
|
// executable
|
||||||
|
|
||||||
|
// Typical relative search paths to locate needed companion files (e.g. sample
|
||||||
|
// input data, or JIT source files) The origin for the relative search may be
|
||||||
|
// the .exe file, a .bat file launching an .exe, a browser .exe launching the
|
||||||
|
// .exe or .bat, etc
|
||||||
|
const char *searchPath[] = {
|
||||||
|
"./", // same dir
|
||||||
|
"./<executable_name>_data_files/",
|
||||||
|
"./common/", // "/common/" subdir
|
||||||
|
"./common/data/", // "/common/data/" subdir
|
||||||
|
"./data/", // "/data/" subdir
|
||||||
|
"./src/", // "/src/" subdir
|
||||||
|
"./src/<executable_name>/data/", // "/src/<executable_name>/data/" subdir
|
||||||
|
"./inc/", // "/inc/" subdir
|
||||||
|
"./0_Simple/", // "/0_Simple/" subdir
|
||||||
|
"./1_Utilities/", // "/1_Utilities/" subdir
|
||||||
|
"./2_Graphics/", // "/2_Graphics/" subdir
|
||||||
|
"./3_Imaging/", // "/3_Imaging/" subdir
|
||||||
|
"./4_Finance/", // "/4_Finance/" subdir
|
||||||
|
"./5_Simulations/", // "/5_Simulations/" subdir
|
||||||
|
"./6_Advanced/", // "/6_Advanced/" subdir
|
||||||
|
"./7_CUDALibraries/", // "/7_CUDALibraries/" subdir
|
||||||
|
"./8_Android/", // "/8_Android/" subdir
|
||||||
|
"./samples/", // "/samples/" subdir
|
||||||
|
|
||||||
|
"./0_Simple/<executable_name>/data/", // "/0_Simple/<executable_name>/data/"
|
||||||
|
// subdir
|
||||||
|
"./1_Utilities/<executable_name>/data/", // "/1_Utilities/<executable_name>/data/"
|
||||||
|
// subdir
|
||||||
|
"./2_Graphics/<executable_name>/data/", // "/2_Graphics/<executable_name>/data/"
|
||||||
|
// subdir
|
||||||
|
"./3_Imaging/<executable_name>/data/", // "/3_Imaging/<executable_name>/data/"
|
||||||
|
// subdir
|
||||||
|
"./4_Finance/<executable_name>/data/", // "/4_Finance/<executable_name>/data/"
|
||||||
|
// subdir
|
||||||
|
"./5_Simulations/<executable_name>/data/", // "/5_Simulations/<executable_name>/data/"
|
||||||
|
// subdir
|
||||||
|
"./6_Advanced/<executable_name>/data/", // "/6_Advanced/<executable_name>/data/"
|
||||||
|
// subdir
|
||||||
|
"./7_CUDALibraries/<executable_name>/", // "/7_CUDALibraries/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"./7_CUDALibraries/<executable_name>/data/", // "/7_CUDALibraries/<executable_name>/data/"
|
||||||
|
// subdir
|
||||||
|
|
||||||
|
"../", // up 1 in tree
|
||||||
|
"../common/", // up 1 in tree, "/common/" subdir
|
||||||
|
"../common/data/", // up 1 in tree, "/common/data/" subdir
|
||||||
|
"../data/", // up 1 in tree, "/data/" subdir
|
||||||
|
"../src/", // up 1 in tree, "/src/" subdir
|
||||||
|
"../inc/", // up 1 in tree, "/inc/" subdir
|
||||||
|
|
||||||
|
"../0_Simple/<executable_name>/data/", // up 1 in tree,
|
||||||
|
// "/0_Simple/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../1_Utilities/<executable_name>/data/", // up 1 in tree,
|
||||||
|
// "/1_Utilities/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../2_Graphics/<executable_name>/data/", // up 1 in tree,
|
||||||
|
// "/2_Graphics/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../3_Imaging/<executable_name>/data/", // up 1 in tree,
|
||||||
|
// "/3_Imaging/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../4_Finance/<executable_name>/data/", // up 1 in tree,
|
||||||
|
// "/4_Finance/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../5_Simulations/<executable_name>/data/", // up 1 in tree,
|
||||||
|
// "/5_Simulations/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../6_Advanced/<executable_name>/data/", // up 1 in tree,
|
||||||
|
// "/6_Advanced/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../7_CUDALibraries/<executable_name>/data/", // up 1 in tree,
|
||||||
|
// "/7_CUDALibraries/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../8_Android/<executable_name>/data/", // up 1 in tree,
|
||||||
|
// "/8_Android/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../samples/<executable_name>/data/", // up 1 in tree,
|
||||||
|
// "/samples/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../", // up 2 in tree
|
||||||
|
"../../common/", // up 2 in tree, "/common/" subdir
|
||||||
|
"../../common/data/", // up 2 in tree, "/common/data/" subdir
|
||||||
|
"../../data/", // up 2 in tree, "/data/" subdir
|
||||||
|
"../../src/", // up 2 in tree, "/src/" subdir
|
||||||
|
"../../inc/", // up 2 in tree, "/inc/" subdir
|
||||||
|
"../../sandbox/<executable_name>/data/", // up 2 in tree,
|
||||||
|
// "/sandbox/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../0_Simple/<executable_name>/data/", // up 2 in tree,
|
||||||
|
// "/0_Simple/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../1_Utilities/<executable_name>/data/", // up 2 in tree,
|
||||||
|
// "/1_Utilities/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../2_Graphics/<executable_name>/data/", // up 2 in tree,
|
||||||
|
// "/2_Graphics/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../3_Imaging/<executable_name>/data/", // up 2 in tree,
|
||||||
|
// "/3_Imaging/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../4_Finance/<executable_name>/data/", // up 2 in tree,
|
||||||
|
// "/4_Finance/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../5_Simulations/<executable_name>/data/", // up 2 in tree,
|
||||||
|
// "/5_Simulations/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../6_Advanced/<executable_name>/data/", // up 2 in tree,
|
||||||
|
// "/6_Advanced/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../7_CUDALibraries/<executable_name>/data/", // up 2 in tree,
|
||||||
|
// "/7_CUDALibraries/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../8_Android/<executable_name>/data/", // up 2 in tree,
|
||||||
|
// "/8_Android/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../samples/<executable_name>/data/", // up 2 in tree,
|
||||||
|
// "/samples/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../", // up 3 in tree
|
||||||
|
"../../../src/<executable_name>/", // up 3 in tree,
|
||||||
|
// "/src/<executable_name>/" subdir
|
||||||
|
"../../../src/<executable_name>/data/", // up 3 in tree,
|
||||||
|
// "/src/<executable_name>/data/"
|
||||||
|
// subdir
|
||||||
|
"../../../src/<executable_name>/src/", // up 3 in tree,
|
||||||
|
// "/src/<executable_name>/src/"
|
||||||
|
// subdir
|
||||||
|
"../../../src/<executable_name>/inc/", // up 3 in tree,
|
||||||
|
// "/src/<executable_name>/inc/"
|
||||||
|
// subdir
|
||||||
|
"../../../sandbox/<executable_name>/", // up 3 in tree,
|
||||||
|
// "/sandbox/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../sandbox/<executable_name>/data/", // up 3 in tree,
|
||||||
|
// "/sandbox/<executable_name>/data/"
|
||||||
|
// subdir
|
||||||
|
"../../../sandbox/<executable_name>/src/", // up 3 in tree,
|
||||||
|
// "/sandbox/<executable_name>/src/"
|
||||||
|
// subdir
|
||||||
|
"../../../sandbox/<executable_name>/inc/", // up 3 in tree,
|
||||||
|
// "/sandbox/<executable_name>/inc/"
|
||||||
|
// subdir
|
||||||
|
"../../../0_Simple/<executable_name>/data/", // up 3 in tree,
|
||||||
|
// "/0_Simple/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../1_Utilities/<executable_name>/data/", // up 3 in tree,
|
||||||
|
// "/1_Utilities/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../2_Graphics/<executable_name>/data/", // up 3 in tree,
|
||||||
|
// "/2_Graphics/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../3_Imaging/<executable_name>/data/", // up 3 in tree,
|
||||||
|
// "/3_Imaging/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../4_Finance/<executable_name>/data/", // up 3 in tree,
|
||||||
|
// "/4_Finance/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../5_Simulations/<executable_name>/data/", // up 3 in tree,
|
||||||
|
// "/5_Simulations/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../6_Advanced/<executable_name>/data/", // up 3 in tree,
|
||||||
|
// "/6_Advanced/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../7_CUDALibraries/<executable_name>/data/", // up 3 in tree,
|
||||||
|
// "/7_CUDALibraries/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../8_Android/<executable_name>/data/", // up 3 in tree,
|
||||||
|
// "/8_Android/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../0_Simple/<executable_name>/", // up 3 in tree,
|
||||||
|
// "/0_Simple/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../1_Utilities/<executable_name>/", // up 3 in tree,
|
||||||
|
// "/1_Utilities/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../2_Graphics/<executable_name>/", // up 3 in tree,
|
||||||
|
// "/2_Graphics/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../3_Imaging/<executable_name>/", // up 3 in tree,
|
||||||
|
// "/3_Imaging/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../4_Finance/<executable_name>/", // up 3 in tree,
|
||||||
|
// "/4_Finance/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../5_Simulations/<executable_name>/", // up 3 in tree,
|
||||||
|
// "/5_Simulations/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../6_Advanced/<executable_name>/", // up 3 in tree,
|
||||||
|
// "/6_Advanced/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../7_CUDALibraries/<executable_name>/", // up 3 in tree,
|
||||||
|
// "/7_CUDALibraries/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../8_Android/<executable_name>/", // up 3 in tree,
|
||||||
|
// "/8_Android/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../samples/<executable_name>/data/", // up 3 in tree,
|
||||||
|
// "/samples/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../common/", // up 3 in tree, "../../../common/" subdir
|
||||||
|
"../../../common/data/", // up 3 in tree, "../../../common/data/" subdir
|
||||||
|
"../../../data/", // up 3 in tree, "../../../data/" subdir
|
||||||
|
"../../../../", // up 4 in tree
|
||||||
|
"../../../../src/<executable_name>/", // up 4 in tree,
|
||||||
|
// "/src/<executable_name>/" subdir
|
||||||
|
"../../../../src/<executable_name>/data/", // up 4 in tree,
|
||||||
|
// "/src/<executable_name>/data/"
|
||||||
|
// subdir
|
||||||
|
"../../../../src/<executable_name>/src/", // up 4 in tree,
|
||||||
|
// "/src/<executable_name>/src/"
|
||||||
|
// subdir
|
||||||
|
"../../../../src/<executable_name>/inc/", // up 4 in tree,
|
||||||
|
// "/src/<executable_name>/inc/"
|
||||||
|
// subdir
|
||||||
|
"../../../../sandbox/<executable_name>/", // up 4 in tree,
|
||||||
|
// "/sandbox/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../sandbox/<executable_name>/data/", // up 4 in tree,
|
||||||
|
// "/sandbox/<executable_name>/data/"
|
||||||
|
// subdir
|
||||||
|
"../../../../sandbox/<executable_name>/src/", // up 4 in tree,
|
||||||
|
// "/sandbox/<executable_name>/src/"
|
||||||
|
// subdir
|
||||||
|
"../../../../sandbox/<executable_name>/inc/", // up 4 in tree,
|
||||||
|
// "/sandbox/<executable_name>/inc/"
|
||||||
|
// subdir
|
||||||
|
"../../../../0_Simple/<executable_name>/data/", // up 4 in tree,
|
||||||
|
// "/0_Simple/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../1_Utilities/<executable_name>/data/", // up 4 in tree,
|
||||||
|
// "/1_Utilities/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../2_Graphics/<executable_name>/data/", // up 4 in tree,
|
||||||
|
// "/2_Graphics/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../3_Imaging/<executable_name>/data/", // up 4 in tree,
|
||||||
|
// "/3_Imaging/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../4_Finance/<executable_name>/data/", // up 4 in tree,
|
||||||
|
// "/4_Finance/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../5_Simulations/<executable_name>/data/", // up 4 in tree,
|
||||||
|
// "/5_Simulations/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../6_Advanced/<executable_name>/data/", // up 4 in tree,
|
||||||
|
// "/6_Advanced/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../7_CUDALibraries/<executable_name>/data/", // up 4 in tree,
|
||||||
|
// "/7_CUDALibraries/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../8_Android/<executable_name>/data/", // up 4 in tree,
|
||||||
|
// "/8_Android/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../0_Simple/<executable_name>/", // up 4 in tree,
|
||||||
|
// "/0_Simple/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../1_Utilities/<executable_name>/", // up 4 in tree,
|
||||||
|
// "/1_Utilities/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../2_Graphics/<executable_name>/", // up 4 in tree,
|
||||||
|
// "/2_Graphics/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../3_Imaging/<executable_name>/", // up 4 in tree,
|
||||||
|
// "/3_Imaging/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../4_Finance/<executable_name>/", // up 4 in tree,
|
||||||
|
// "/4_Finance/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../5_Simulations/<executable_name>/", // up 4 in tree,
|
||||||
|
// "/5_Simulations/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../6_Advanced/<executable_name>/", // up 4 in tree,
|
||||||
|
// "/6_Advanced/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../7_CUDALibraries/<executable_name>/", // up 4 in tree,
|
||||||
|
// "/7_CUDALibraries/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../8_Android/<executable_name>/", // up 4 in tree,
|
||||||
|
// "/8_Android/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../samples/<executable_name>/data/", // up 4 in tree,
|
||||||
|
// "/samples/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../common/", // up 4 in tree, "../../../common/" subdir
|
||||||
|
"../../../../common/data/", // up 4 in tree, "../../../common/data/"
|
||||||
|
// subdir
|
||||||
|
"../../../../data/", // up 4 in tree, "../../../data/" subdir
|
||||||
|
"../../../../../", // up 5 in tree
|
||||||
|
"../../../../../src/<executable_name>/", // up 5 in tree,
|
||||||
|
// "/src/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../../src/<executable_name>/data/", // up 5 in tree,
|
||||||
|
// "/src/<executable_name>/data/"
|
||||||
|
// subdir
|
||||||
|
"../../../../../src/<executable_name>/src/", // up 5 in tree,
|
||||||
|
// "/src/<executable_name>/src/"
|
||||||
|
// subdir
|
||||||
|
"../../../../../src/<executable_name>/inc/", // up 5 in tree,
|
||||||
|
// "/src/<executable_name>/inc/"
|
||||||
|
// subdir
|
||||||
|
"../../../../../sandbox/<executable_name>/", // up 5 in tree,
|
||||||
|
// "/sandbox/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../../sandbox/<executable_name>/data/", // up 5 in tree,
|
||||||
|
// "/sandbox/<executable_name>/data/"
|
||||||
|
// subdir
|
||||||
|
"../../../../../sandbox/<executable_name>/src/", // up 5 in tree,
|
||||||
|
// "/sandbox/<executable_name>/src/"
|
||||||
|
// subdir
|
||||||
|
"../../../../../sandbox/<executable_name>/inc/", // up 5 in tree,
|
||||||
|
// "/sandbox/<executable_name>/inc/"
|
||||||
|
// subdir
|
||||||
|
"../../../../../0_Simple/<executable_name>/data/", // up 5 in tree,
|
||||||
|
// "/0_Simple/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../../1_Utilities/<executable_name>/data/", // up 5 in tree,
|
||||||
|
// "/1_Utilities/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../../2_Graphics/<executable_name>/data/", // up 5 in tree,
|
||||||
|
// "/2_Graphics/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../../3_Imaging/<executable_name>/data/", // up 5 in tree,
|
||||||
|
// "/3_Imaging/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../../4_Finance/<executable_name>/data/", // up 5 in tree,
|
||||||
|
// "/4_Finance/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../../5_Simulations/<executable_name>/data/", // up 5 in tree,
|
||||||
|
// "/5_Simulations/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../../6_Advanced/<executable_name>/data/", // up 5 in tree,
|
||||||
|
// "/6_Advanced/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../../7_CUDALibraries/<executable_name>/data/", // up 5 in
|
||||||
|
// tree,
|
||||||
|
// "/7_CUDALibraries/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../../8_Android/<executable_name>/data/", // up 5 in tree,
|
||||||
|
// "/8_Android/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../../samples/<executable_name>/data/", // up 5 in tree,
|
||||||
|
// "/samples/<executable_name>/"
|
||||||
|
// subdir
|
||||||
|
"../../../../../common/", // up 5 in tree, "../../../common/" subdir
|
||||||
|
"../../../../../common/data/", // up 5 in tree, "../../../common/data/"
|
||||||
|
// subdir
|
||||||
|
};
|
||||||
|
|
||||||
|
// Extract the executable name
|
||||||
|
std::string executable_name;
|
||||||
|
|
||||||
|
if (executable_path != 0) {
|
||||||
|
executable_name = std::string(executable_path);
|
||||||
|
|
||||||
|
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
|
||||||
|
// Windows path delimiter
|
||||||
|
size_t delimiter_pos = executable_name.find_last_of('\\');
|
||||||
|
executable_name.erase(0, delimiter_pos + 1);
|
||||||
|
|
||||||
|
if (executable_name.rfind(".exe") != std::string::npos) {
|
||||||
|
// we strip .exe, only if the .exe is found
|
||||||
|
executable_name.resize(executable_name.size() - 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
// Linux & OSX path delimiter
|
||||||
|
size_t delimiter_pos = executable_name.find_last_of('/');
|
||||||
|
executable_name.erase(0, delimiter_pos + 1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Loop over all search paths and return the first hit
|
||||||
|
for (unsigned int i = 0; i < sizeof(searchPath) / sizeof(char *); ++i) {
|
||||||
|
std::string path(searchPath[i]);
|
||||||
|
size_t executable_name_pos = path.find("<executable_name>");
|
||||||
|
|
||||||
|
// If there is executable_name variable in the searchPath
|
||||||
|
// replace it with the value
|
||||||
|
if (executable_name_pos != std::string::npos) {
|
||||||
|
if (executable_path != 0) {
|
||||||
|
path.replace(executable_name_pos, strlen("<executable_name>"),
|
||||||
|
executable_name);
|
||||||
|
} else {
|
||||||
|
// Skip this path entry if no executable argument is given
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
printf("sdkFindFilePath <%s> in %s\n", filename, path.c_str());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Test if the file exists
|
||||||
|
path.append(filename);
|
||||||
|
FILE *fp;
|
||||||
|
FOPEN(fp, path.c_str(), "rb");
|
||||||
|
|
||||||
|
if (fp != NULL) {
|
||||||
|
fclose(fp);
|
||||||
|
// File found
|
||||||
|
// returning an allocated array here for backwards compatibility reasons
|
||||||
|
char *file_path = reinterpret_cast<char *>(malloc(path.length() + 1));
|
||||||
|
STRCPY(file_path, path.length() + 1, path.c_str());
|
||||||
|
return file_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fp) {
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// File not found
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // COMMON_HELPER_STRING_H_
|
465
Common/helper_timer.h
Normal file
465
Common/helper_timer.h
Normal file
|
@ -0,0 +1,465 @@
|
||||||
|
/* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Helper Timing Functions
|
||||||
|
#ifndef COMMON_HELPER_TIMER_H_
|
||||||
|
#define COMMON_HELPER_TIMER_H_
|
||||||
|
|
||||||
|
#ifndef EXIT_WAIVED
|
||||||
|
#define EXIT_WAIVED 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// includes, system
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
// includes, project
|
||||||
|
#include <exception.h>
|
||||||
|
|
||||||
|
// Definition of the StopWatch Interface, this is used if we don't want to use
|
||||||
|
// the CUT functions But rather in a self contained class interface
|
||||||
|
class StopWatchInterface {
|
||||||
|
public:
|
||||||
|
StopWatchInterface() {}
|
||||||
|
virtual ~StopWatchInterface() {}
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! Start time measurement
|
||||||
|
virtual void start() = 0;
|
||||||
|
|
||||||
|
//! Stop time measurement
|
||||||
|
virtual void stop() = 0;
|
||||||
|
|
||||||
|
//! Reset time counters to zero
|
||||||
|
virtual void reset() = 0;
|
||||||
|
|
||||||
|
//! Time in msec. after start. If the stop watch is still running (i.e. there
|
||||||
|
//! was no call to stop()) then the elapsed time is returned, otherwise the
|
||||||
|
//! time between the last start() and stop call is returned
|
||||||
|
virtual float getTime() = 0;
|
||||||
|
|
||||||
|
//! Mean time to date based on the number of times the stopwatch has been
|
||||||
|
//! _stopped_ (ie finished sessions) and the current total time
|
||||||
|
virtual float getAverageTime() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
// Begin Stopwatch timer class definitions for all OS platforms //
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
|
||||||
|
// includes, system
|
||||||
|
#define WINDOWS_LEAN_AND_MEAN
|
||||||
|
#include <windows.h>
|
||||||
|
#undef min
|
||||||
|
#undef max
|
||||||
|
|
||||||
|
//! Windows specific implementation of StopWatch
|
||||||
|
class StopWatchWin : public StopWatchInterface {
|
||||||
|
public:
|
||||||
|
//! Constructor, default
|
||||||
|
StopWatchWin()
|
||||||
|
: start_time(),
|
||||||
|
end_time(),
|
||||||
|
diff_time(0.0f),
|
||||||
|
total_time(0.0f),
|
||||||
|
running(false),
|
||||||
|
clock_sessions(0),
|
||||||
|
freq(0),
|
||||||
|
freq_set(false) {
|
||||||
|
if (!freq_set) {
|
||||||
|
// helper variable
|
||||||
|
LARGE_INTEGER temp;
|
||||||
|
|
||||||
|
// get the tick frequency from the OS
|
||||||
|
QueryPerformanceFrequency(reinterpret_cast<LARGE_INTEGER *>(&temp));
|
||||||
|
|
||||||
|
// convert to type in which it is needed
|
||||||
|
freq = (static_cast<double>(temp.QuadPart)) / 1000.0;
|
||||||
|
|
||||||
|
// rememeber query
|
||||||
|
freq_set = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
~StopWatchWin() {}
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! Start time measurement
|
||||||
|
inline void start();
|
||||||
|
|
||||||
|
//! Stop time measurement
|
||||||
|
inline void stop();
|
||||||
|
|
||||||
|
//! Reset time counters to zero
|
||||||
|
inline void reset();
|
||||||
|
|
||||||
|
//! Time in msec. after start. If the stop watch is still running (i.e. there
|
||||||
|
//! was no call to stop()) then the elapsed time is returned, otherwise the
|
||||||
|
//! time between the last start() and stop call is returned
|
||||||
|
inline float getTime();
|
||||||
|
|
||||||
|
//! Mean time to date based on the number of times the stopwatch has been
|
||||||
|
//! _stopped_ (ie finished sessions) and the current total time
|
||||||
|
inline float getAverageTime();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// member variables
|
||||||
|
|
||||||
|
//! Start of measurement
|
||||||
|
LARGE_INTEGER start_time;
|
||||||
|
//! End of measurement
|
||||||
|
LARGE_INTEGER end_time;
|
||||||
|
|
||||||
|
//! Time difference between the last start and stop
|
||||||
|
float diff_time;
|
||||||
|
|
||||||
|
//! TOTAL time difference between starts and stops
|
||||||
|
float total_time;
|
||||||
|
|
||||||
|
//! flag if the stop watch is running
|
||||||
|
bool running;
|
||||||
|
|
||||||
|
//! Number of times clock has been started
|
||||||
|
//! and stopped to allow averaging
|
||||||
|
int clock_sessions;
|
||||||
|
|
||||||
|
//! tick frequency
|
||||||
|
double freq;
|
||||||
|
|
||||||
|
//! flag if the frequency has been set
|
||||||
|
bool freq_set;
|
||||||
|
};
|
||||||
|
|
||||||
|
// functions, inlined
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Start time measurement
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
inline void StopWatchWin::start() {
|
||||||
|
QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER *>(&start_time));
|
||||||
|
running = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Stop time measurement and increment add to the current diff_time summation
|
||||||
|
//! variable. Also increment the number of times this clock has been run.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
inline void StopWatchWin::stop() {
|
||||||
|
QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER *>(&end_time));
|
||||||
|
diff_time = static_cast<float>(((static_cast<double>(end_time.QuadPart) -
|
||||||
|
static_cast<double>(start_time.QuadPart)) /
|
||||||
|
freq));
|
||||||
|
|
||||||
|
total_time += diff_time;
|
||||||
|
clock_sessions++;
|
||||||
|
running = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Reset the timer to 0. Does not change the timer running state but does
|
||||||
|
//! recapture this point in time as the current start time if it is running.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
inline void StopWatchWin::reset() {
|
||||||
|
diff_time = 0;
|
||||||
|
total_time = 0;
|
||||||
|
clock_sessions = 0;
|
||||||
|
|
||||||
|
if (running) {
|
||||||
|
QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER *>(&start_time));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Time in msec. after start. If the stop watch is still running (i.e. there
|
||||||
|
//! was no call to stop()) then the elapsed time is returned added to the
|
||||||
|
//! current diff_time sum, otherwise the current summed time difference alone
|
||||||
|
//! is returned.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
inline float StopWatchWin::getTime() {
|
||||||
|
// Return the TOTAL time to date
|
||||||
|
float retval = total_time;
|
||||||
|
|
||||||
|
if (running) {
|
||||||
|
LARGE_INTEGER temp;
|
||||||
|
QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER *>(&temp));
|
||||||
|
retval += static_cast<float>(((static_cast<double>(temp.QuadPart) -
|
||||||
|
static_cast<double>(start_time.QuadPart)) /
|
||||||
|
freq));
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Time in msec. for a single run based on the total number of COMPLETED runs
|
||||||
|
//! and the total time.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
inline float StopWatchWin::getAverageTime() {
|
||||||
|
return (clock_sessions > 0) ? (total_time / clock_sessions) : 0.0f;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// Declarations for Stopwatch on Linux and Mac OSX
|
||||||
|
// includes, system
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
//! Windows specific implementation of StopWatch
|
||||||
|
class StopWatchLinux : public StopWatchInterface {
|
||||||
|
public:
|
||||||
|
//! Constructor, default
|
||||||
|
StopWatchLinux()
|
||||||
|
: start_time(),
|
||||||
|
diff_time(0.0),
|
||||||
|
total_time(0.0),
|
||||||
|
running(false),
|
||||||
|
clock_sessions(0) {}
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
virtual ~StopWatchLinux() {}
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! Start time measurement
|
||||||
|
inline void start();
|
||||||
|
|
||||||
|
//! Stop time measurement
|
||||||
|
inline void stop();
|
||||||
|
|
||||||
|
//! Reset time counters to zero
|
||||||
|
inline void reset();
|
||||||
|
|
||||||
|
//! Time in msec. after start. If the stop watch is still running (i.e. there
|
||||||
|
//! was no call to stop()) then the elapsed time is returned, otherwise the
|
||||||
|
//! time between the last start() and stop call is returned
|
||||||
|
inline float getTime();
|
||||||
|
|
||||||
|
//! Mean time to date based on the number of times the stopwatch has been
|
||||||
|
//! _stopped_ (ie finished sessions) and the current total time
|
||||||
|
inline float getAverageTime();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// helper functions
|
||||||
|
|
||||||
|
//! Get difference between start time and current time
|
||||||
|
inline float getDiffTime();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// member variables
|
||||||
|
|
||||||
|
//! Start of measurement
|
||||||
|
struct timeval start_time;
|
||||||
|
|
||||||
|
//! Time difference between the last start and stop
|
||||||
|
float diff_time;
|
||||||
|
|
||||||
|
//! TOTAL time difference between starts and stops
|
||||||
|
float total_time;
|
||||||
|
|
||||||
|
//! flag if the stop watch is running
|
||||||
|
bool running;
|
||||||
|
|
||||||
|
//! Number of times clock has been started
|
||||||
|
//! and stopped to allow averaging
|
||||||
|
int clock_sessions;
|
||||||
|
};
|
||||||
|
|
||||||
|
// functions, inlined
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Start time measurement
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
inline void StopWatchLinux::start() {
|
||||||
|
gettimeofday(&start_time, 0);
|
||||||
|
running = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Stop time measurement and increment add to the current diff_time summation
|
||||||
|
//! variable. Also increment the number of times this clock has been run.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
inline void StopWatchLinux::stop() {
|
||||||
|
diff_time = getDiffTime();
|
||||||
|
total_time += diff_time;
|
||||||
|
running = false;
|
||||||
|
clock_sessions++;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Reset the timer to 0. Does not change the timer running state but does
|
||||||
|
//! recapture this point in time as the current start time if it is running.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
inline void StopWatchLinux::reset() {
|
||||||
|
diff_time = 0;
|
||||||
|
total_time = 0;
|
||||||
|
clock_sessions = 0;
|
||||||
|
|
||||||
|
if (running) {
|
||||||
|
gettimeofday(&start_time, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Time in msec. after start. If the stop watch is still running (i.e. there
|
||||||
|
//! was no call to stop()) then the elapsed time is returned added to the
|
||||||
|
//! current diff_time sum, otherwise the current summed time difference alone
|
||||||
|
//! is returned.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
inline float StopWatchLinux::getTime() {
|
||||||
|
// Return the TOTAL time to date
|
||||||
|
float retval = total_time;
|
||||||
|
|
||||||
|
if (running) {
|
||||||
|
retval += getDiffTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Time in msec. for a single run based on the total number of COMPLETED runs
|
||||||
|
//! and the total time.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
inline float StopWatchLinux::getAverageTime() {
|
||||||
|
return (clock_sessions > 0) ? (total_time / clock_sessions) : 0.0f;
|
||||||
|
}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
inline float StopWatchLinux::getDiffTime() {
|
||||||
|
struct timeval t_time;
|
||||||
|
gettimeofday(&t_time, 0);
|
||||||
|
|
||||||
|
// time difference in milli-seconds
|
||||||
|
return static_cast<float>(1000.0 * (t_time.tv_sec - start_time.tv_sec) +
|
||||||
|
(0.001 * (t_time.tv_usec - start_time.tv_usec)));
|
||||||
|
}
|
||||||
|
#endif // WIN32
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Timer functionality exported
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Create a new timer
|
||||||
|
//! @return true if a time has been created, otherwise false
|
||||||
|
//! @param name of the new timer, 0 if the creation failed
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
inline bool sdkCreateTimer(StopWatchInterface **timer_interface) {
|
||||||
|
// printf("sdkCreateTimer called object %08x\n", (void *)*timer_interface);
|
||||||
|
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
|
||||||
|
*timer_interface = reinterpret_cast<StopWatchInterface *>(new StopWatchWin());
|
||||||
|
#else
|
||||||
|
*timer_interface =
|
||||||
|
reinterpret_cast<StopWatchInterface *>(new StopWatchLinux());
|
||||||
|
#endif
|
||||||
|
return (*timer_interface != NULL) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Delete a timer
|
||||||
|
//! @return true if a time has been deleted, otherwise false
|
||||||
|
//! @param name of the timer to delete
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
inline bool sdkDeleteTimer(StopWatchInterface **timer_interface) {
|
||||||
|
// printf("sdkDeleteTimer called object %08x\n", (void *)*timer_interface);
|
||||||
|
if (*timer_interface) {
|
||||||
|
delete *timer_interface;
|
||||||
|
*timer_interface = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Start the time with name \a name
|
||||||
|
//! @param name name of the timer to start
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
inline bool sdkStartTimer(StopWatchInterface **timer_interface) {
|
||||||
|
// printf("sdkStartTimer called object %08x\n", (void *)*timer_interface);
|
||||||
|
if (*timer_interface) {
|
||||||
|
(*timer_interface)->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Stop the time with name \a name. Does not reset.
|
||||||
|
//! @param name name of the timer to stop
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
inline bool sdkStopTimer(StopWatchInterface **timer_interface) {
|
||||||
|
// printf("sdkStopTimer called object %08x\n", (void *)*timer_interface);
|
||||||
|
if (*timer_interface) {
|
||||||
|
(*timer_interface)->stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Resets the timer's counter.
|
||||||
|
//! @param name name of the timer to reset.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
inline bool sdkResetTimer(StopWatchInterface **timer_interface) {
|
||||||
|
// printf("sdkResetTimer called object %08x\n", (void *)*timer_interface);
|
||||||
|
if (*timer_interface) {
|
||||||
|
(*timer_interface)->reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Return the average time for timer execution as the total time
|
||||||
|
//! for the timer dividied by the number of completed (stopped) runs the timer
|
||||||
|
//! has made.
|
||||||
|
//! Excludes the current running time if the timer is currently running.
|
||||||
|
//! @param name name of the timer to return the time of
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
inline float sdkGetAverageTimerValue(StopWatchInterface **timer_interface) {
|
||||||
|
// printf("sdkGetAverageTimerValue called object %08x\n", (void
|
||||||
|
// *)*timer_interface);
|
||||||
|
if (*timer_interface) {
|
||||||
|
return (*timer_interface)->getAverageTime();
|
||||||
|
} else {
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Total execution time for the timer over all runs since the last reset
|
||||||
|
//! or timer creation.
|
||||||
|
//! @param name name of the timer to obtain the value of.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
inline float sdkGetTimerValue(StopWatchInterface **timer_interface) {
|
||||||
|
// printf("sdkGetTimerValue called object %08x\n", (void *)*timer_interface);
|
||||||
|
if (*timer_interface) {
|
||||||
|
return (*timer_interface)->getTime();
|
||||||
|
} else {
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // COMMON_HELPER_TIMER_H_
|
170
Common/nvrtc_helper.h
Normal file
170
Common/nvrtc_helper.h
Normal file
|
@ -0,0 +1,170 @@
|
||||||
|
/* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMMON_NVRTC_HELPER_H_
|
||||||
|
|
||||||
|
#define COMMON_NVRTC_HELPER_H_ 1
|
||||||
|
|
||||||
|
#include <cuda.h>
|
||||||
|
#include <helper_cuda_drvapi.h>
|
||||||
|
#include <nvrtc.h>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#define NVRTC_SAFE_CALL(Name, x) \
|
||||||
|
do { \
|
||||||
|
nvrtcResult result = x; \
|
||||||
|
if (result != NVRTC_SUCCESS) { \
|
||||||
|
std::cerr << "\nerror: " << Name << " failed with error " \
|
||||||
|
<< nvrtcGetErrorString(result); \
|
||||||
|
exit(1); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
void compileFileToPTX(char *filename, int argc, char **argv, char **ptxResult,
|
||||||
|
size_t *ptxResultSize, int requiresCGheaders) {
|
||||||
|
std::ifstream inputFile(filename,
|
||||||
|
std::ios::in | std::ios::binary | std::ios::ate);
|
||||||
|
|
||||||
|
if (!inputFile.is_open()) {
|
||||||
|
std::cerr << "\nerror: unable to open " << filename << " for reading!\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::streampos pos = inputFile.tellg();
|
||||||
|
size_t inputSize = (size_t)pos;
|
||||||
|
char *memBlock = new char[inputSize + 1];
|
||||||
|
|
||||||
|
inputFile.seekg(0, std::ios::beg);
|
||||||
|
inputFile.read(memBlock, inputSize);
|
||||||
|
inputFile.close();
|
||||||
|
memBlock[inputSize] = '\x0';
|
||||||
|
|
||||||
|
int numCompileOptions = 0;
|
||||||
|
|
||||||
|
char *compileParams[1];
|
||||||
|
|
||||||
|
if (requiresCGheaders) {
|
||||||
|
std::string compileOptions;
|
||||||
|
char HeaderNames[256];
|
||||||
|
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
|
||||||
|
sprintf_s(HeaderNames, sizeof(HeaderNames), "%s", "cooperative_groups.h");
|
||||||
|
#else
|
||||||
|
snprintf(HeaderNames, sizeof(HeaderNames), "%s", "cooperative_groups.h");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
compileOptions = "--include-path=";
|
||||||
|
|
||||||
|
std::string path = sdkFindFilePath(HeaderNames, argv[0]);
|
||||||
|
if (!path.empty()) {
|
||||||
|
std::size_t found = path.find(HeaderNames);
|
||||||
|
path.erase(found);
|
||||||
|
} else {
|
||||||
|
printf(
|
||||||
|
"\nCooperativeGroups headers not found, please install it in %s "
|
||||||
|
"sample directory..\n Exiting..\n",
|
||||||
|
argv[0]);
|
||||||
|
}
|
||||||
|
compileOptions += path.c_str();
|
||||||
|
compileParams[0] = reinterpret_cast<char *>(
|
||||||
|
malloc(sizeof(char) * (compileOptions.length() + 1)));
|
||||||
|
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
|
||||||
|
sprintf_s(compileParams[0], sizeof(char) * (compileOptions.length() + 1),
|
||||||
|
"%s", compileOptions.c_str());
|
||||||
|
#else
|
||||||
|
snprintf(compileParams[0], compileOptions.size(), "%s",
|
||||||
|
compileOptions.c_str());
|
||||||
|
#endif
|
||||||
|
numCompileOptions++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// compile
|
||||||
|
nvrtcProgram prog;
|
||||||
|
NVRTC_SAFE_CALL("nvrtcCreateProgram",
|
||||||
|
nvrtcCreateProgram(&prog, memBlock, filename, 0, NULL, NULL));
|
||||||
|
|
||||||
|
nvrtcResult res = nvrtcCompileProgram(prog, numCompileOptions, compileParams);
|
||||||
|
|
||||||
|
// dump log
|
||||||
|
size_t logSize;
|
||||||
|
NVRTC_SAFE_CALL("nvrtcGetProgramLogSize",
|
||||||
|
nvrtcGetProgramLogSize(prog, &logSize));
|
||||||
|
char *log = reinterpret_cast<char *>(malloc(sizeof(char) * logSize + 1));
|
||||||
|
NVRTC_SAFE_CALL("nvrtcGetProgramLog", nvrtcGetProgramLog(prog, log));
|
||||||
|
log[logSize] = '\x0';
|
||||||
|
|
||||||
|
if (strlen(log) >= 2) {
|
||||||
|
std::cerr << "\n compilation log ---\n";
|
||||||
|
std::cerr << log;
|
||||||
|
std::cerr << "\n end log ---\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
free(log);
|
||||||
|
|
||||||
|
NVRTC_SAFE_CALL("nvrtcCompileProgram", res);
|
||||||
|
// fetch PTX
|
||||||
|
size_t ptxSize;
|
||||||
|
NVRTC_SAFE_CALL("nvrtcGetPTXSize", nvrtcGetPTXSize(prog, &ptxSize));
|
||||||
|
char *ptx = reinterpret_cast<char *>(malloc(sizeof(char) * ptxSize));
|
||||||
|
NVRTC_SAFE_CALL("nvrtcGetPTX", nvrtcGetPTX(prog, ptx));
|
||||||
|
NVRTC_SAFE_CALL("nvrtcDestroyProgram", nvrtcDestroyProgram(&prog));
|
||||||
|
*ptxResult = ptx;
|
||||||
|
*ptxResultSize = ptxSize;
|
||||||
|
|
||||||
|
if (requiresCGheaders) free(compileParams[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
CUmodule loadPTX(char *ptx, int argc, char **argv) {
|
||||||
|
CUmodule module;
|
||||||
|
CUcontext context;
|
||||||
|
int major = 0, minor = 0;
|
||||||
|
char deviceName[256];
|
||||||
|
|
||||||
|
// Picks the best CUDA device available
|
||||||
|
CUdevice cuDevice = findCudaDeviceDRV(argc, (const char **)argv);
|
||||||
|
|
||||||
|
// get compute capabilities and the devicename
|
||||||
|
checkCudaErrors(cuDeviceGetAttribute(
|
||||||
|
&major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, cuDevice));
|
||||||
|
checkCudaErrors(cuDeviceGetAttribute(
|
||||||
|
&minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, cuDevice));
|
||||||
|
checkCudaErrors(cuDeviceGetName(deviceName, 256, cuDevice));
|
||||||
|
printf("> GPU Device has SM %d.%d compute capability\n", major, minor);
|
||||||
|
|
||||||
|
checkCudaErrors(cuInit(0));
|
||||||
|
checkCudaErrors(cuDeviceGet(&cuDevice, 0));
|
||||||
|
checkCudaErrors(cuCtxCreate(&context, 0, cuDevice));
|
||||||
|
|
||||||
|
checkCudaErrors(cuModuleLoadDataEx(&module, ptx, 0, 0, 0));
|
||||||
|
free(ptx);
|
||||||
|
|
||||||
|
return module;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // COMMON_NVRTC_HELPER_H_
|
25
LICENSE
Normal file
25
LICENSE
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of NVIDIA CORPORATION nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived
|
||||||
|
from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||||
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
64
Makefile
Normal file
64
Makefile
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# * Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
# * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||||
|
# contributors may be used to endorse or promote products derived
|
||||||
|
# from this software without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||||
|
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# CUDA Samples
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
TARGET_ARCH ?= $(shell uname -m)
|
||||||
|
|
||||||
|
# Project folders that contain CUDA samples
|
||||||
|
PROJECTS ?= $(shell find Samples -name Makefile)
|
||||||
|
|
||||||
|
FILTER_OUT :=
|
||||||
|
|
||||||
|
PROJECTS := $(filter-out $(FILTER_OUT),$(PROJECTS))
|
||||||
|
|
||||||
|
%.ph_build :
|
||||||
|
+@$(MAKE) -C $(dir $*) $(MAKECMDGOALS)
|
||||||
|
|
||||||
|
%.ph_clean :
|
||||||
|
+@$(MAKE) -C $(dir $*) clean $(USE_DEVICE)
|
||||||
|
|
||||||
|
%.ph_clobber :
|
||||||
|
+@$(MAKE) -C $(dir $*) clobber $(USE_DEVICE)
|
||||||
|
|
||||||
|
all: $(addsuffix .ph_build,$(PROJECTS))
|
||||||
|
@echo "Finished building CUDA samples"
|
||||||
|
|
||||||
|
build: $(addsuffix .ph_build,$(PROJECTS))
|
||||||
|
|
||||||
|
tidy:
|
||||||
|
@find * | egrep "#" | xargs rm -f
|
||||||
|
@find * | egrep "\~" | xargs rm -f
|
||||||
|
|
||||||
|
clean: tidy $(addsuffix .ph_clean,$(PROJECTS))
|
||||||
|
|
||||||
|
clobber: clean $(addsuffix .ph_clobber,$(PROJECTS))
|
261
README.md
Normal file
261
README.md
Normal file
|
@ -0,0 +1,261 @@
|
||||||
|
# CUDA Samples
|
||||||
|
|
||||||
|
Samples for CUDA Developers which demonstrates features in CUDA Toolkit. This version supports [CUDA Toolkit 9.2](https://developer.nvidia.com/cuda-downloads).
|
||||||
|
|
||||||
|
## Release Notes
|
||||||
|
|
||||||
|
This section describes the release notes for the CUDA Samples on GitHub only.
|
||||||
|
|
||||||
|
### CUDA 9.2
|
||||||
|
|
||||||
|
This is the first release of CUDA Samples on GitHub:
|
||||||
|
* Added `warpAggregatedAtomicsCG`. Demonstrates warp aggregated atomics using Cooperative Groups.
|
||||||
|
* Added `deviceQuery`. Enumerates the properties of the CUDA devices present in the system.
|
||||||
|
* Added `matrixMul`. Demonstrates a matrix multiplication using shared memory through tiled approach.
|
||||||
|
* Added `matrixMulDrv`. Demonstrates a matrix multiplication using shared memory through tiled approach, uses CUDA Driver API.
|
||||||
|
* Added `cudaTensorCoreGemm`. Demonstrates a GEMM computation using the Warp Matrix Multiply and Accumulate (WMMA) API introduced in CUDA 9, as well as the new Tensor Cores introduced in the Volta chip family.
|
||||||
|
* Added `simpleVoteIntrinsics` which uses *_sync equivalent of the vote intrinsics _any, _all added since CUDA 9.0.
|
||||||
|
* Added `shfl_scan` which uses *_sync equivalent of the shfl intrinsics added since CUDA 9.0.
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
|
||||||
|
Download and install the [CUDA Toolkit 9.2](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
|
||||||
|
For system requirements and installation instructions of cuda toolkit, please refer to the [Linux Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/), the [Windows Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/index.html), and the [Mac Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html).
|
||||||
|
|
||||||
|
### Getting the CUDA Samples
|
||||||
|
|
||||||
|
Using git clone the repository of CUDA Samples using the command below.
|
||||||
|
```
|
||||||
|
git clone <GIT_REPO_CLONE_LINK>
|
||||||
|
```
|
||||||
|
|
||||||
|
Without using git the easiest way to use these samples is to download the zip file containing the current version by clicking the "Download ZIP" button on the repo page. You can then unzip the entire archive and use the samples.
|
||||||
|
|
||||||
|
## Building CUDA Samples
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
|
||||||
|
The Windows samples are built using the Visual Studio IDE. Solution files (.sln) are provided for each supported version of Visual Studio, using the format:
|
||||||
|
```
|
||||||
|
*_vs<version>.sln - for Visual Studio <version>
|
||||||
|
```
|
||||||
|
Complete samples solution files exist at parent directory of the repo:
|
||||||
|
|
||||||
|
Each individual sample has its own set of solution files at:
|
||||||
|
`<CUDA_SAMPLES_REPO>\Samples\<sample_dir>\`
|
||||||
|
|
||||||
|
To build/examine all the samples at once, the complete solution files should be used. To build/examine a single sample, the individual sample solution files should be used.
|
||||||
|
> **Note:** Some samples require that the Microsoft DirectX SDK (June 2010 or newer) be installed and that the VC++ directory paths are properly set up (**Tools > Options...**). Check [DirectX Dependencies](#directx) section for details."
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
The Linux samples are built using makefiles. To use the makefiles, change the current directory to the sample directory you wish to build, and run make:
|
||||||
|
```
|
||||||
|
$ cd <sample_dir>
|
||||||
|
$ make
|
||||||
|
```
|
||||||
|
The samples makefiles can take advantage of certain options:
|
||||||
|
* **TARGET_ARCH=<arch>** - cross-compile targeting a specific architecture. Allowed architectures are x86_64, ppc64le, armv7l, aarch64.
|
||||||
|
By default, TARGET_ARCH is set to HOST_ARCH. On a x86_64 machine, not setting TARGET_ARCH is the equivalent of setting TARGET_ARCH=x86_64.<br/>
|
||||||
|
`$ make TARGET_ARCH=x86_64` <br/> `$ make TARGET_ARCH=ppc64le` <br/> `$ make TARGET_ARCH=armv7l` <br/> `$ make TARGET_ARCH=aarch64` <br/>
|
||||||
|
See [here](http://docs.nvidia.com/cuda/cuda-samples/index.html#cross-samples) for more details on cross platform compilation of cuda samples.
|
||||||
|
* **dbg=1** - build with debug symbols
|
||||||
|
```
|
||||||
|
$ make dbg=1
|
||||||
|
```
|
||||||
|
* **SMS="A B ..."** - override the SM architectures for which the sample will be built, where `"A B ..."` is a space-delimited list of SM architectures. For example, to generate SASS for SM 50 and SM 60, use `SMS="50 60"`.
|
||||||
|
```
|
||||||
|
$ make SMS="50 60"
|
||||||
|
```
|
||||||
|
|
||||||
|
* **HOST_COMPILER=<host_compiler>** - override the default g++ host compiler. See the [Linux Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements) for a list of supported host compilers.
|
||||||
|
```
|
||||||
|
$ make HOST_COMPILER=g++
|
||||||
|
```
|
||||||
|
|
||||||
|
### Mac
|
||||||
|
The Mac samples are built using makefiles. To use the makefiles, change directory into the sample directory you wish to build, and run make:
|
||||||
|
```
|
||||||
|
$ cd <sample_dir>
|
||||||
|
$ make
|
||||||
|
```
|
||||||
|
|
||||||
|
The samples makefiles can take advantage of certain options:
|
||||||
|
|
||||||
|
* **dbg=1** - build with debug symbols
|
||||||
|
```
|
||||||
|
$ make dbg=1
|
||||||
|
```
|
||||||
|
|
||||||
|
* **SMS="A B ..."** - override the SM architectures for which the sample will be built, where "A B ..." is a space-delimited list of SM architectures. For example, to generate SASS for SM 50 and SM 60, use SMS="50 60".
|
||||||
|
```
|
||||||
|
$ make SMS="A B ..."
|
||||||
|
```
|
||||||
|
|
||||||
|
* **HOST_COMPILER=<host_compiler>** - override the default clang host compiler. See the [Mac Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html#system-requirements) for a list of supported host compilers.
|
||||||
|
```
|
||||||
|
$ make HOST_COMPILER=clang
|
||||||
|
```
|
||||||
|
|
||||||
|
## Samples list
|
||||||
|
|
||||||
|
### Samples by OS
|
||||||
|
|
||||||
|
#### Linux
|
||||||
|
**[warpAggregatedAtomicsCG](./Samples/warpAggregatedAtomicsCG)** | **[matrixMulDrv](./Samples/matrixMulDrv)** | **[vectorAdd_nvrtc](./Samples/vectorAdd_nvrtc)** | **[simpleCUFFT](./Samples/simpleCUFFT)** |
|
||||||
|
---|---|---|---|
|
||||||
|
**[simpleCUBLAS](./Samples/simpleCUBLAS)** | **[matrixMul](./Samples/matrixMul)** | **[deviceQuery](./Samples/deviceQuery)** |
|
||||||
|
|
||||||
|
#### Windows
|
||||||
|
**[warpAggregatedAtomicsCG](./Samples/warpAggregatedAtomicsCG)** | **[matrixMulDrv](./Samples/matrixMulDrv)** | **[vectorAdd_nvrtc](./Samples/vectorAdd_nvrtc)** | **[simpleCUFFT](./Samples/simpleCUFFT)** |
|
||||||
|
---|---|---|---|
|
||||||
|
**[simpleCUBLAS](./Samples/simpleCUBLAS)** | **[matrixMul](./Samples/matrixMul)** | **[deviceQuery](./Samples/deviceQuery)** |
|
||||||
|
|
||||||
|
#### Mac OSX
|
||||||
|
**[warpAggregatedAtomicsCG](./Samples/warpAggregatedAtomicsCG)** | **[matrixMulDrv](./Samples/matrixMulDrv)** | **[vectorAdd_nvrtc](./Samples/vectorAdd_nvrtc)** | **[simpleCUFFT](./Samples/simpleCUFFT)** |
|
||||||
|
---|---|---|---|
|
||||||
|
**[simpleCUBLAS](./Samples/simpleCUBLAS)** | **[matrixMul](./Samples/matrixMul)** | **[deviceQuery](./Samples/deviceQuery)** |
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
Some CUDA Samples rely on third-party applications and/or libraries, or features provided by the CUDA Toolkit and Driver, to either build or execute. These dependencies are listed below.
|
||||||
|
|
||||||
|
If a sample has a third-party dependency that is available on the system, but is not installed, the sample will waive itself at build time.
|
||||||
|
|
||||||
|
Each sample's dependencies are listed in its README's Dependencies section.
|
||||||
|
|
||||||
|
### Third-Party Dependencies
|
||||||
|
|
||||||
|
These third-party dependencies are required by some CUDA samples. If available, these dependencies are either installed on your system automatically, or are installable via your system's package manager (Linux) or a third-party website.
|
||||||
|
|
||||||
|
#### FreeImage
|
||||||
|
|
||||||
|
FreeImage is an open source imaging library. FreeImage can usually be installed on Linux using your distribution's package manager system. FreeImage can also be downloaded from the [FreeImage website](http://freeimage.sourceforge.net/). FreeImage is also redistributed with the CUDA Samples.
|
||||||
|
|
||||||
|
#### Message Passing Interface
|
||||||
|
|
||||||
|
MPI (Message Passing Interface) is an API for communicating data between distributed processes. A MPI compiler can be installed using your Linux distribution's package manager system. It is also available on some online resources, such as [Open MPI](http://www.open-mpi.org/). On Windows, to build and run MPI-CUDA applications one can install [MS-MPI SDK](https://msdn.microsoft.com/en-us/library/bb524831(v=vs.85).aspx).
|
||||||
|
|
||||||
|
#### Only 64-Bit
|
||||||
|
|
||||||
|
Some samples can only be run on a 64-bit operating system.
|
||||||
|
|
||||||
|
#### DirectX
|
||||||
|
|
||||||
|
DirectX is a collection of APIs designed to allow development of multimedia applications on Microsoft platforms. For Microsoft platforms, NVIDIA's CUDA Driver supports DirectX. Several CUDA Samples for Windows demonstrates CUDA-DirectX Interoperability, for building such samples one needs to install [Direct X SDK (June 2010 or newer)](http://www.microsoft.com/en-us/download/details.aspx?id=6812) , this is required to be installed on Windows 7, Windows 10 and Windows Server 2008, Other Windows OSes do not need to explicitly install the DirectX SDK.
|
||||||
|
|
||||||
|
#### OpenGL
|
||||||
|
|
||||||
|
OpenGL is a graphics library used for 2D and 3D rendering. On systems which support OpenGL, NVIDIA's OpenGL implementation is provided with the CUDA Driver.
|
||||||
|
|
||||||
|
#### OpenGL ES
|
||||||
|
|
||||||
|
OpenGL ES is an embedded systems graphics library used for 2D and 3D rendering. On systems which support OpenGL ES, NVIDIA's OpenGL ES implementation is provided with the CUDA Driver.
|
||||||
|
|
||||||
|
#### OpenMP
|
||||||
|
|
||||||
|
OpenMP is an API for multiprocessing programming. OpenMP can be installed using your Linux distribution's package manager system. It usually comes preinstalled with GCC. It can also be found at the [OpenMP website](http://openmp.org/).
|
||||||
|
|
||||||
|
#### Screen
|
||||||
|
|
||||||
|
Screen is a windowing system found on the QNX operating system. Screen is usually found as part of the root filesystem.
|
||||||
|
|
||||||
|
#### X11
|
||||||
|
|
||||||
|
X11 is a windowing system commonly found on *-nix style operating systems. X11 can be installed using your Linux distribution's package manager, and comes preinstalled on Mac OS X systems.
|
||||||
|
|
||||||
|
#### EGL
|
||||||
|
|
||||||
|
EGL is an interface between Khronos rendering APIs (such as OpenGL, OpenGL ES or OpenVG) and the underlying native platform windowing system.
|
||||||
|
|
||||||
|
#### EGLOutput
|
||||||
|
|
||||||
|
EGLOutput is a set of EGL extensions which allow EGL to render directly to the display.
|
||||||
|
|
||||||
|
#### EGLSync
|
||||||
|
|
||||||
|
EGLSync is a set of EGL extensions which provides sync objects that are synchronization primitive, representing events whose completion can be tested or waited upon.
|
||||||
|
|
||||||
|
### CUDA Features
|
||||||
|
|
||||||
|
These CUDA features are needed by some CUDA samples. They are provided by either the CUDA Toolkit or CUDA Driver. Some features may not be available on your system.
|
||||||
|
|
||||||
|
#### CUFFT Callback Routines
|
||||||
|
|
||||||
|
CUFFT Callback Routines are user-supplied kernel routines that CUFFT will call when loading or storing data. These callback routines are only available on Linux x86_64 and ppc64le systems.
|
||||||
|
|
||||||
|
#### CUDA Dynamic Paralellism
|
||||||
|
|
||||||
|
CDP (CUDA Dynamic Paralellism) allows kernels to be launched from threads running on the GPU. CDP is only available on GPUs with SM architecture of 3.5 or above.
|
||||||
|
|
||||||
|
#### Multi-block Cooperative Groups
|
||||||
|
|
||||||
|
Multi Block Cooperative Groups(MBCG) extends Cooperative Groups and the CUDA programming model to express inter-thread-block synchronization. MBCG is available on GPUs with Pascal and higher architecture on Linux systems.
|
||||||
|
|
||||||
|
#### CUBLAS
|
||||||
|
|
||||||
|
CUBLAS (CUDA Basic Linear Algebra Subroutines) is a GPU-accelerated version of the BLAS library.
|
||||||
|
|
||||||
|
#### CUDA Interprocess Communication
|
||||||
|
|
||||||
|
IPC (Interprocess Communication) allows processes to share device pointers. IPC is only available on Linux x86_64 and ppc64le systems.
|
||||||
|
|
||||||
|
#### CUFFT
|
||||||
|
|
||||||
|
CUFFT (CUDA Fast Fourier Transform) is a GPU-accelerated FFT library.
|
||||||
|
|
||||||
|
#### CURAND
|
||||||
|
|
||||||
|
CURAND (CUDA Random Number Generation) is a GPU-accelerated RNG library.
|
||||||
|
|
||||||
|
#### CUSPARSE
|
||||||
|
|
||||||
|
CUSPARSE (CUDA Sparse Matrix) provides linear algebra subroutines used for sparse matrix calculations.
|
||||||
|
|
||||||
|
#### CUSOLVER
|
||||||
|
|
||||||
|
CUSOLVER library is a high-level package based on the CUBLAS and CUSPARSE libraries. It combines three separate libraries under a single umbrella, each of which can be used independently or in concert with other toolkit libraries. The intent ofCUSOLVER is to provide useful LAPACK-like features, such as common matrix factorization and triangular solve routines for dense matrices, a sparse least-squares solver and an eigenvalue solver. In addition cuSolver provides a new refactorization library useful for solving sequences of matrices with a shared sparsity pattern.
|
||||||
|
|
||||||
|
#### NPP
|
||||||
|
|
||||||
|
NPP (NVIDIA Performance Primitives) provides GPU-accelerated image, video, and signal processing functions.
|
||||||
|
|
||||||
|
#### NVGRAPH
|
||||||
|
|
||||||
|
NVGRAPH is a GPU-accelerated graph analytics library..
|
||||||
|
|
||||||
|
#### NVRTC
|
||||||
|
|
||||||
|
NVRTC (CUDA RunTime Compilation) is a runtime compilation library for CUDA C++.
|
||||||
|
|
||||||
|
#### NVCUVID
|
||||||
|
|
||||||
|
NVCUVID (NVIDIA CUDA Video Decoder) provides GPU-accelerated video decoding capabilities.
|
||||||
|
|
||||||
|
#### Stream Priorities
|
||||||
|
|
||||||
|
Stream Priorities allows the creation of streams with specified priorities. Stream Priorities is only available on GPUs with SM architecture of 3.5 or above.
|
||||||
|
|
||||||
|
#### Unified Virtual Memory
|
||||||
|
|
||||||
|
UVM (Unified Virtual Memory) enables memory that can be accessed by both the CPU and GPU without explicit copying between the two. UVM is only available on Linux and Windows systems.
|
||||||
|
|
||||||
|
#### 16-bit Floating Point
|
||||||
|
|
||||||
|
FP16 is a 16-bit floating-point format. One bit is used for the sign, five bits for the exponent, and ten bits for the mantissa.
|
||||||
|
|
||||||
|
#### C++11 CUDA
|
||||||
|
|
||||||
|
NVCC support of [C++11 features](https://en.wikipedia.org/wiki/C++11).
|
||||||
|
|
||||||
|
## Contributors Guide
|
||||||
|
|
||||||
|
We welcome your input on issues and suggestions for new samples. At this time we are not accepting contributions from the public, check back here as we evolve our contribution model.
|
||||||
|
|
||||||
|
We use Google C++ Style Guide for all the sources https://google.github.io/styleguide/cppguide.html
|
||||||
|
|
||||||
|
## Frequently Asked Questions
|
||||||
|
|
||||||
|
Answers to frequently asked questions about CUDA can be found at http://developer.nvidia.com/cuda-faq and in the [CUDA Toolkit Release Notes](http://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html).
|
||||||
|
|
287
Samples/deviceQuery/Makefile
Normal file
287
Samples/deviceQuery/Makefile
Normal file
|
@ -0,0 +1,287 @@
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Copyright 1993-2015 NVIDIA Corporation. All rights reserved.
|
||||||
|
#
|
||||||
|
# NOTICE TO USER:
|
||||||
|
#
|
||||||
|
# This source code is subject to NVIDIA ownership rights under U.S. and
|
||||||
|
# international Copyright laws.
|
||||||
|
#
|
||||||
|
# NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
|
||||||
|
# CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
|
||||||
|
# IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
# REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
# MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
# IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
||||||
|
# OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||||
|
# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||||
|
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|
||||||
|
# OR PERFORMANCE OF THIS SOURCE CODE.
|
||||||
|
#
|
||||||
|
# U.S. Government End Users. This source code is a "commercial item" as
|
||||||
|
# that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
|
||||||
|
# "commercial computer software" and "commercial computer software
|
||||||
|
# documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
|
||||||
|
# and is provided to the U.S. Government only as a commercial end item.
|
||||||
|
# Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
|
||||||
|
# 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
|
||||||
|
# source code with only those rights set forth herein.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Makefile project only supported on Mac OS X and Linux Platforms)
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Location of the CUDA Toolkit
|
||||||
|
CUDA_PATH ?= /usr/local/cuda
|
||||||
|
|
||||||
|
##############################
|
||||||
|
# start deprecated interface #
|
||||||
|
##############################
|
||||||
|
ifeq ($(x86_64),1)
|
||||||
|
$(info WARNING - x86_64 variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=x86_64 instead)
|
||||||
|
TARGET_ARCH ?= x86_64
|
||||||
|
endif
|
||||||
|
ifeq ($(ARMv7),1)
|
||||||
|
$(info WARNING - ARMv7 variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=armv7l instead)
|
||||||
|
TARGET_ARCH ?= armv7l
|
||||||
|
endif
|
||||||
|
ifeq ($(aarch64),1)
|
||||||
|
$(info WARNING - aarch64 variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=aarch64 instead)
|
||||||
|
TARGET_ARCH ?= aarch64
|
||||||
|
endif
|
||||||
|
ifeq ($(ppc64le),1)
|
||||||
|
$(info WARNING - ppc64le variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=ppc64le instead)
|
||||||
|
TARGET_ARCH ?= ppc64le
|
||||||
|
endif
|
||||||
|
ifneq ($(GCC),)
|
||||||
|
$(info WARNING - GCC variable has been deprecated)
|
||||||
|
$(info WARNING - please use HOST_COMPILER=$(GCC) instead)
|
||||||
|
HOST_COMPILER ?= $(GCC)
|
||||||
|
endif
|
||||||
|
ifneq ($(abi),)
|
||||||
|
$(error ERROR - abi variable has been removed)
|
||||||
|
endif
|
||||||
|
############################
|
||||||
|
# end deprecated interface #
|
||||||
|
############################
|
||||||
|
|
||||||
|
# architecture
|
||||||
|
HOST_ARCH := $(shell uname -m)
|
||||||
|
TARGET_ARCH ?= $(HOST_ARCH)
|
||||||
|
ifneq (,$(filter $(TARGET_ARCH),x86_64 aarch64 ppc64le armv7l))
|
||||||
|
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifneq (,$(filter $(TARGET_ARCH),x86_64 aarch64 ppc64le))
|
||||||
|
TARGET_SIZE := 64
|
||||||
|
else ifneq (,$(filter $(TARGET_ARCH),armv7l))
|
||||||
|
TARGET_SIZE := 32
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
TARGET_SIZE := $(shell getconf LONG_BIT)
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
$(error ERROR - unsupported value $(TARGET_ARCH) for TARGET_ARCH!)
|
||||||
|
endif
|
||||||
|
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifeq (,$(filter $(HOST_ARCH)-$(TARGET_ARCH),aarch64-armv7l x86_64-armv7l x86_64-aarch64 x86_64-ppc64le))
|
||||||
|
$(error ERROR - cross compiling from $(HOST_ARCH) to $(TARGET_ARCH) is not supported!)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# When on native aarch64 system with userspace of 32-bit, change TARGET_ARCH to armv7l
|
||||||
|
ifeq ($(HOST_ARCH)-$(TARGET_ARCH)-$(TARGET_SIZE),aarch64-aarch64-32)
|
||||||
|
TARGET_ARCH = armv7l
|
||||||
|
endif
|
||||||
|
|
||||||
|
# operating system
|
||||||
|
HOST_OS := $(shell uname -s 2>/dev/null | tr "[:upper:]" "[:lower:]")
|
||||||
|
TARGET_OS ?= $(HOST_OS)
|
||||||
|
ifeq (,$(filter $(TARGET_OS),linux darwin qnx android))
|
||||||
|
$(error ERROR - unsupported value $(TARGET_OS) for TARGET_OS!)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# host compiler
|
||||||
|
ifeq ($(TARGET_OS),darwin)
|
||||||
|
ifeq ($(shell expr `xcodebuild -version | grep -i xcode | awk '{print $$2}' | cut -d'.' -f1` \>= 5),1)
|
||||||
|
HOST_COMPILER ?= clang++
|
||||||
|
endif
|
||||||
|
else ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifeq ($(HOST_ARCH)-$(TARGET_ARCH),x86_64-armv7l)
|
||||||
|
ifeq ($(TARGET_OS),linux)
|
||||||
|
HOST_COMPILER ?= arm-linux-gnueabihf-g++
|
||||||
|
else ifeq ($(TARGET_OS),qnx)
|
||||||
|
ifeq ($(QNX_HOST),)
|
||||||
|
$(error ERROR - QNX_HOST must be passed to the QNX host toolchain)
|
||||||
|
endif
|
||||||
|
ifeq ($(QNX_TARGET),)
|
||||||
|
$(error ERROR - QNX_TARGET must be passed to the QNX target toolchain)
|
||||||
|
endif
|
||||||
|
export QNX_HOST
|
||||||
|
export QNX_TARGET
|
||||||
|
HOST_COMPILER ?= $(QNX_HOST)/usr/bin/arm-unknown-nto-qnx6.6.0eabi-g++
|
||||||
|
else ifeq ($(TARGET_OS),android)
|
||||||
|
HOST_COMPILER ?= arm-linux-androideabi-g++
|
||||||
|
endif
|
||||||
|
else ifeq ($(TARGET_ARCH),aarch64)
|
||||||
|
ifeq ($(TARGET_OS), linux)
|
||||||
|
HOST_COMPILER ?= aarch64-linux-gnu-g++
|
||||||
|
else ifeq ($(TARGET_OS),qnx)
|
||||||
|
ifeq ($(QNX_HOST),)
|
||||||
|
$(error ERROR - QNX_HOST must be passed to the QNX host toolchain)
|
||||||
|
endif
|
||||||
|
ifeq ($(QNX_TARGET),)
|
||||||
|
$(error ERROR - QNX_TARGET must be passed to the QNX target toolchain)
|
||||||
|
endif
|
||||||
|
export QNX_HOST
|
||||||
|
export QNX_TARGET
|
||||||
|
HOST_COMPILER ?= $(QNX_HOST)/usr/bin/aarch64-unknown-nto-qnx7.0.0-g++
|
||||||
|
else ifeq ($(TARGET_OS), android)
|
||||||
|
HOST_COMPILER ?= aarch64-linux-android-g++
|
||||||
|
endif
|
||||||
|
else ifeq ($(TARGET_ARCH),ppc64le)
|
||||||
|
HOST_COMPILER ?= powerpc64le-linux-gnu-g++
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
HOST_COMPILER ?= g++
|
||||||
|
NVCC := $(CUDA_PATH)/bin/nvcc -ccbin $(HOST_COMPILER)
|
||||||
|
|
||||||
|
# internal flags
|
||||||
|
NVCCFLAGS := -m${TARGET_SIZE}
|
||||||
|
CCFLAGS :=
|
||||||
|
LDFLAGS :=
|
||||||
|
|
||||||
|
# build flags
|
||||||
|
ifeq ($(TARGET_OS),darwin)
|
||||||
|
LDFLAGS += -rpath $(CUDA_PATH)/lib
|
||||||
|
CCFLAGS += -arch $(HOST_ARCH)
|
||||||
|
else ifeq ($(HOST_ARCH)-$(TARGET_ARCH)-$(TARGET_OS),x86_64-armv7l-linux)
|
||||||
|
LDFLAGS += --dynamic-linker=/lib/ld-linux-armhf.so.3
|
||||||
|
CCFLAGS += -mfloat-abi=hard
|
||||||
|
else ifeq ($(TARGET_OS),android)
|
||||||
|
LDFLAGS += -pie
|
||||||
|
CCFLAGS += -fpie -fpic -fexceptions
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
||||||
|
ifneq ($(TARGET_FS),)
|
||||||
|
GCCVERSIONLTEQ46 := $(shell expr `$(HOST_COMPILER) -dumpversion` \<= 4.6)
|
||||||
|
ifeq ($(GCCVERSIONLTEQ46),1)
|
||||||
|
CCFLAGS += --sysroot=$(TARGET_FS)
|
||||||
|
endif
|
||||||
|
LDFLAGS += --sysroot=$(TARGET_FS)
|
||||||
|
LDFLAGS += -rpath-link=$(TARGET_FS)/lib
|
||||||
|
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib
|
||||||
|
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib/arm-linux-gnueabihf
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_OS),qnx)
|
||||||
|
CCFLAGS += -DWIN_INTERFACE_CUSTOM
|
||||||
|
LDFLAGS += -lsocket
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Install directory of different arch
|
||||||
|
CUDA_INSTALL_TARGET_DIR :=
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/armv7-linux-gnueabihf/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-linux)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/aarch64-linux/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-android)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/armv7-linux-androideabi/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-android)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/aarch64-linux-androideabi/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-qnx)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/ARMv7-linux-QNX/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-qnx)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/aarch64-qnx/
|
||||||
|
else ifeq ($(TARGET_ARCH),ppc64le)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/ppc64le-linux/
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Debug build flags
|
||||||
|
ifeq ($(dbg),1)
|
||||||
|
NVCCFLAGS += -g -G
|
||||||
|
BUILD_TYPE := debug
|
||||||
|
else
|
||||||
|
BUILD_TYPE := release
|
||||||
|
endif
|
||||||
|
|
||||||
|
ALL_CCFLAGS :=
|
||||||
|
ALL_CCFLAGS += $(NVCCFLAGS)
|
||||||
|
ALL_CCFLAGS += $(EXTRA_NVCCFLAGS)
|
||||||
|
ALL_CCFLAGS += $(addprefix -Xcompiler ,$(CCFLAGS))
|
||||||
|
ALL_CCFLAGS += $(addprefix -Xcompiler ,$(EXTRA_CCFLAGS))
|
||||||
|
|
||||||
|
SAMPLE_ENABLED := 1
|
||||||
|
|
||||||
|
ALL_LDFLAGS :=
|
||||||
|
ALL_LDFLAGS += $(ALL_CCFLAGS)
|
||||||
|
ALL_LDFLAGS += $(addprefix -Xlinker ,$(LDFLAGS))
|
||||||
|
ALL_LDFLAGS += $(addprefix -Xlinker ,$(EXTRA_LDFLAGS))
|
||||||
|
|
||||||
|
# Common includes and paths for CUDA
|
||||||
|
INCLUDES := -I../../Common
|
||||||
|
LIBRARIES :=
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Gencode arguments
|
||||||
|
SMS ?= 30 35 37 50 52 60 61 70
|
||||||
|
|
||||||
|
ifeq ($(SMS),)
|
||||||
|
$(info >>> WARNING - no SM architectures have been specified - waiving sample <<<)
|
||||||
|
SAMPLE_ENABLED := 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(GENCODE_FLAGS),)
|
||||||
|
# Generate SASS code for each SM architecture listed in $(SMS)
|
||||||
|
$(foreach sm,$(SMS),$(eval GENCODE_FLAGS += -gencode arch=compute_$(sm),code=sm_$(sm)))
|
||||||
|
|
||||||
|
# Generate PTX code from the highest SM architecture in $(SMS) to guarantee forward-compatibility
|
||||||
|
HIGHEST_SM := $(lastword $(sort $(SMS)))
|
||||||
|
ifneq ($(HIGHEST_SM),)
|
||||||
|
GENCODE_FLAGS += -gencode arch=compute_$(HIGHEST_SM),code=compute_$(HIGHEST_SM)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(SAMPLE_ENABLED),0)
|
||||||
|
EXEC ?= @echo "[@]"
|
||||||
|
endif
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Target rules
|
||||||
|
all: build
|
||||||
|
|
||||||
|
build: deviceQuery
|
||||||
|
|
||||||
|
check.deps:
|
||||||
|
ifeq ($(SAMPLE_ENABLED),0)
|
||||||
|
@echo "Sample will be waived due to the above missing dependencies"
|
||||||
|
else
|
||||||
|
@echo "Sample is ready - all dependencies have been met"
|
||||||
|
endif
|
||||||
|
|
||||||
|
deviceQuery.o:deviceQuery.cpp
|
||||||
|
$(EXEC) $(NVCC) $(INCLUDES) $(ALL_CCFLAGS) $(GENCODE_FLAGS) -o $@ -c $<
|
||||||
|
|
||||||
|
deviceQuery: deviceQuery.o
|
||||||
|
$(EXEC) $(NVCC) $(ALL_LDFLAGS) $(GENCODE_FLAGS) -o $@ $+ $(LIBRARIES)
|
||||||
|
$(EXEC) mkdir -p ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
||||||
|
$(EXEC) cp $@ ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
||||||
|
|
||||||
|
run: build
|
||||||
|
$(EXEC) ./deviceQuery
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f deviceQuery deviceQuery.o
|
||||||
|
rm -rf ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)/deviceQuery
|
||||||
|
|
||||||
|
clobber: clean
|
70
Samples/deviceQuery/NsightEclipse.xml
Normal file
70
Samples/deviceQuery/NsightEclipse.xml
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE entry SYSTEM "SamplesInfo.dtd">
|
||||||
|
<entry>
|
||||||
|
<name>deviceQuery</name>
|
||||||
|
<cuda_api_list>
|
||||||
|
<toolkit>cudaSetDevice</toolkit>
|
||||||
|
<toolkit>cudaGetDeviceCount</toolkit>
|
||||||
|
<toolkit>cudaGetDeviceProperties</toolkit>
|
||||||
|
<toolkit>cudaDriverGetVersion</toolkit>
|
||||||
|
<toolkit>cudaRuntimeGetVersion</toolkit>
|
||||||
|
</cuda_api_list>
|
||||||
|
<description><![CDATA[This sample enumerates the properties of the CUDA devices present in the system.]]></description>
|
||||||
|
<devicecompilation>whole</devicecompilation>
|
||||||
|
<includepaths>
|
||||||
|
<path>./</path>
|
||||||
|
<path>../</path>
|
||||||
|
<path>../../common/inc</path>
|
||||||
|
</includepaths>
|
||||||
|
<keyconcepts>
|
||||||
|
<concept level="basic">CUDA Runtime API</concept>
|
||||||
|
<concept level="basic">Device Query</concept>
|
||||||
|
</keyconcepts>
|
||||||
|
<keywords>
|
||||||
|
</keywords>
|
||||||
|
<libraries>
|
||||||
|
</libraries>
|
||||||
|
<librarypaths>
|
||||||
|
</librarypaths>
|
||||||
|
<nsight_eclipse>true</nsight_eclipse>
|
||||||
|
<primary_file>deviceQuery.cpp</primary_file>
|
||||||
|
<scopes>
|
||||||
|
<scope>1:CUDA Basic Topics</scope>
|
||||||
|
</scopes>
|
||||||
|
<sm-arch>sm30</sm-arch>
|
||||||
|
<sm-arch>sm35</sm-arch>
|
||||||
|
<sm-arch>sm37</sm-arch>
|
||||||
|
<sm-arch>sm50</sm-arch>
|
||||||
|
<sm-arch>sm52</sm-arch>
|
||||||
|
<sm-arch>sm60</sm-arch>
|
||||||
|
<sm-arch>sm61</sm-arch>
|
||||||
|
<sm-arch>sm70</sm-arch>
|
||||||
|
<supported_envs>
|
||||||
|
<env>
|
||||||
|
<arch>x86_64</arch>
|
||||||
|
<platform>linux</platform>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<platform>windows7</platform>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<arch>x86_64</arch>
|
||||||
|
<platform>macosx</platform>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<arch>arm</arch>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<arch>aarch64</arch>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<arch>ppc64le</arch>
|
||||||
|
<platform>linux</platform>
|
||||||
|
</env>
|
||||||
|
</supported_envs>
|
||||||
|
<supported_sm_architectures>
|
||||||
|
<include>all</include>
|
||||||
|
</supported_sm_architectures>
|
||||||
|
<title>Device Query</title>
|
||||||
|
<type>exe</type>
|
||||||
|
</entry>
|
94
Samples/deviceQuery/README.md
Normal file
94
Samples/deviceQuery/README.md
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
# deviceQuery - Device Query
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
This sample enumerates the properties of the CUDA devices present in the system.
|
||||||
|
|
||||||
|
## Key Concepts
|
||||||
|
|
||||||
|
CUDA Runtime API, Device Query
|
||||||
|
|
||||||
|
## Supported SM Architectures
|
||||||
|
|
||||||
|
[SM 3.0 ](https://developer.nvidia.com/cuda-gpus) [SM 3.5 ](https://developer.nvidia.com/cuda-gpus) [SM 3.7 ](https://developer.nvidia.com/cuda-gpus) [SM 5.0 ](https://developer.nvidia.com/cuda-gpus) [SM 5.2 ](https://developer.nvidia.com/cuda-gpus) [SM 6.0 ](https://developer.nvidia.com/cuda-gpus) [SM 6.1 ](https://developer.nvidia.com/cuda-gpus) [SM 7.0 ](https://developer.nvidia.com/cuda-gpus)
|
||||||
|
|
||||||
|
## Supported OSes
|
||||||
|
|
||||||
|
Linux, Windows, MacOSX
|
||||||
|
|
||||||
|
## Supported CPU Architecture
|
||||||
|
|
||||||
|
x86_64, ppc64le, armv7l, aarch64
|
||||||
|
|
||||||
|
## CUDA APIs involved
|
||||||
|
|
||||||
|
### [CUDA Runtime API](http://docs.nvidia.com/cuda/cuda-runtime-api/index.html)
|
||||||
|
cudaSetDevice, cudaGetDeviceCount, cudaGetDeviceProperties, cudaDriverGetVersion, cudaRuntimeGetVersion
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
Download and install the [CUDA Toolkit 9.2](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
|
||||||
|
|
||||||
|
## Build and Run
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
The Windows samples are built using the Visual Studio IDE. Solution files (.sln) are provided for each supported version of Visual Studio, using the format:
|
||||||
|
```
|
||||||
|
*_vs<version>.sln - for Visual Studio <version>
|
||||||
|
```
|
||||||
|
Each individual sample has its own set of solution files in its directory:
|
||||||
|
|
||||||
|
To build/examine all the samples at once, the complete solution files should be used. To build/examine a single sample, the individual sample solution files should be used.
|
||||||
|
> **Note:** Some samples require that the Microsoft DirectX SDK (June 2010 or newer) be installed and that the VC++ directory paths are properly set up (**Tools > Options...**). Check DirectX Dependencies section for details."
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
The Linux samples are built using makefiles. To use the makefiles, change the current directory to the sample directory you wish to build, and run make:
|
||||||
|
```
|
||||||
|
$ cd <sample_dir>
|
||||||
|
$ make
|
||||||
|
```
|
||||||
|
The samples makefiles can take advantage of certain options:
|
||||||
|
* **TARGET_ARCH=<arch>** - cross-compile targeting a specific architecture. Allowed architectures are x86_64, ppc64le, armv7l, aarch64.
|
||||||
|
By default, TARGET_ARCH is set to HOST_ARCH. On a x86_64 machine, not setting TARGET_ARCH is the equivalent of setting TARGET_ARCH=x86_64.<br/>
|
||||||
|
`$ make TARGET_ARCH=x86_64` <br/> `$ make TARGET_ARCH=ppc64le` <br/> `$ make TARGET_ARCH=armv7l` <br/> `$ make TARGET_ARCH=aarch64` <br/>
|
||||||
|
See [here](http://docs.nvidia.com/cuda/cuda-samples/index.html#cross-samples) for more details.
|
||||||
|
* **dbg=1** - build with debug symbols
|
||||||
|
```
|
||||||
|
$ make dbg=1
|
||||||
|
```
|
||||||
|
* **SMS="A B ..."** - override the SM architectures for which the sample will be built, where `"A B ..."` is a space-delimited list of SM architectures. For example, to generate SASS for SM 50 and SM 60, use `SMS="50 60"`.
|
||||||
|
```
|
||||||
|
$ make SMS="50 60"
|
||||||
|
```
|
||||||
|
|
||||||
|
* **HOST_COMPILER=<host_compiler>** - override the default g++ host compiler. See the [Linux Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements) for a list of supported host compilers.
|
||||||
|
```
|
||||||
|
$ make HOST_COMPILER=g++
|
||||||
|
```
|
||||||
|
|
||||||
|
### Mac
|
||||||
|
The Mac samples are built using makefiles. To use the makefiles, change directory into the sample directory you wish to build, and run make:
|
||||||
|
```
|
||||||
|
$ cd <sample_dir>
|
||||||
|
$ make
|
||||||
|
```
|
||||||
|
|
||||||
|
The samples makefiles can take advantage of certain options:
|
||||||
|
|
||||||
|
* **dbg=1** - build with debug symbols
|
||||||
|
```
|
||||||
|
$ make dbg=1
|
||||||
|
```
|
||||||
|
|
||||||
|
* **SMS="A B ..."** - override the SM architectures for which the sample will be built, where "A B ..." is a space-delimited list of SM architectures. For example, to generate SASS for SM 50 and SM 60, use SMS="50 60".
|
||||||
|
```
|
||||||
|
$ make SMS="A B ..."
|
||||||
|
```
|
||||||
|
|
||||||
|
* **HOST_COMPILER=<host_compiler>** - override the default clang host compiler. See the [Mac Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html#system-requirements) for a list of supported host compilers.
|
||||||
|
```
|
||||||
|
$ make HOST_COMPILER=clang
|
||||||
|
```
|
||||||
|
|
||||||
|
## References (for more details)
|
||||||
|
|
338
Samples/deviceQuery/deviceQuery.cpp
Normal file
338
Samples/deviceQuery/deviceQuery.cpp
Normal file
|
@ -0,0 +1,338 @@
|
||||||
|
/* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This sample queries the properties of the CUDA devices present in the system
|
||||||
|
* via CUDA Runtime API. */
|
||||||
|
|
||||||
|
// std::system includes
|
||||||
|
|
||||||
|
#include <cuda_runtime.h>
|
||||||
|
#include <helper_cuda.h>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
int *pArgc = NULL;
|
||||||
|
char **pArgv = NULL;
|
||||||
|
|
||||||
|
#if CUDART_VERSION < 5000
|
||||||
|
|
||||||
|
// CUDA-C includes
|
||||||
|
#include <cuda.h>
|
||||||
|
|
||||||
|
// This function wraps the CUDA Driver API into a template function
|
||||||
|
template <class T>
|
||||||
|
inline void getCudaAttribute(T *attribute, CUdevice_attribute device_attribute,
|
||||||
|
int device) {
|
||||||
|
CUresult error = cuDeviceGetAttribute(attribute, device_attribute, device);
|
||||||
|
|
||||||
|
if (CUDA_SUCCESS != error) {
|
||||||
|
fprintf(
|
||||||
|
stderr,
|
||||||
|
"cuSafeCallNoSync() Driver API error = %04d from file <%s>, line %i.\n",
|
||||||
|
error, __FILE__, __LINE__);
|
||||||
|
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CUDART_VERSION < 5000 */
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Program main
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
pArgc = &argc;
|
||||||
|
pArgv = argv;
|
||||||
|
|
||||||
|
printf("%s Starting...\n\n", argv[0]);
|
||||||
|
printf(
|
||||||
|
" CUDA Device Query (Runtime API) version (CUDART static linking)\n\n");
|
||||||
|
|
||||||
|
int deviceCount = 0;
|
||||||
|
cudaError_t error_id = cudaGetDeviceCount(&deviceCount);
|
||||||
|
|
||||||
|
if (error_id != cudaSuccess) {
|
||||||
|
printf("cudaGetDeviceCount returned %d\n-> %s\n",
|
||||||
|
static_cast<int>(error_id), cudaGetErrorString(error_id));
|
||||||
|
printf("Result = FAIL\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This function call returns 0 if there are no CUDA capable devices.
|
||||||
|
if (deviceCount == 0) {
|
||||||
|
printf("There are no available device(s) that support CUDA\n");
|
||||||
|
} else {
|
||||||
|
printf("Detected %d CUDA Capable device(s)\n", deviceCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
int dev, driverVersion = 0, runtimeVersion = 0;
|
||||||
|
|
||||||
|
for (dev = 0; dev < deviceCount; ++dev) {
|
||||||
|
cudaSetDevice(dev);
|
||||||
|
cudaDeviceProp deviceProp;
|
||||||
|
cudaGetDeviceProperties(&deviceProp, dev);
|
||||||
|
|
||||||
|
printf("\nDevice %d: \"%s\"\n", dev, deviceProp.name);
|
||||||
|
|
||||||
|
// Console log
|
||||||
|
cudaDriverGetVersion(&driverVersion);
|
||||||
|
cudaRuntimeGetVersion(&runtimeVersion);
|
||||||
|
printf(" CUDA Driver Version / Runtime Version %d.%d / %d.%d\n",
|
||||||
|
driverVersion / 1000, (driverVersion % 100) / 10,
|
||||||
|
runtimeVersion / 1000, (runtimeVersion % 100) / 10);
|
||||||
|
printf(" CUDA Capability Major/Minor version number: %d.%d\n",
|
||||||
|
deviceProp.major, deviceProp.minor);
|
||||||
|
|
||||||
|
char msg[256];
|
||||||
|
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
|
||||||
|
sprintf_s(msg, sizeof(msg),
|
||||||
|
" Total amount of global memory: %.0f MBytes "
|
||||||
|
"(%llu bytes)\n",
|
||||||
|
static_cast<float>(deviceProp.totalGlobalMem / 1048576.0f),
|
||||||
|
(unsigned long long)deviceProp.totalGlobalMem);
|
||||||
|
#else
|
||||||
|
snprintf(msg, sizeof(msg),
|
||||||
|
" Total amount of global memory: %.0f MBytes "
|
||||||
|
"(%llu bytes)\n",
|
||||||
|
static_cast<float>(deviceProp.totalGlobalMem / 1048576.0f),
|
||||||
|
(unsigned long long)deviceProp.totalGlobalMem);
|
||||||
|
#endif
|
||||||
|
printf("%s", msg);
|
||||||
|
|
||||||
|
printf(" (%2d) Multiprocessors, (%3d) CUDA Cores/MP: %d CUDA Cores\n",
|
||||||
|
deviceProp.multiProcessorCount,
|
||||||
|
_ConvertSMVer2Cores(deviceProp.major, deviceProp.minor),
|
||||||
|
_ConvertSMVer2Cores(deviceProp.major, deviceProp.minor) *
|
||||||
|
deviceProp.multiProcessorCount);
|
||||||
|
printf(
|
||||||
|
" GPU Max Clock rate: %.0f MHz (%0.2f "
|
||||||
|
"GHz)\n",
|
||||||
|
deviceProp.clockRate * 1e-3f, deviceProp.clockRate * 1e-6f);
|
||||||
|
|
||||||
|
#if CUDART_VERSION >= 5000
|
||||||
|
// This is supported in CUDA 5.0 (runtime API device properties)
|
||||||
|
printf(" Memory Clock rate: %.0f Mhz\n",
|
||||||
|
deviceProp.memoryClockRate * 1e-3f);
|
||||||
|
printf(" Memory Bus Width: %d-bit\n",
|
||||||
|
deviceProp.memoryBusWidth);
|
||||||
|
|
||||||
|
if (deviceProp.l2CacheSize) {
|
||||||
|
printf(" L2 Cache Size: %d bytes\n",
|
||||||
|
deviceProp.l2CacheSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
// This only available in CUDA 4.0-4.2 (but these were only exposed in the
|
||||||
|
// CUDA Driver API)
|
||||||
|
int memoryClock;
|
||||||
|
getCudaAttribute<int>(&memoryClock, CU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE,
|
||||||
|
dev);
|
||||||
|
printf(" Memory Clock rate: %.0f Mhz\n",
|
||||||
|
memoryClock * 1e-3f);
|
||||||
|
int memBusWidth;
|
||||||
|
getCudaAttribute<int>(&memBusWidth,
|
||||||
|
CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH, dev);
|
||||||
|
printf(" Memory Bus Width: %d-bit\n",
|
||||||
|
memBusWidth);
|
||||||
|
int L2CacheSize;
|
||||||
|
getCudaAttribute<int>(&L2CacheSize, CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE, dev);
|
||||||
|
|
||||||
|
if (L2CacheSize) {
|
||||||
|
printf(" L2 Cache Size: %d bytes\n",
|
||||||
|
L2CacheSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf(
|
||||||
|
" Maximum Texture Dimension Size (x,y,z) 1D=(%d), 2D=(%d, "
|
||||||
|
"%d), 3D=(%d, %d, %d)\n",
|
||||||
|
deviceProp.maxTexture1D, deviceProp.maxTexture2D[0],
|
||||||
|
deviceProp.maxTexture2D[1], deviceProp.maxTexture3D[0],
|
||||||
|
deviceProp.maxTexture3D[1], deviceProp.maxTexture3D[2]);
|
||||||
|
printf(
|
||||||
|
" Maximum Layered 1D Texture Size, (num) layers 1D=(%d), %d layers\n",
|
||||||
|
deviceProp.maxTexture1DLayered[0], deviceProp.maxTexture1DLayered[1]);
|
||||||
|
printf(
|
||||||
|
" Maximum Layered 2D Texture Size, (num) layers 2D=(%d, %d), %d "
|
||||||
|
"layers\n",
|
||||||
|
deviceProp.maxTexture2DLayered[0], deviceProp.maxTexture2DLayered[1],
|
||||||
|
deviceProp.maxTexture2DLayered[2]);
|
||||||
|
|
||||||
|
printf(" Total amount of constant memory: %lu bytes\n",
|
||||||
|
deviceProp.totalConstMem);
|
||||||
|
printf(" Total amount of shared memory per block: %lu bytes\n",
|
||||||
|
deviceProp.sharedMemPerBlock);
|
||||||
|
printf(" Total number of registers available per block: %d\n",
|
||||||
|
deviceProp.regsPerBlock);
|
||||||
|
printf(" Warp size: %d\n",
|
||||||
|
deviceProp.warpSize);
|
||||||
|
printf(" Maximum number of threads per multiprocessor: %d\n",
|
||||||
|
deviceProp.maxThreadsPerMultiProcessor);
|
||||||
|
printf(" Maximum number of threads per block: %d\n",
|
||||||
|
deviceProp.maxThreadsPerBlock);
|
||||||
|
printf(" Max dimension size of a thread block (x,y,z): (%d, %d, %d)\n",
|
||||||
|
deviceProp.maxThreadsDim[0], deviceProp.maxThreadsDim[1],
|
||||||
|
deviceProp.maxThreadsDim[2]);
|
||||||
|
printf(" Max dimension size of a grid size (x,y,z): (%d, %d, %d)\n",
|
||||||
|
deviceProp.maxGridSize[0], deviceProp.maxGridSize[1],
|
||||||
|
deviceProp.maxGridSize[2]);
|
||||||
|
printf(" Maximum memory pitch: %lu bytes\n",
|
||||||
|
deviceProp.memPitch);
|
||||||
|
printf(" Texture alignment: %lu bytes\n",
|
||||||
|
deviceProp.textureAlignment);
|
||||||
|
printf(
|
||||||
|
" Concurrent copy and kernel execution: %s with %d copy "
|
||||||
|
"engine(s)\n",
|
||||||
|
(deviceProp.deviceOverlap ? "Yes" : "No"), deviceProp.asyncEngineCount);
|
||||||
|
printf(" Run time limit on kernels: %s\n",
|
||||||
|
deviceProp.kernelExecTimeoutEnabled ? "Yes" : "No");
|
||||||
|
printf(" Integrated GPU sharing Host Memory: %s\n",
|
||||||
|
deviceProp.integrated ? "Yes" : "No");
|
||||||
|
printf(" Support host page-locked memory mapping: %s\n",
|
||||||
|
deviceProp.canMapHostMemory ? "Yes" : "No");
|
||||||
|
printf(" Alignment requirement for Surfaces: %s\n",
|
||||||
|
deviceProp.surfaceAlignment ? "Yes" : "No");
|
||||||
|
printf(" Device has ECC support: %s\n",
|
||||||
|
deviceProp.ECCEnabled ? "Enabled" : "Disabled");
|
||||||
|
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
|
||||||
|
printf(" CUDA Device Driver Mode (TCC or WDDM): %s\n",
|
||||||
|
deviceProp.tccDriver ? "TCC (Tesla Compute Cluster Driver)"
|
||||||
|
: "WDDM (Windows Display Driver Model)");
|
||||||
|
#endif
|
||||||
|
printf(" Device supports Unified Addressing (UVA): %s\n",
|
||||||
|
deviceProp.unifiedAddressing ? "Yes" : "No");
|
||||||
|
printf(" Device supports Compute Preemption: %s\n",
|
||||||
|
deviceProp.computePreemptionSupported ? "Yes" : "No");
|
||||||
|
printf(" Supports Cooperative Kernel Launch: %s\n",
|
||||||
|
deviceProp.cooperativeLaunch ? "Yes" : "No");
|
||||||
|
printf(" Supports MultiDevice Co-op Kernel Launch: %s\n",
|
||||||
|
deviceProp.cooperativeMultiDeviceLaunch ? "Yes" : "No");
|
||||||
|
printf(" Device PCI Domain ID / Bus ID / location ID: %d / %d / %d\n",
|
||||||
|
deviceProp.pciDomainID, deviceProp.pciBusID, deviceProp.pciDeviceID);
|
||||||
|
|
||||||
|
const char *sComputeMode[] = {
|
||||||
|
"Default (multiple host threads can use ::cudaSetDevice() with device "
|
||||||
|
"simultaneously)",
|
||||||
|
"Exclusive (only one host thread in one process is able to use "
|
||||||
|
"::cudaSetDevice() with this device)",
|
||||||
|
"Prohibited (no host thread can use ::cudaSetDevice() with this "
|
||||||
|
"device)",
|
||||||
|
"Exclusive Process (many threads in one process is able to use "
|
||||||
|
"::cudaSetDevice() with this device)",
|
||||||
|
"Unknown",
|
||||||
|
NULL};
|
||||||
|
printf(" Compute Mode:\n");
|
||||||
|
printf(" < %s >\n", sComputeMode[deviceProp.computeMode]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there are 2 or more GPUs, query to determine whether RDMA is supported
|
||||||
|
if (deviceCount >= 2) {
|
||||||
|
cudaDeviceProp prop[64];
|
||||||
|
int gpuid[64]; // we want to find the first two GPUs that can support P2P
|
||||||
|
int gpu_p2p_count = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < deviceCount; i++) {
|
||||||
|
checkCudaErrors(cudaGetDeviceProperties(&prop[i], i));
|
||||||
|
|
||||||
|
// Only boards based on Fermi or later can support P2P
|
||||||
|
if ((prop[i].major >= 2)
|
||||||
|
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
|
||||||
|
// on Windows (64-bit), the Tesla Compute Cluster driver for windows
|
||||||
|
// must be enabled to support this
|
||||||
|
&& prop[i].tccDriver
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
|
// This is an array of P2P capable GPUs
|
||||||
|
gpuid[gpu_p2p_count++] = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show all the combinations of support P2P GPUs
|
||||||
|
int can_access_peer;
|
||||||
|
|
||||||
|
if (gpu_p2p_count >= 2) {
|
||||||
|
for (int i = 0; i < gpu_p2p_count; i++) {
|
||||||
|
for (int j = 0; j < gpu_p2p_count; j++) {
|
||||||
|
if (gpuid[i] == gpuid[j]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
checkCudaErrors(
|
||||||
|
cudaDeviceCanAccessPeer(&can_access_peer, gpuid[i], gpuid[j]));
|
||||||
|
printf("> Peer access from %s (GPU%d) -> %s (GPU%d) : %s\n",
|
||||||
|
prop[gpuid[i]].name, gpuid[i], prop[gpuid[j]].name, gpuid[j],
|
||||||
|
can_access_peer ? "Yes" : "No");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// csv masterlog info
|
||||||
|
// *****************************
|
||||||
|
// exe and CUDA driver name
|
||||||
|
printf("\n");
|
||||||
|
std::string sProfileString = "deviceQuery, CUDA Driver = CUDART";
|
||||||
|
char cTemp[16];
|
||||||
|
|
||||||
|
// driver version
|
||||||
|
sProfileString += ", CUDA Driver Version = ";
|
||||||
|
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
|
||||||
|
sprintf_s(cTemp, 10, "%d.%d", driverVersion/1000, (driverVersion%100)/10);
|
||||||
|
#else
|
||||||
|
snprintf(cTemp, sizeof(cTemp), "%d.%d", driverVersion / 1000,
|
||||||
|
(driverVersion % 100) / 10);
|
||||||
|
#endif
|
||||||
|
sProfileString += cTemp;
|
||||||
|
|
||||||
|
// Runtime version
|
||||||
|
sProfileString += ", CUDA Runtime Version = ";
|
||||||
|
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
|
||||||
|
sprintf_s(cTemp, 10, "%d.%d", runtimeVersion/1000, (runtimeVersion%100)/10);
|
||||||
|
#else
|
||||||
|
snprintf(cTemp, sizeof(cTemp), "%d.%d", runtimeVersion / 1000,
|
||||||
|
(runtimeVersion % 100) / 10);
|
||||||
|
#endif
|
||||||
|
sProfileString += cTemp;
|
||||||
|
|
||||||
|
// Device count
|
||||||
|
sProfileString += ", NumDevs = ";
|
||||||
|
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
|
||||||
|
sprintf_s(cTemp, 10, "%d", deviceCount);
|
||||||
|
#else
|
||||||
|
snprintf(cTemp, sizeof(cTemp), "%d", deviceCount);
|
||||||
|
#endif
|
||||||
|
sProfileString += cTemp;
|
||||||
|
sProfileString += "\n";
|
||||||
|
printf("%s", sProfileString.c_str());
|
||||||
|
|
||||||
|
printf("Result = PASS\n");
|
||||||
|
|
||||||
|
// finish
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
20
Samples/deviceQuery/deviceQuery_vs2010.sln
Normal file
20
Samples/deviceQuery/deviceQuery_vs2010.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||||
|
# Visual Studio 2010
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "deviceQuery", "deviceQuery_vs2010.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
106
Samples/deviceQuery/deviceQuery_vs2010.vcxproj
Normal file
106
Samples/deviceQuery/deviceQuery_vs2010.vcxproj
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>deviceQuery_vs2010</RootNamespace>
|
||||||
|
<ProjectName>deviceQuery</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/deviceQuery.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,sm_30;compute_35,sm_35;compute_37,sm_37;compute_50,sm_50;compute_52,sm_52;compute_60,sm_60;compute_61,sm_61;compute_70,sm_70;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="deviceQuery.cpp" />
|
||||||
|
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/deviceQuery/deviceQuery_vs2012.sln
Normal file
20
Samples/deviceQuery/deviceQuery_vs2012.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2012
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "deviceQuery", "deviceQuery_vs2012.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
107
Samples/deviceQuery/deviceQuery_vs2012.vcxproj
Normal file
107
Samples/deviceQuery/deviceQuery_vs2012.vcxproj
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>deviceQuery_vs2012</RootNamespace>
|
||||||
|
<ProjectName>deviceQuery</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/deviceQuery.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,sm_30;compute_35,sm_35;compute_37,sm_37;compute_50,sm_50;compute_52,sm_52;compute_60,sm_60;compute_61,sm_61;compute_70,sm_70;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="deviceQuery.cpp" />
|
||||||
|
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/deviceQuery/deviceQuery_vs2013.sln
Normal file
20
Samples/deviceQuery/deviceQuery_vs2013.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 13.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "deviceQuery", "deviceQuery_vs2013.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
107
Samples/deviceQuery/deviceQuery_vs2013.vcxproj
Normal file
107
Samples/deviceQuery/deviceQuery_vs2013.vcxproj
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>deviceQuery_vs2013</RootNamespace>
|
||||||
|
<ProjectName>deviceQuery</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/deviceQuery.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,sm_30;compute_35,sm_35;compute_37,sm_37;compute_50,sm_50;compute_52,sm_52;compute_60,sm_60;compute_61,sm_61;compute_70,sm_70;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="deviceQuery.cpp" />
|
||||||
|
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/deviceQuery/deviceQuery_vs2015.sln
Normal file
20
Samples/deviceQuery/deviceQuery_vs2015.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 14.00
|
||||||
|
# Visual Studio 2015
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "deviceQuery", "deviceQuery_vs2015.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
107
Samples/deviceQuery/deviceQuery_vs2015.vcxproj
Normal file
107
Samples/deviceQuery/deviceQuery_vs2015.vcxproj
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>deviceQuery_vs2015</RootNamespace>
|
||||||
|
<ProjectName>deviceQuery</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/deviceQuery.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,sm_30;compute_35,sm_35;compute_37,sm_37;compute_50,sm_50;compute_52,sm_52;compute_60,sm_60;compute_61,sm_61;compute_70,sm_70;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="deviceQuery.cpp" />
|
||||||
|
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/deviceQuery/deviceQuery_vs2017.sln
Normal file
20
Samples/deviceQuery/deviceQuery_vs2017.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2017
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "deviceQuery", "deviceQuery_vs2017.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
108
Samples/deviceQuery/deviceQuery_vs2017.vcxproj
Normal file
108
Samples/deviceQuery/deviceQuery_vs2017.vcxproj
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>deviceQuery_vs2017</RootNamespace>
|
||||||
|
<ProjectName>deviceQuery</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/deviceQuery.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,sm_30;compute_35,sm_35;compute_37,sm_37;compute_50,sm_50;compute_52,sm_52;compute_60,sm_60;compute_61,sm_61;compute_70,sm_70;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="deviceQuery.cpp" />
|
||||||
|
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
287
Samples/matrixMul/Makefile
Normal file
287
Samples/matrixMul/Makefile
Normal file
|
@ -0,0 +1,287 @@
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Copyright 1993-2015 NVIDIA Corporation. All rights reserved.
|
||||||
|
#
|
||||||
|
# NOTICE TO USER:
|
||||||
|
#
|
||||||
|
# This source code is subject to NVIDIA ownership rights under U.S. and
|
||||||
|
# international Copyright laws.
|
||||||
|
#
|
||||||
|
# NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
|
||||||
|
# CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
|
||||||
|
# IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
# REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
# MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
# IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
||||||
|
# OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||||
|
# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||||
|
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|
||||||
|
# OR PERFORMANCE OF THIS SOURCE CODE.
|
||||||
|
#
|
||||||
|
# U.S. Government End Users. This source code is a "commercial item" as
|
||||||
|
# that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
|
||||||
|
# "commercial computer software" and "commercial computer software
|
||||||
|
# documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
|
||||||
|
# and is provided to the U.S. Government only as a commercial end item.
|
||||||
|
# Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
|
||||||
|
# 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
|
||||||
|
# source code with only those rights set forth herein.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Makefile project only supported on Mac OS X and Linux Platforms)
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Location of the CUDA Toolkit
|
||||||
|
CUDA_PATH ?= /usr/local/cuda
|
||||||
|
|
||||||
|
##############################
|
||||||
|
# start deprecated interface #
|
||||||
|
##############################
|
||||||
|
ifeq ($(x86_64),1)
|
||||||
|
$(info WARNING - x86_64 variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=x86_64 instead)
|
||||||
|
TARGET_ARCH ?= x86_64
|
||||||
|
endif
|
||||||
|
ifeq ($(ARMv7),1)
|
||||||
|
$(info WARNING - ARMv7 variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=armv7l instead)
|
||||||
|
TARGET_ARCH ?= armv7l
|
||||||
|
endif
|
||||||
|
ifeq ($(aarch64),1)
|
||||||
|
$(info WARNING - aarch64 variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=aarch64 instead)
|
||||||
|
TARGET_ARCH ?= aarch64
|
||||||
|
endif
|
||||||
|
ifeq ($(ppc64le),1)
|
||||||
|
$(info WARNING - ppc64le variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=ppc64le instead)
|
||||||
|
TARGET_ARCH ?= ppc64le
|
||||||
|
endif
|
||||||
|
ifneq ($(GCC),)
|
||||||
|
$(info WARNING - GCC variable has been deprecated)
|
||||||
|
$(info WARNING - please use HOST_COMPILER=$(GCC) instead)
|
||||||
|
HOST_COMPILER ?= $(GCC)
|
||||||
|
endif
|
||||||
|
ifneq ($(abi),)
|
||||||
|
$(error ERROR - abi variable has been removed)
|
||||||
|
endif
|
||||||
|
############################
|
||||||
|
# end deprecated interface #
|
||||||
|
############################
|
||||||
|
|
||||||
|
# architecture
|
||||||
|
HOST_ARCH := $(shell uname -m)
|
||||||
|
TARGET_ARCH ?= $(HOST_ARCH)
|
||||||
|
ifneq (,$(filter $(TARGET_ARCH),x86_64 aarch64 ppc64le armv7l))
|
||||||
|
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifneq (,$(filter $(TARGET_ARCH),x86_64 aarch64 ppc64le))
|
||||||
|
TARGET_SIZE := 64
|
||||||
|
else ifneq (,$(filter $(TARGET_ARCH),armv7l))
|
||||||
|
TARGET_SIZE := 32
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
TARGET_SIZE := $(shell getconf LONG_BIT)
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
$(error ERROR - unsupported value $(TARGET_ARCH) for TARGET_ARCH!)
|
||||||
|
endif
|
||||||
|
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifeq (,$(filter $(HOST_ARCH)-$(TARGET_ARCH),aarch64-armv7l x86_64-armv7l x86_64-aarch64 x86_64-ppc64le))
|
||||||
|
$(error ERROR - cross compiling from $(HOST_ARCH) to $(TARGET_ARCH) is not supported!)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# When on native aarch64 system with userspace of 32-bit, change TARGET_ARCH to armv7l
|
||||||
|
ifeq ($(HOST_ARCH)-$(TARGET_ARCH)-$(TARGET_SIZE),aarch64-aarch64-32)
|
||||||
|
TARGET_ARCH = armv7l
|
||||||
|
endif
|
||||||
|
|
||||||
|
# operating system
|
||||||
|
HOST_OS := $(shell uname -s 2>/dev/null | tr "[:upper:]" "[:lower:]")
|
||||||
|
TARGET_OS ?= $(HOST_OS)
|
||||||
|
ifeq (,$(filter $(TARGET_OS),linux darwin qnx android))
|
||||||
|
$(error ERROR - unsupported value $(TARGET_OS) for TARGET_OS!)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# host compiler
|
||||||
|
ifeq ($(TARGET_OS),darwin)
|
||||||
|
ifeq ($(shell expr `xcodebuild -version | grep -i xcode | awk '{print $$2}' | cut -d'.' -f1` \>= 5),1)
|
||||||
|
HOST_COMPILER ?= clang++
|
||||||
|
endif
|
||||||
|
else ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifeq ($(HOST_ARCH)-$(TARGET_ARCH),x86_64-armv7l)
|
||||||
|
ifeq ($(TARGET_OS),linux)
|
||||||
|
HOST_COMPILER ?= arm-linux-gnueabihf-g++
|
||||||
|
else ifeq ($(TARGET_OS),qnx)
|
||||||
|
ifeq ($(QNX_HOST),)
|
||||||
|
$(error ERROR - QNX_HOST must be passed to the QNX host toolchain)
|
||||||
|
endif
|
||||||
|
ifeq ($(QNX_TARGET),)
|
||||||
|
$(error ERROR - QNX_TARGET must be passed to the QNX target toolchain)
|
||||||
|
endif
|
||||||
|
export QNX_HOST
|
||||||
|
export QNX_TARGET
|
||||||
|
HOST_COMPILER ?= $(QNX_HOST)/usr/bin/arm-unknown-nto-qnx6.6.0eabi-g++
|
||||||
|
else ifeq ($(TARGET_OS),android)
|
||||||
|
HOST_COMPILER ?= arm-linux-androideabi-g++
|
||||||
|
endif
|
||||||
|
else ifeq ($(TARGET_ARCH),aarch64)
|
||||||
|
ifeq ($(TARGET_OS), linux)
|
||||||
|
HOST_COMPILER ?= aarch64-linux-gnu-g++
|
||||||
|
else ifeq ($(TARGET_OS),qnx)
|
||||||
|
ifeq ($(QNX_HOST),)
|
||||||
|
$(error ERROR - QNX_HOST must be passed to the QNX host toolchain)
|
||||||
|
endif
|
||||||
|
ifeq ($(QNX_TARGET),)
|
||||||
|
$(error ERROR - QNX_TARGET must be passed to the QNX target toolchain)
|
||||||
|
endif
|
||||||
|
export QNX_HOST
|
||||||
|
export QNX_TARGET
|
||||||
|
HOST_COMPILER ?= $(QNX_HOST)/usr/bin/aarch64-unknown-nto-qnx7.0.0-g++
|
||||||
|
else ifeq ($(TARGET_OS), android)
|
||||||
|
HOST_COMPILER ?= aarch64-linux-android-g++
|
||||||
|
endif
|
||||||
|
else ifeq ($(TARGET_ARCH),ppc64le)
|
||||||
|
HOST_COMPILER ?= powerpc64le-linux-gnu-g++
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
HOST_COMPILER ?= g++
|
||||||
|
NVCC := $(CUDA_PATH)/bin/nvcc -ccbin $(HOST_COMPILER)
|
||||||
|
|
||||||
|
# internal flags
|
||||||
|
NVCCFLAGS := -m${TARGET_SIZE}
|
||||||
|
CCFLAGS :=
|
||||||
|
LDFLAGS :=
|
||||||
|
|
||||||
|
# build flags
|
||||||
|
ifeq ($(TARGET_OS),darwin)
|
||||||
|
LDFLAGS += -rpath $(CUDA_PATH)/lib
|
||||||
|
CCFLAGS += -arch $(HOST_ARCH)
|
||||||
|
else ifeq ($(HOST_ARCH)-$(TARGET_ARCH)-$(TARGET_OS),x86_64-armv7l-linux)
|
||||||
|
LDFLAGS += --dynamic-linker=/lib/ld-linux-armhf.so.3
|
||||||
|
CCFLAGS += -mfloat-abi=hard
|
||||||
|
else ifeq ($(TARGET_OS),android)
|
||||||
|
LDFLAGS += -pie
|
||||||
|
CCFLAGS += -fpie -fpic -fexceptions
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
||||||
|
ifneq ($(TARGET_FS),)
|
||||||
|
GCCVERSIONLTEQ46 := $(shell expr `$(HOST_COMPILER) -dumpversion` \<= 4.6)
|
||||||
|
ifeq ($(GCCVERSIONLTEQ46),1)
|
||||||
|
CCFLAGS += --sysroot=$(TARGET_FS)
|
||||||
|
endif
|
||||||
|
LDFLAGS += --sysroot=$(TARGET_FS)
|
||||||
|
LDFLAGS += -rpath-link=$(TARGET_FS)/lib
|
||||||
|
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib
|
||||||
|
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib/arm-linux-gnueabihf
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_OS),qnx)
|
||||||
|
CCFLAGS += -DWIN_INTERFACE_CUSTOM
|
||||||
|
LDFLAGS += -lsocket
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Install directory of different arch
|
||||||
|
CUDA_INSTALL_TARGET_DIR :=
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/armv7-linux-gnueabihf/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-linux)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/aarch64-linux/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-android)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/armv7-linux-androideabi/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-android)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/aarch64-linux-androideabi/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-qnx)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/ARMv7-linux-QNX/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-qnx)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/aarch64-qnx/
|
||||||
|
else ifeq ($(TARGET_ARCH),ppc64le)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/ppc64le-linux/
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Debug build flags
|
||||||
|
ifeq ($(dbg),1)
|
||||||
|
NVCCFLAGS += -g -G
|
||||||
|
BUILD_TYPE := debug
|
||||||
|
else
|
||||||
|
BUILD_TYPE := release
|
||||||
|
endif
|
||||||
|
|
||||||
|
ALL_CCFLAGS :=
|
||||||
|
ALL_CCFLAGS += $(NVCCFLAGS)
|
||||||
|
ALL_CCFLAGS += $(EXTRA_NVCCFLAGS)
|
||||||
|
ALL_CCFLAGS += $(addprefix -Xcompiler ,$(CCFLAGS))
|
||||||
|
ALL_CCFLAGS += $(addprefix -Xcompiler ,$(EXTRA_CCFLAGS))
|
||||||
|
|
||||||
|
SAMPLE_ENABLED := 1
|
||||||
|
|
||||||
|
ALL_LDFLAGS :=
|
||||||
|
ALL_LDFLAGS += $(ALL_CCFLAGS)
|
||||||
|
ALL_LDFLAGS += $(addprefix -Xlinker ,$(LDFLAGS))
|
||||||
|
ALL_LDFLAGS += $(addprefix -Xlinker ,$(EXTRA_LDFLAGS))
|
||||||
|
|
||||||
|
# Common includes and paths for CUDA
|
||||||
|
INCLUDES := -I../../Common
|
||||||
|
LIBRARIES :=
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Gencode arguments
|
||||||
|
SMS ?= 30 35 37 50 52 60 61 70
|
||||||
|
|
||||||
|
ifeq ($(SMS),)
|
||||||
|
$(info >>> WARNING - no SM architectures have been specified - waiving sample <<<)
|
||||||
|
SAMPLE_ENABLED := 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(GENCODE_FLAGS),)
|
||||||
|
# Generate SASS code for each SM architecture listed in $(SMS)
|
||||||
|
$(foreach sm,$(SMS),$(eval GENCODE_FLAGS += -gencode arch=compute_$(sm),code=sm_$(sm)))
|
||||||
|
|
||||||
|
# Generate PTX code from the highest SM architecture in $(SMS) to guarantee forward-compatibility
|
||||||
|
HIGHEST_SM := $(lastword $(sort $(SMS)))
|
||||||
|
ifneq ($(HIGHEST_SM),)
|
||||||
|
GENCODE_FLAGS += -gencode arch=compute_$(HIGHEST_SM),code=compute_$(HIGHEST_SM)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(SAMPLE_ENABLED),0)
|
||||||
|
EXEC ?= @echo "[@]"
|
||||||
|
endif
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Target rules
|
||||||
|
all: build
|
||||||
|
|
||||||
|
build: matrixMul
|
||||||
|
|
||||||
|
check.deps:
|
||||||
|
ifeq ($(SAMPLE_ENABLED),0)
|
||||||
|
@echo "Sample will be waived due to the above missing dependencies"
|
||||||
|
else
|
||||||
|
@echo "Sample is ready - all dependencies have been met"
|
||||||
|
endif
|
||||||
|
|
||||||
|
matrixMul.o:matrixMul.cu
|
||||||
|
$(EXEC) $(NVCC) $(INCLUDES) $(ALL_CCFLAGS) $(GENCODE_FLAGS) -o $@ -c $<
|
||||||
|
|
||||||
|
matrixMul: matrixMul.o
|
||||||
|
$(EXEC) $(NVCC) $(ALL_LDFLAGS) $(GENCODE_FLAGS) -o $@ $+ $(LIBRARIES)
|
||||||
|
$(EXEC) mkdir -p ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
||||||
|
$(EXEC) cp $@ ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
||||||
|
|
||||||
|
run: build
|
||||||
|
$(EXEC) ./matrixMul
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f matrixMul matrixMul.o
|
||||||
|
rm -rf ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)/matrixMul
|
||||||
|
|
||||||
|
clobber: clean
|
76
Samples/matrixMul/NsightEclipse.xml
Normal file
76
Samples/matrixMul/NsightEclipse.xml
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE entry SYSTEM "SamplesInfo.dtd">
|
||||||
|
<entry>
|
||||||
|
<name>matrixMul</name>
|
||||||
|
<cuda_api_list>
|
||||||
|
<toolkit>cudaEventCreate</toolkit>
|
||||||
|
<toolkit>cudaEventRecord</toolkit>
|
||||||
|
<toolkit>cudaEventQuery</toolkit>
|
||||||
|
<toolkit>cudaEventDestroy</toolkit>
|
||||||
|
<toolkit>cudaEventElapsedTime</toolkit>
|
||||||
|
<toolkit>cudaEventSynchronize</toolkit>
|
||||||
|
<toolkit>cudaMalloc</toolkit>
|
||||||
|
<toolkit>cudaFree</toolkit>
|
||||||
|
<toolkit>cudaMemcpy</toolkit>
|
||||||
|
</cuda_api_list>
|
||||||
|
<description><![CDATA[This sample implements matrix multiplication and is exactly the same as Chapter 6 of the programming guide. It has been written for clarity of exposition to illustrate various CUDA programming principles, not with the goal of providing the most performant generic kernel for matrix multiplication. To illustrate GPU performance for matrix multiply, this sample also shows how to use the new CUDA 4.0 interface for CUBLAS to demonstrate high-performance performance for matrix multiplication.]]></description>
|
||||||
|
<devicecompilation>whole</devicecompilation>
|
||||||
|
<includepaths>
|
||||||
|
<path>./</path>
|
||||||
|
<path>../</path>
|
||||||
|
<path>../../common/inc</path>
|
||||||
|
</includepaths>
|
||||||
|
<keyconcepts>
|
||||||
|
<concept level="basic">CUDA Runtime API</concept>
|
||||||
|
<concept level="basic">Linear Algebra</concept>
|
||||||
|
</keyconcepts>
|
||||||
|
<keywords>
|
||||||
|
<keyword>CUDA</keyword>
|
||||||
|
<keyword>matrix multiply</keyword>
|
||||||
|
</keywords>
|
||||||
|
<libraries>
|
||||||
|
</libraries>
|
||||||
|
<librarypaths>
|
||||||
|
</librarypaths>
|
||||||
|
<nsight_eclipse>true</nsight_eclipse>
|
||||||
|
<primary_file>matrixMul.cu</primary_file>
|
||||||
|
<scopes>
|
||||||
|
<scope>1:CUDA Basic Topics</scope>
|
||||||
|
<scope>3:Linear Algebra</scope>
|
||||||
|
</scopes>
|
||||||
|
<sm-arch>sm30</sm-arch>
|
||||||
|
<sm-arch>sm35</sm-arch>
|
||||||
|
<sm-arch>sm37</sm-arch>
|
||||||
|
<sm-arch>sm50</sm-arch>
|
||||||
|
<sm-arch>sm52</sm-arch>
|
||||||
|
<sm-arch>sm60</sm-arch>
|
||||||
|
<sm-arch>sm61</sm-arch>
|
||||||
|
<sm-arch>sm70</sm-arch>
|
||||||
|
<supported_envs>
|
||||||
|
<env>
|
||||||
|
<arch>x86_64</arch>
|
||||||
|
<platform>linux</platform>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<platform>windows7</platform>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<arch>x86_64</arch>
|
||||||
|
<platform>macosx</platform>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<arch>arm</arch>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<arch>aarch64</arch>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<arch>ppc64le</arch>
|
||||||
|
<platform>linux</platform>
|
||||||
|
</env>
|
||||||
|
</supported_envs>
|
||||||
|
<supported_sm_architectures>
|
||||||
|
<include>all</include>
|
||||||
|
</supported_sm_architectures>
|
||||||
|
<title>Matrix Multiplication (CUDA Runtime API Version)</title>
|
||||||
|
</entry>
|
94
Samples/matrixMul/README.md
Normal file
94
Samples/matrixMul/README.md
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
# matrixMul - Matrix Multiplication (CUDA Runtime API Version)
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
This sample implements matrix multiplication and is exactly the same as Chapter 6 of the programming guide. It has been written for clarity of exposition to illustrate various CUDA programming principles, not with the goal of providing the most performant generic kernel for matrix multiplication. To illustrate GPU performance for matrix multiply, this sample also shows how to use the new CUDA 4.0 interface for CUBLAS to demonstrate high-performance performance for matrix multiplication.
|
||||||
|
|
||||||
|
## Key Concepts
|
||||||
|
|
||||||
|
CUDA Runtime API, Linear Algebra
|
||||||
|
|
||||||
|
## Supported SM Architectures
|
||||||
|
|
||||||
|
[SM 3.0 ](https://developer.nvidia.com/cuda-gpus) [SM 3.5 ](https://developer.nvidia.com/cuda-gpus) [SM 3.7 ](https://developer.nvidia.com/cuda-gpus) [SM 5.0 ](https://developer.nvidia.com/cuda-gpus) [SM 5.2 ](https://developer.nvidia.com/cuda-gpus) [SM 6.0 ](https://developer.nvidia.com/cuda-gpus) [SM 6.1 ](https://developer.nvidia.com/cuda-gpus) [SM 7.0 ](https://developer.nvidia.com/cuda-gpus)
|
||||||
|
|
||||||
|
## Supported OSes
|
||||||
|
|
||||||
|
Linux, Windows, MacOSX
|
||||||
|
|
||||||
|
## Supported CPU Architecture
|
||||||
|
|
||||||
|
x86_64, ppc64le, armv7l, aarch64
|
||||||
|
|
||||||
|
## CUDA APIs involved
|
||||||
|
|
||||||
|
### [CUDA Runtime API](http://docs.nvidia.com/cuda/cuda-runtime-api/index.html)
|
||||||
|
cudaEventCreate, cudaEventRecord, cudaEventQuery, cudaEventDestroy, cudaEventElapsedTime, cudaEventSynchronize, cudaMalloc, cudaFree, cudaMemcpy
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
Download and install the [CUDA Toolkit 9.2](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
|
||||||
|
|
||||||
|
## Build and Run
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
The Windows samples are built using the Visual Studio IDE. Solution files (.sln) are provided for each supported version of Visual Studio, using the format:
|
||||||
|
```
|
||||||
|
*_vs<version>.sln - for Visual Studio <version>
|
||||||
|
```
|
||||||
|
Each individual sample has its own set of solution files in its directory:
|
||||||
|
|
||||||
|
To build/examine all the samples at once, the complete solution files should be used. To build/examine a single sample, the individual sample solution files should be used.
|
||||||
|
> **Note:** Some samples require that the Microsoft DirectX SDK (June 2010 or newer) be installed and that the VC++ directory paths are properly set up (**Tools > Options...**). Check DirectX Dependencies section for details."
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
The Linux samples are built using makefiles. To use the makefiles, change the current directory to the sample directory you wish to build, and run make:
|
||||||
|
```
|
||||||
|
$ cd <sample_dir>
|
||||||
|
$ make
|
||||||
|
```
|
||||||
|
The samples makefiles can take advantage of certain options:
|
||||||
|
* **TARGET_ARCH=<arch>** - cross-compile targeting a specific architecture. Allowed architectures are x86_64, ppc64le, armv7l, aarch64.
|
||||||
|
By default, TARGET_ARCH is set to HOST_ARCH. On a x86_64 machine, not setting TARGET_ARCH is the equivalent of setting TARGET_ARCH=x86_64.<br/>
|
||||||
|
`$ make TARGET_ARCH=x86_64` <br/> `$ make TARGET_ARCH=ppc64le` <br/> `$ make TARGET_ARCH=armv7l` <br/> `$ make TARGET_ARCH=aarch64` <br/>
|
||||||
|
See [here](http://docs.nvidia.com/cuda/cuda-samples/index.html#cross-samples) for more details.
|
||||||
|
* **dbg=1** - build with debug symbols
|
||||||
|
```
|
||||||
|
$ make dbg=1
|
||||||
|
```
|
||||||
|
* **SMS="A B ..."** - override the SM architectures for which the sample will be built, where `"A B ..."` is a space-delimited list of SM architectures. For example, to generate SASS for SM 50 and SM 60, use `SMS="50 60"`.
|
||||||
|
```
|
||||||
|
$ make SMS="50 60"
|
||||||
|
```
|
||||||
|
|
||||||
|
* **HOST_COMPILER=<host_compiler>** - override the default g++ host compiler. See the [Linux Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements) for a list of supported host compilers.
|
||||||
|
```
|
||||||
|
$ make HOST_COMPILER=g++
|
||||||
|
```
|
||||||
|
|
||||||
|
### Mac
|
||||||
|
The Mac samples are built using makefiles. To use the makefiles, change directory into the sample directory you wish to build, and run make:
|
||||||
|
```
|
||||||
|
$ cd <sample_dir>
|
||||||
|
$ make
|
||||||
|
```
|
||||||
|
|
||||||
|
The samples makefiles can take advantage of certain options:
|
||||||
|
|
||||||
|
* **dbg=1** - build with debug symbols
|
||||||
|
```
|
||||||
|
$ make dbg=1
|
||||||
|
```
|
||||||
|
|
||||||
|
* **SMS="A B ..."** - override the SM architectures for which the sample will be built, where "A B ..." is a space-delimited list of SM architectures. For example, to generate SASS for SM 50 and SM 60, use SMS="50 60".
|
||||||
|
```
|
||||||
|
$ make SMS="A B ..."
|
||||||
|
```
|
||||||
|
|
||||||
|
* **HOST_COMPILER=<host_compiler>** - override the default clang host compiler. See the [Mac Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html#system-requirements) for a list of supported host compilers.
|
||||||
|
```
|
||||||
|
$ make HOST_COMPILER=clang
|
||||||
|
```
|
||||||
|
|
||||||
|
## References (for more details)
|
||||||
|
|
348
Samples/matrixMul/matrixMul.cu
Normal file
348
Samples/matrixMul/matrixMul.cu
Normal file
|
@ -0,0 +1,348 @@
|
||||||
|
/* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Matrix multiplication: C = A * B.
|
||||||
|
* Host code.
|
||||||
|
*
|
||||||
|
* This sample implements matrix multiplication which makes use of shared memory
|
||||||
|
* to ensure data reuse, the matrix multiplication is done using tiling approach.
|
||||||
|
* It has been written for clarity of exposition to illustrate various CUDA programming
|
||||||
|
* principles, not with the goal of providing the most performant generic kernel for matrix multiplication.
|
||||||
|
* See also:
|
||||||
|
* V. Volkov and J. Demmel, "Benchmarking GPUs to tune dense linear algebra,"
|
||||||
|
* in Proc. 2008 ACM/IEEE Conf. on Supercomputing (SC '08),
|
||||||
|
* Piscataway, NJ: IEEE Press, 2008, pp. Art. 31:1-11.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// System includes
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
// CUDA runtime
|
||||||
|
#include <cuda_runtime.h>
|
||||||
|
|
||||||
|
// Helper functions and utilities to work with CUDA
|
||||||
|
#include <helper_functions.h>
|
||||||
|
#include <helper_cuda.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Matrix multiplication (CUDA Kernel) on the device: C = A * B
|
||||||
|
* wA is A's width and wB is B's width
|
||||||
|
*/
|
||||||
|
template <int BLOCK_SIZE> __global__ void MatrixMulCUDA(float *C, float *A,
|
||||||
|
float *B, int wA,
|
||||||
|
int wB) {
|
||||||
|
// Block index
|
||||||
|
int bx = blockIdx.x;
|
||||||
|
int by = blockIdx.y;
|
||||||
|
|
||||||
|
// Thread index
|
||||||
|
int tx = threadIdx.x;
|
||||||
|
int ty = threadIdx.y;
|
||||||
|
|
||||||
|
// Index of the first sub-matrix of A processed by the block
|
||||||
|
int aBegin = wA * BLOCK_SIZE * by;
|
||||||
|
|
||||||
|
// Index of the last sub-matrix of A processed by the block
|
||||||
|
int aEnd = aBegin + wA - 1;
|
||||||
|
|
||||||
|
// Step size used to iterate through the sub-matrices of A
|
||||||
|
int aStep = BLOCK_SIZE;
|
||||||
|
|
||||||
|
// Index of the first sub-matrix of B processed by the block
|
||||||
|
int bBegin = BLOCK_SIZE * bx;
|
||||||
|
|
||||||
|
// Step size used to iterate through the sub-matrices of B
|
||||||
|
int bStep = BLOCK_SIZE * wB;
|
||||||
|
|
||||||
|
// Csub is used to store the element of the block sub-matrix
|
||||||
|
// that is computed by the thread
|
||||||
|
float Csub = 0;
|
||||||
|
|
||||||
|
// Loop over all the sub-matrices of A and B
|
||||||
|
// required to compute the block sub-matrix
|
||||||
|
for (int a = aBegin, b = bBegin;
|
||||||
|
a <= aEnd;
|
||||||
|
a += aStep, b += bStep) {
|
||||||
|
// Declaration of the shared memory array As used to
|
||||||
|
// store the sub-matrix of A
|
||||||
|
__shared__ float As[BLOCK_SIZE][BLOCK_SIZE];
|
||||||
|
|
||||||
|
// Declaration of the shared memory array Bs used to
|
||||||
|
// store the sub-matrix of B
|
||||||
|
__shared__ float Bs[BLOCK_SIZE][BLOCK_SIZE];
|
||||||
|
|
||||||
|
// Load the matrices from device memory
|
||||||
|
// to shared memory; each thread loads
|
||||||
|
// one element of each matrix
|
||||||
|
As[ty][tx] = A[a + wA * ty + tx];
|
||||||
|
Bs[ty][tx] = B[b + wB * ty + tx];
|
||||||
|
|
||||||
|
// Synchronize to make sure the matrices are loaded
|
||||||
|
__syncthreads();
|
||||||
|
|
||||||
|
// Multiply the two matrices together;
|
||||||
|
// each thread computes one element
|
||||||
|
// of the block sub-matrix
|
||||||
|
#pragma unroll
|
||||||
|
|
||||||
|
for (int k = 0; k < BLOCK_SIZE; ++k) {
|
||||||
|
Csub += As[ty][k] * Bs[k][tx];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Synchronize to make sure that the preceding
|
||||||
|
// computation is done before loading two new
|
||||||
|
// sub-matrices of A and B in the next iteration
|
||||||
|
__syncthreads();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write the block sub-matrix to device memory;
|
||||||
|
// each thread writes one element
|
||||||
|
int c = wB * BLOCK_SIZE * by + BLOCK_SIZE * bx;
|
||||||
|
C[c + wB * ty + tx] = Csub;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConstantInit(float *data, int size, float val) {
|
||||||
|
for (int i = 0; i < size; ++i) {
|
||||||
|
data[i] = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run a simple test of matrix multiplication using CUDA
|
||||||
|
*/
|
||||||
|
int MatrixMultiply(int argc, char **argv,
|
||||||
|
int block_size, const dim3 &dimsA,
|
||||||
|
const dim3 &dimsB) {
|
||||||
|
// Allocate host memory for matrices A and B
|
||||||
|
unsigned int size_A = dimsA.x * dimsA.y;
|
||||||
|
unsigned int mem_size_A = sizeof(float) * size_A;
|
||||||
|
float *h_A = reinterpret_cast<float *>(malloc(mem_size_A));
|
||||||
|
unsigned int size_B = dimsB.x * dimsB.y;
|
||||||
|
unsigned int mem_size_B = sizeof(float) * size_B;
|
||||||
|
float *h_B = reinterpret_cast<float *>(malloc(mem_size_B));
|
||||||
|
|
||||||
|
// Initialize host memory
|
||||||
|
const float valB = 0.01f;
|
||||||
|
ConstantInit(h_A, size_A, 1.0f);
|
||||||
|
ConstantInit(h_B, size_B, valB);
|
||||||
|
|
||||||
|
// Allocate device memory
|
||||||
|
float *d_A, *d_B, *d_C;
|
||||||
|
|
||||||
|
// Allocate host matrix C
|
||||||
|
dim3 dimsC(dimsB.x, dimsA.y, 1);
|
||||||
|
unsigned int mem_size_C = dimsC.x * dimsC.y * sizeof(float);
|
||||||
|
float *h_C = reinterpret_cast<float *>(malloc(mem_size_C));
|
||||||
|
|
||||||
|
if (h_C == NULL) {
|
||||||
|
fprintf(stderr, "Failed to allocate host matrix C!\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
checkCudaErrors(cudaMalloc(reinterpret_cast<void **>(&d_A), mem_size_A));
|
||||||
|
|
||||||
|
checkCudaErrors(cudaMalloc(reinterpret_cast<void **>(&d_B), mem_size_B));
|
||||||
|
|
||||||
|
checkCudaErrors(cudaMalloc(reinterpret_cast<void **>(&d_C), mem_size_C));
|
||||||
|
|
||||||
|
// copy host memory to device
|
||||||
|
checkCudaErrors(cudaMemcpy(d_A, h_A, mem_size_A, cudaMemcpyHostToDevice));
|
||||||
|
|
||||||
|
checkCudaErrors(cudaMemcpy(d_B, h_B, mem_size_B, cudaMemcpyHostToDevice));
|
||||||
|
|
||||||
|
// Setup execution parameters
|
||||||
|
dim3 threads(block_size, block_size);
|
||||||
|
dim3 grid(dimsB.x / threads.x, dimsA.y / threads.y);
|
||||||
|
|
||||||
|
// Create and start timer
|
||||||
|
printf("Computing result using CUDA Kernel...\n");
|
||||||
|
|
||||||
|
// Performs warmup operation using matrixMul CUDA kernel
|
||||||
|
if (block_size == 16) {
|
||||||
|
MatrixMulCUDA<16> <<< grid, threads >>>(d_C, d_A, d_B,
|
||||||
|
dimsA.x, dimsB.x);
|
||||||
|
} else {
|
||||||
|
MatrixMulCUDA<32> <<< grid, threads >>>(d_C, d_A, d_B,
|
||||||
|
dimsA.x, dimsB.x);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("done\n");
|
||||||
|
|
||||||
|
cudaDeviceSynchronize();
|
||||||
|
|
||||||
|
// Allocate CUDA events that we'll use for timing
|
||||||
|
cudaEvent_t start;
|
||||||
|
checkCudaErrors(cudaEventCreate(&start));
|
||||||
|
|
||||||
|
cudaEvent_t stop;
|
||||||
|
checkCudaErrors(cudaEventCreate(&stop));
|
||||||
|
|
||||||
|
// Record the start event
|
||||||
|
checkCudaErrors(cudaEventRecord(start, NULL));
|
||||||
|
|
||||||
|
// Execute the kernel
|
||||||
|
int nIter = 300;
|
||||||
|
|
||||||
|
for (int j = 0; j < nIter; j++) {
|
||||||
|
if (block_size == 16) {
|
||||||
|
MatrixMulCUDA<16> <<< grid, threads >>>(d_C, d_A, d_B,
|
||||||
|
dimsA.x, dimsB.x);
|
||||||
|
} else {
|
||||||
|
MatrixMulCUDA<32> <<< grid, threads >>>(d_C, d_A, d_B,
|
||||||
|
dimsA.x, dimsB.x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Record the stop event
|
||||||
|
checkCudaErrors(cudaEventRecord(stop, NULL));
|
||||||
|
|
||||||
|
// Wait for the stop event to complete
|
||||||
|
checkCudaErrors(cudaEventSynchronize(stop));
|
||||||
|
|
||||||
|
float msecTotal = 0.0f;
|
||||||
|
checkCudaErrors(cudaEventElapsedTime(&msecTotal, start, stop));
|
||||||
|
|
||||||
|
// Compute and print the performance
|
||||||
|
float msecPerMatrixMul = msecTotal / nIter;
|
||||||
|
double flopsPerMatrixMul = 2.0 * static_cast<double>(dimsA.x) *
|
||||||
|
static_cast<double>(dimsA.y) *
|
||||||
|
static_cast<double>(dimsB.x);
|
||||||
|
double gigaFlops = (flopsPerMatrixMul * 1.0e-9f) /
|
||||||
|
(msecPerMatrixMul / 1000.0f);
|
||||||
|
printf(
|
||||||
|
"Performance= %.2f GFlop/s, Time= %.3f msec, Size= %.0f Ops," \
|
||||||
|
" WorkgroupSize= %u threads/block\n",
|
||||||
|
gigaFlops,
|
||||||
|
msecPerMatrixMul,
|
||||||
|
flopsPerMatrixMul,
|
||||||
|
threads.x * threads.y);
|
||||||
|
|
||||||
|
// Copy result from device to host
|
||||||
|
checkCudaErrors(cudaMemcpy(h_C, d_C, mem_size_C, cudaMemcpyDeviceToHost));
|
||||||
|
|
||||||
|
printf("Checking computed result for correctness: ");
|
||||||
|
bool correct = true;
|
||||||
|
|
||||||
|
// test relative error by the formula
|
||||||
|
// |<x, y>_cpu - <x,y>_gpu|/<|x|, |y|> < eps
|
||||||
|
double eps = 1.e-6; // machine zero
|
||||||
|
|
||||||
|
for (int i = 0; i < static_cast<int>(dimsC.x * dimsC.y); i++) {
|
||||||
|
double abs_err = fabs(h_C[i] - (dimsA.x * valB));
|
||||||
|
double dot_length = dimsA.x;
|
||||||
|
double abs_val = fabs(h_C[i]);
|
||||||
|
double rel_err = abs_err / abs_val / dot_length;
|
||||||
|
|
||||||
|
if (rel_err > eps) {
|
||||||
|
printf("Error! Matrix[%05d]=%.8f, ref=%.8f error term is > %E\n",
|
||||||
|
i, h_C[i], dimsA.x * valB, eps);
|
||||||
|
correct = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%s\n", correct ? "Result = PASS" : "Result = FAIL");
|
||||||
|
|
||||||
|
// Clean up memory
|
||||||
|
free(h_A);
|
||||||
|
free(h_B);
|
||||||
|
free(h_C);
|
||||||
|
checkCudaErrors(cudaFree(d_A));
|
||||||
|
checkCudaErrors(cudaFree(d_B));
|
||||||
|
checkCudaErrors(cudaFree(d_C));
|
||||||
|
|
||||||
|
printf("\nNOTE: The CUDA Samples are not meant for performance"\
|
||||||
|
"measurements. Results may vary when GPU Boost is enabled.\n");
|
||||||
|
|
||||||
|
if (correct) {
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
} else {
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Program main
|
||||||
|
*/
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
printf("[Matrix Multiply Using CUDA] - Starting...\n");
|
||||||
|
|
||||||
|
if (checkCmdLineFlag(argc, (const char **)argv, "help") ||
|
||||||
|
checkCmdLineFlag(argc, (const char **)argv, "?")) {
|
||||||
|
printf("Usage -device=n (n >= 0 for deviceID)\n");
|
||||||
|
printf(" -wA=WidthA -hA=HeightA (Width x Height of Matrix A)\n");
|
||||||
|
printf(" -wB=WidthB -hB=HeightB (Width x Height of Matrix B)\n");
|
||||||
|
printf(" Note: Outer matrix dimensions of A & B matrices" \
|
||||||
|
" must be equal.\n");
|
||||||
|
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This will pick the best possible CUDA capable device, otherwise
|
||||||
|
// override the device ID based on input provided at the command line
|
||||||
|
int dev = findCudaDevice(argc, (const char **)argv);
|
||||||
|
|
||||||
|
int block_size = 32;
|
||||||
|
|
||||||
|
dim3 dimsA(5 * 2 * block_size, 5 * 2 * block_size, 1);
|
||||||
|
dim3 dimsB(5 * 4 * block_size, 5 * 2 * block_size, 1);
|
||||||
|
|
||||||
|
// width of Matrix A
|
||||||
|
if (checkCmdLineFlag(argc, (const char **)argv, "wA")) {
|
||||||
|
dimsA.x = getCmdLineArgumentInt(argc, (const char **)argv, "wA");
|
||||||
|
}
|
||||||
|
|
||||||
|
// height of Matrix A
|
||||||
|
if (checkCmdLineFlag(argc, (const char **)argv, "hA")) {
|
||||||
|
dimsA.y = getCmdLineArgumentInt(argc, (const char **)argv, "hA");
|
||||||
|
}
|
||||||
|
|
||||||
|
// width of Matrix B
|
||||||
|
if (checkCmdLineFlag(argc, (const char **)argv, "wB")) {
|
||||||
|
dimsB.x = getCmdLineArgumentInt(argc, (const char **)argv, "wB");
|
||||||
|
}
|
||||||
|
|
||||||
|
// height of Matrix B
|
||||||
|
if (checkCmdLineFlag(argc, (const char **)argv, "hB")) {
|
||||||
|
dimsB.y = getCmdLineArgumentInt(argc, (const char **)argv, "hB");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dimsA.x != dimsB.y) {
|
||||||
|
printf("Error: outer matrix dimensions must be equal. (%d != %d)\n",
|
||||||
|
dimsA.x, dimsB.y);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("MatrixA(%d,%d), MatrixB(%d,%d)\n", dimsA.x, dimsA.y,
|
||||||
|
dimsB.x, dimsB.y);
|
||||||
|
|
||||||
|
int matrix_result = MatrixMultiply(argc, argv, block_size, dimsA, dimsB);
|
||||||
|
|
||||||
|
exit(matrix_result);
|
||||||
|
}
|
20
Samples/matrixMul/matrixMul_vs2010.sln
Normal file
20
Samples/matrixMul/matrixMul_vs2010.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||||
|
# Visual Studio 2010
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "matrixMul", "matrixMul_vs2010.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
106
Samples/matrixMul/matrixMul_vs2010.vcxproj
Normal file
106
Samples/matrixMul/matrixMul_vs2010.vcxproj
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>matrixMul_vs2010</RootNamespace>
|
||||||
|
<ProjectName>matrixMul</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/matrixMul.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,sm_30;compute_35,sm_35;compute_37,sm_37;compute_50,sm_50;compute_52,sm_52;compute_60,sm_60;compute_61,sm_61;compute_70,sm_70;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<CudaCompile Include="matrixMul.cu" />
|
||||||
|
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/matrixMul/matrixMul_vs2012.sln
Normal file
20
Samples/matrixMul/matrixMul_vs2012.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2012
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "matrixMul", "matrixMul_vs2012.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
107
Samples/matrixMul/matrixMul_vs2012.vcxproj
Normal file
107
Samples/matrixMul/matrixMul_vs2012.vcxproj
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>matrixMul_vs2012</RootNamespace>
|
||||||
|
<ProjectName>matrixMul</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/matrixMul.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,sm_30;compute_35,sm_35;compute_37,sm_37;compute_50,sm_50;compute_52,sm_52;compute_60,sm_60;compute_61,sm_61;compute_70,sm_70;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<CudaCompile Include="matrixMul.cu" />
|
||||||
|
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/matrixMul/matrixMul_vs2013.sln
Normal file
20
Samples/matrixMul/matrixMul_vs2013.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 13.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "matrixMul", "matrixMul_vs2013.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
107
Samples/matrixMul/matrixMul_vs2013.vcxproj
Normal file
107
Samples/matrixMul/matrixMul_vs2013.vcxproj
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>matrixMul_vs2013</RootNamespace>
|
||||||
|
<ProjectName>matrixMul</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/matrixMul.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,sm_30;compute_35,sm_35;compute_37,sm_37;compute_50,sm_50;compute_52,sm_52;compute_60,sm_60;compute_61,sm_61;compute_70,sm_70;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<CudaCompile Include="matrixMul.cu" />
|
||||||
|
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/matrixMul/matrixMul_vs2015.sln
Normal file
20
Samples/matrixMul/matrixMul_vs2015.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 14.00
|
||||||
|
# Visual Studio 2015
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "matrixMul", "matrixMul_vs2015.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
107
Samples/matrixMul/matrixMul_vs2015.vcxproj
Normal file
107
Samples/matrixMul/matrixMul_vs2015.vcxproj
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>matrixMul_vs2015</RootNamespace>
|
||||||
|
<ProjectName>matrixMul</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/matrixMul.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,sm_30;compute_35,sm_35;compute_37,sm_37;compute_50,sm_50;compute_52,sm_52;compute_60,sm_60;compute_61,sm_61;compute_70,sm_70;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<CudaCompile Include="matrixMul.cu" />
|
||||||
|
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/matrixMul/matrixMul_vs2017.sln
Normal file
20
Samples/matrixMul/matrixMul_vs2017.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2017
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "matrixMul", "matrixMul_vs2017.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
108
Samples/matrixMul/matrixMul_vs2017.vcxproj
Normal file
108
Samples/matrixMul/matrixMul_vs2017.vcxproj
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>matrixMul_vs2017</RootNamespace>
|
||||||
|
<ProjectName>matrixMul</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/matrixMul.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,sm_30;compute_35,sm_35;compute_37,sm_37;compute_50,sm_50;compute_52,sm_52;compute_60,sm_60;compute_61,sm_61;compute_70,sm_70;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<CudaCompile Include="matrixMul.cu" />
|
||||||
|
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
344
Samples/matrixMulDrv/Makefile
Normal file
344
Samples/matrixMulDrv/Makefile
Normal file
|
@ -0,0 +1,344 @@
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Copyright 1993-2015 NVIDIA Corporation. All rights reserved.
|
||||||
|
#
|
||||||
|
# NOTICE TO USER:
|
||||||
|
#
|
||||||
|
# This source code is subject to NVIDIA ownership rights under U.S. and
|
||||||
|
# international Copyright laws.
|
||||||
|
#
|
||||||
|
# NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
|
||||||
|
# CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
|
||||||
|
# IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
# REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
# MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
# IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
||||||
|
# OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||||
|
# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||||
|
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|
||||||
|
# OR PERFORMANCE OF THIS SOURCE CODE.
|
||||||
|
#
|
||||||
|
# U.S. Government End Users. This source code is a "commercial item" as
|
||||||
|
# that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
|
||||||
|
# "commercial computer software" and "commercial computer software
|
||||||
|
# documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
|
||||||
|
# and is provided to the U.S. Government only as a commercial end item.
|
||||||
|
# Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
|
||||||
|
# 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
|
||||||
|
# source code with only those rights set forth herein.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Makefile project only supported on Mac OS X and Linux Platforms)
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Location of the CUDA Toolkit
|
||||||
|
CUDA_PATH ?= /usr/local/cuda
|
||||||
|
|
||||||
|
##############################
|
||||||
|
# start deprecated interface #
|
||||||
|
##############################
|
||||||
|
ifeq ($(x86_64),1)
|
||||||
|
$(info WARNING - x86_64 variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=x86_64 instead)
|
||||||
|
TARGET_ARCH ?= x86_64
|
||||||
|
endif
|
||||||
|
ifeq ($(ARMv7),1)
|
||||||
|
$(info WARNING - ARMv7 variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=armv7l instead)
|
||||||
|
TARGET_ARCH ?= armv7l
|
||||||
|
endif
|
||||||
|
ifeq ($(aarch64),1)
|
||||||
|
$(info WARNING - aarch64 variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=aarch64 instead)
|
||||||
|
TARGET_ARCH ?= aarch64
|
||||||
|
endif
|
||||||
|
ifeq ($(ppc64le),1)
|
||||||
|
$(info WARNING - ppc64le variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=ppc64le instead)
|
||||||
|
TARGET_ARCH ?= ppc64le
|
||||||
|
endif
|
||||||
|
ifneq ($(GCC),)
|
||||||
|
$(info WARNING - GCC variable has been deprecated)
|
||||||
|
$(info WARNING - please use HOST_COMPILER=$(GCC) instead)
|
||||||
|
HOST_COMPILER ?= $(GCC)
|
||||||
|
endif
|
||||||
|
ifneq ($(abi),)
|
||||||
|
$(error ERROR - abi variable has been removed)
|
||||||
|
endif
|
||||||
|
############################
|
||||||
|
# end deprecated interface #
|
||||||
|
############################
|
||||||
|
|
||||||
|
# architecture
|
||||||
|
HOST_ARCH := $(shell uname -m)
|
||||||
|
TARGET_ARCH ?= $(HOST_ARCH)
|
||||||
|
ifneq (,$(filter $(TARGET_ARCH),x86_64 aarch64 ppc64le armv7l))
|
||||||
|
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifneq (,$(filter $(TARGET_ARCH),x86_64 aarch64 ppc64le))
|
||||||
|
TARGET_SIZE := 64
|
||||||
|
else ifneq (,$(filter $(TARGET_ARCH),armv7l))
|
||||||
|
TARGET_SIZE := 32
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
TARGET_SIZE := $(shell getconf LONG_BIT)
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
$(error ERROR - unsupported value $(TARGET_ARCH) for TARGET_ARCH!)
|
||||||
|
endif
|
||||||
|
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifeq (,$(filter $(HOST_ARCH)-$(TARGET_ARCH),aarch64-armv7l x86_64-armv7l x86_64-aarch64 x86_64-ppc64le))
|
||||||
|
$(error ERROR - cross compiling from $(HOST_ARCH) to $(TARGET_ARCH) is not supported!)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# When on native aarch64 system with userspace of 32-bit, change TARGET_ARCH to armv7l
|
||||||
|
ifeq ($(HOST_ARCH)-$(TARGET_ARCH)-$(TARGET_SIZE),aarch64-aarch64-32)
|
||||||
|
TARGET_ARCH = armv7l
|
||||||
|
endif
|
||||||
|
|
||||||
|
# operating system
|
||||||
|
HOST_OS := $(shell uname -s 2>/dev/null | tr "[:upper:]" "[:lower:]")
|
||||||
|
TARGET_OS ?= $(HOST_OS)
|
||||||
|
ifeq (,$(filter $(TARGET_OS),linux darwin qnx android))
|
||||||
|
$(error ERROR - unsupported value $(TARGET_OS) for TARGET_OS!)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# host compiler
|
||||||
|
ifeq ($(TARGET_OS),darwin)
|
||||||
|
ifeq ($(shell expr `xcodebuild -version | grep -i xcode | awk '{print $$2}' | cut -d'.' -f1` \>= 5),1)
|
||||||
|
HOST_COMPILER ?= clang++
|
||||||
|
endif
|
||||||
|
else ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifeq ($(HOST_ARCH)-$(TARGET_ARCH),x86_64-armv7l)
|
||||||
|
ifeq ($(TARGET_OS),linux)
|
||||||
|
HOST_COMPILER ?= arm-linux-gnueabihf-g++
|
||||||
|
else ifeq ($(TARGET_OS),qnx)
|
||||||
|
ifeq ($(QNX_HOST),)
|
||||||
|
$(error ERROR - QNX_HOST must be passed to the QNX host toolchain)
|
||||||
|
endif
|
||||||
|
ifeq ($(QNX_TARGET),)
|
||||||
|
$(error ERROR - QNX_TARGET must be passed to the QNX target toolchain)
|
||||||
|
endif
|
||||||
|
export QNX_HOST
|
||||||
|
export QNX_TARGET
|
||||||
|
HOST_COMPILER ?= $(QNX_HOST)/usr/bin/arm-unknown-nto-qnx6.6.0eabi-g++
|
||||||
|
else ifeq ($(TARGET_OS),android)
|
||||||
|
HOST_COMPILER ?= arm-linux-androideabi-g++
|
||||||
|
endif
|
||||||
|
else ifeq ($(TARGET_ARCH),aarch64)
|
||||||
|
ifeq ($(TARGET_OS), linux)
|
||||||
|
HOST_COMPILER ?= aarch64-linux-gnu-g++
|
||||||
|
else ifeq ($(TARGET_OS),qnx)
|
||||||
|
ifeq ($(QNX_HOST),)
|
||||||
|
$(error ERROR - QNX_HOST must be passed to the QNX host toolchain)
|
||||||
|
endif
|
||||||
|
ifeq ($(QNX_TARGET),)
|
||||||
|
$(error ERROR - QNX_TARGET must be passed to the QNX target toolchain)
|
||||||
|
endif
|
||||||
|
export QNX_HOST
|
||||||
|
export QNX_TARGET
|
||||||
|
HOST_COMPILER ?= $(QNX_HOST)/usr/bin/aarch64-unknown-nto-qnx7.0.0-g++
|
||||||
|
else ifeq ($(TARGET_OS), android)
|
||||||
|
HOST_COMPILER ?= aarch64-linux-android-g++
|
||||||
|
endif
|
||||||
|
else ifeq ($(TARGET_ARCH),ppc64le)
|
||||||
|
HOST_COMPILER ?= powerpc64le-linux-gnu-g++
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
HOST_COMPILER ?= g++
|
||||||
|
NVCC := $(CUDA_PATH)/bin/nvcc -ccbin $(HOST_COMPILER)
|
||||||
|
|
||||||
|
# internal flags
|
||||||
|
NVCCFLAGS := -m${TARGET_SIZE}
|
||||||
|
CCFLAGS :=
|
||||||
|
LDFLAGS :=
|
||||||
|
|
||||||
|
# build flags
|
||||||
|
ifeq ($(TARGET_OS),darwin)
|
||||||
|
LDFLAGS += -rpath $(CUDA_PATH)/lib
|
||||||
|
CCFLAGS += -arch $(HOST_ARCH)
|
||||||
|
else ifeq ($(HOST_ARCH)-$(TARGET_ARCH)-$(TARGET_OS),x86_64-armv7l-linux)
|
||||||
|
LDFLAGS += --dynamic-linker=/lib/ld-linux-armhf.so.3
|
||||||
|
CCFLAGS += -mfloat-abi=hard
|
||||||
|
else ifeq ($(TARGET_OS),android)
|
||||||
|
LDFLAGS += -pie
|
||||||
|
CCFLAGS += -fpie -fpic -fexceptions
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
||||||
|
ifneq ($(TARGET_FS),)
|
||||||
|
GCCVERSIONLTEQ46 := $(shell expr `$(HOST_COMPILER) -dumpversion` \<= 4.6)
|
||||||
|
ifeq ($(GCCVERSIONLTEQ46),1)
|
||||||
|
CCFLAGS += --sysroot=$(TARGET_FS)
|
||||||
|
endif
|
||||||
|
LDFLAGS += --sysroot=$(TARGET_FS)
|
||||||
|
LDFLAGS += -rpath-link=$(TARGET_FS)/lib
|
||||||
|
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib
|
||||||
|
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib/arm-linux-gnueabihf
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_OS),qnx)
|
||||||
|
CCFLAGS += -DWIN_INTERFACE_CUSTOM
|
||||||
|
LDFLAGS += -lsocket
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Install directory of different arch
|
||||||
|
CUDA_INSTALL_TARGET_DIR :=
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/armv7-linux-gnueabihf/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-linux)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/aarch64-linux/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-android)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/armv7-linux-androideabi/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-android)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/aarch64-linux-androideabi/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-qnx)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/ARMv7-linux-QNX/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-qnx)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/aarch64-qnx/
|
||||||
|
else ifeq ($(TARGET_ARCH),ppc64le)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/ppc64le-linux/
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Debug build flags
|
||||||
|
ifeq ($(dbg),1)
|
||||||
|
NVCCFLAGS += -g -G
|
||||||
|
BUILD_TYPE := debug
|
||||||
|
else
|
||||||
|
BUILD_TYPE := release
|
||||||
|
endif
|
||||||
|
|
||||||
|
ALL_CCFLAGS :=
|
||||||
|
ALL_CCFLAGS += $(NVCCFLAGS)
|
||||||
|
ALL_CCFLAGS += $(EXTRA_NVCCFLAGS)
|
||||||
|
ALL_CCFLAGS += $(addprefix -Xcompiler ,$(CCFLAGS))
|
||||||
|
ALL_CCFLAGS += $(addprefix -Xcompiler ,$(EXTRA_CCFLAGS))
|
||||||
|
|
||||||
|
UBUNTU = $(shell lsb_release -i -s 2>/dev/null | grep -i ubuntu)
|
||||||
|
|
||||||
|
SAMPLE_ENABLED := 1
|
||||||
|
|
||||||
|
ALL_LDFLAGS :=
|
||||||
|
ALL_LDFLAGS += $(ALL_CCFLAGS)
|
||||||
|
ALL_LDFLAGS += $(addprefix -Xlinker ,$(LDFLAGS))
|
||||||
|
ALL_LDFLAGS += $(addprefix -Xlinker ,$(EXTRA_LDFLAGS))
|
||||||
|
|
||||||
|
# Common includes and paths for CUDA
|
||||||
|
INCLUDES := -I../../Common
|
||||||
|
LIBRARIES :=
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
PTX_FILE := matrixMul_kernel${TARGET_SIZE}.ptx
|
||||||
|
|
||||||
|
# Gencode arguments
|
||||||
|
SMS ?=
|
||||||
|
|
||||||
|
ifeq ($(GENCODE_FLAGS),)
|
||||||
|
# Generate SASS code for each SM architecture listed in $(SMS)
|
||||||
|
$(foreach sm,$(SMS),$(eval GENCODE_FLAGS += -gencode arch=compute_$(sm),code=sm_$(sm)))
|
||||||
|
|
||||||
|
ifeq ($(SMS),)
|
||||||
|
# Generate PTX code from SM 30
|
||||||
|
GENCODE_FLAGS += -gencode arch=compute_30,code=compute_30
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Generate PTX code from the highest SM architecture in $(SMS) to guarantee forward-compatibility
|
||||||
|
HIGHEST_SM := $(lastword $(sort $(SMS)))
|
||||||
|
ifneq ($(HIGHEST_SM),)
|
||||||
|
GENCODE_FLAGS += -gencode arch=compute_$(HIGHEST_SM),code=compute_$(HIGHEST_SM)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_OS),darwin)
|
||||||
|
ALL_LDFLAGS += -Xcompiler -F/Library/Frameworks -Xlinker -framework -Xlinker CUDA
|
||||||
|
else
|
||||||
|
ifeq ($(TARGET_ARCH),x86_64)
|
||||||
|
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/lib64/stubs
|
||||||
|
CUDA_SEARCH_PATH += $(CUDA_PATH)/targets/x86_64-linux/lib/stubs
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
||||||
|
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/armv7-linux-gnueabihf/lib/stubs
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-linux)
|
||||||
|
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/aarch64-linux/lib/stubs
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-android)
|
||||||
|
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/armv7-linux-androideabi/lib/stubs
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-android)
|
||||||
|
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/aarch64-linux-androideabi/lib/stubs
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-qnx)
|
||||||
|
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/ARMv7-linux-QNX/lib/stubs
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-qnx)
|
||||||
|
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/aarch64-qnx/lib/stubs
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_ARCH),ppc64le)
|
||||||
|
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/ppc64le-linux/lib/stubs
|
||||||
|
endif
|
||||||
|
|
||||||
|
CUDALIB ?= $(shell find -L $(CUDA_SEARCH_PATH) -maxdepth 1 -name libcuda.so 2> /dev/null)
|
||||||
|
ifeq ("$(CUDALIB)","")
|
||||||
|
$(info >>> WARNING - libcuda.so not found, CUDA Driver is not installed. Please re-install the driver. <<<)
|
||||||
|
SAMPLE_ENABLED := 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
LIBRARIES += -lcuda
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(SAMPLE_ENABLED),0)
|
||||||
|
EXEC ?= @echo "[@]"
|
||||||
|
endif
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Target rules
|
||||||
|
all: build
|
||||||
|
|
||||||
|
build: matrixMulDrv $(PTX_FILE)
|
||||||
|
|
||||||
|
check.deps:
|
||||||
|
ifeq ($(SAMPLE_ENABLED),0)
|
||||||
|
@echo "Sample will be waived due to the above missing dependencies"
|
||||||
|
else
|
||||||
|
@echo "Sample is ready - all dependencies have been met"
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(PTX_FILE): matrixMul_kernel.cu
|
||||||
|
$(EXEC) $(NVCC) $(INCLUDES) $(ALL_CCFLAGS) $(GENCODE_FLAGS) -o $@ -ptx $<
|
||||||
|
$(EXEC) mkdir -p data
|
||||||
|
$(EXEC) cp -f $@ ./data
|
||||||
|
$(EXEC) mkdir -p ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
||||||
|
$(EXEC) cp -f $@ ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
||||||
|
|
||||||
|
matrixMulDrv.o:matrixMulDrv.cpp
|
||||||
|
$(EXEC) $(NVCC) $(INCLUDES) $(ALL_CCFLAGS) $(GENCODE_FLAGS) -o $@ -c $<
|
||||||
|
|
||||||
|
matrixMulDrv: matrixMulDrv.o
|
||||||
|
$(EXEC) $(NVCC) $(ALL_LDFLAGS) $(GENCODE_FLAGS) -o $@ $+ $(LIBRARIES)
|
||||||
|
$(EXEC) mkdir -p ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
||||||
|
$(EXEC) cp $@ ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
||||||
|
|
||||||
|
run: build
|
||||||
|
$(EXEC) ./matrixMulDrv
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f matrixMulDrv matrixMulDrv.o data/$(PTX_FILE) $(PTX_FILE)
|
||||||
|
rm -rf ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)/matrixMulDrv
|
||||||
|
rm -rf ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)/$(PTX_FILE)
|
||||||
|
|
||||||
|
clobber: clean
|
94
Samples/matrixMulDrv/README.md
Normal file
94
Samples/matrixMulDrv/README.md
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
# matrixMulDrv - Matrix Multiplication (CUDA Driver API Version)
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
This sample implements matrix multiplication and uses the new CUDA 4.0 kernel launch Driver API. It has been written for clarity of exposition to illustrate various CUDA programming principles, not with the goal of providing the most performant generic kernel for matrix multiplication. CUBLAS provides high-performance matrix multiplication.
|
||||||
|
|
||||||
|
## Key Concepts
|
||||||
|
|
||||||
|
CUDA Driver API, Matrix Multiply
|
||||||
|
|
||||||
|
## Supported SM Architectures
|
||||||
|
|
||||||
|
[SM 3.0 ](https://developer.nvidia.com/cuda-gpus) [SM 3.5 ](https://developer.nvidia.com/cuda-gpus) [SM 3.7 ](https://developer.nvidia.com/cuda-gpus) [SM 5.0 ](https://developer.nvidia.com/cuda-gpus) [SM 5.2 ](https://developer.nvidia.com/cuda-gpus) [SM 6.0 ](https://developer.nvidia.com/cuda-gpus) [SM 6.1 ](https://developer.nvidia.com/cuda-gpus) [SM 7.0 ](https://developer.nvidia.com/cuda-gpus)
|
||||||
|
|
||||||
|
## Supported OSes
|
||||||
|
|
||||||
|
Linux, Windows, MacOSX
|
||||||
|
|
||||||
|
## Supported CPU Architecture
|
||||||
|
|
||||||
|
x86_64, ppc64le, armv7l, aarch64
|
||||||
|
|
||||||
|
## CUDA APIs involved
|
||||||
|
|
||||||
|
### [CUDA Driver API](http://docs.nvidia.com/cuda/cuda-driver-api/index.html)
|
||||||
|
cuModuleLoad, cuModuleLoadDataEx, cuModuleGetFunction, cuMemAlloc, cuMemFree, cuMemcpyHtoD, cuMemcpyDtoH, cuLaunchKernel
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
Download and install the [CUDA Toolkit 9.2](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
|
||||||
|
|
||||||
|
## Build and Run
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
The Windows samples are built using the Visual Studio IDE. Solution files (.sln) are provided for each supported version of Visual Studio, using the format:
|
||||||
|
```
|
||||||
|
*_vs<version>.sln - for Visual Studio <version>
|
||||||
|
```
|
||||||
|
Each individual sample has its own set of solution files in its directory:
|
||||||
|
|
||||||
|
To build/examine all the samples at once, the complete solution files should be used. To build/examine a single sample, the individual sample solution files should be used.
|
||||||
|
> **Note:** Some samples require that the Microsoft DirectX SDK (June 2010 or newer) be installed and that the VC++ directory paths are properly set up (**Tools > Options...**). Check DirectX Dependencies section for details."
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
The Linux samples are built using makefiles. To use the makefiles, change the current directory to the sample directory you wish to build, and run make:
|
||||||
|
```
|
||||||
|
$ cd <sample_dir>
|
||||||
|
$ make
|
||||||
|
```
|
||||||
|
The samples makefiles can take advantage of certain options:
|
||||||
|
* **TARGET_ARCH=<arch>** - cross-compile targeting a specific architecture. Allowed architectures are x86_64, ppc64le, armv7l, aarch64.
|
||||||
|
By default, TARGET_ARCH is set to HOST_ARCH. On a x86_64 machine, not setting TARGET_ARCH is the equivalent of setting TARGET_ARCH=x86_64.<br/>
|
||||||
|
`$ make TARGET_ARCH=x86_64` <br/> `$ make TARGET_ARCH=ppc64le` <br/> `$ make TARGET_ARCH=armv7l` <br/> `$ make TARGET_ARCH=aarch64` <br/>
|
||||||
|
See [here](http://docs.nvidia.com/cuda/cuda-samples/index.html#cross-samples) for more details.
|
||||||
|
* **dbg=1** - build with debug symbols
|
||||||
|
```
|
||||||
|
$ make dbg=1
|
||||||
|
```
|
||||||
|
* **SMS="A B ..."** - override the SM architectures for which the sample will be built, where `"A B ..."` is a space-delimited list of SM architectures. For example, to generate SASS for SM 50 and SM 60, use `SMS="50 60"`.
|
||||||
|
```
|
||||||
|
$ make SMS="50 60"
|
||||||
|
```
|
||||||
|
|
||||||
|
* **HOST_COMPILER=<host_compiler>** - override the default g++ host compiler. See the [Linux Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements) for a list of supported host compilers.
|
||||||
|
```
|
||||||
|
$ make HOST_COMPILER=g++
|
||||||
|
```
|
||||||
|
|
||||||
|
### Mac
|
||||||
|
The Mac samples are built using makefiles. To use the makefiles, change directory into the sample directory you wish to build, and run make:
|
||||||
|
```
|
||||||
|
$ cd <sample_dir>
|
||||||
|
$ make
|
||||||
|
```
|
||||||
|
|
||||||
|
The samples makefiles can take advantage of certain options:
|
||||||
|
|
||||||
|
* **dbg=1** - build with debug symbols
|
||||||
|
```
|
||||||
|
$ make dbg=1
|
||||||
|
```
|
||||||
|
|
||||||
|
* **SMS="A B ..."** - override the SM architectures for which the sample will be built, where "A B ..." is a space-delimited list of SM architectures. For example, to generate SASS for SM 50 and SM 60, use SMS="50 60".
|
||||||
|
```
|
||||||
|
$ make SMS="A B ..."
|
||||||
|
```
|
||||||
|
|
||||||
|
* **HOST_COMPILER=<host_compiler>** - override the default clang host compiler. See the [Mac Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html#system-requirements) for a list of supported host compilers.
|
||||||
|
```
|
||||||
|
$ make HOST_COMPILER=clang
|
||||||
|
```
|
||||||
|
|
||||||
|
## References (for more details)
|
||||||
|
|
40
Samples/matrixMulDrv/matrixMul.h
Normal file
40
Samples/matrixMulDrv/matrixMul.h
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
/* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _MATRIXMUL_H_
|
||||||
|
#define _MATRIXMUL_H_
|
||||||
|
|
||||||
|
// Matrix dimensions
|
||||||
|
// (chosen as multiples of the thread block size for simplicity)
|
||||||
|
#define WA (4 * block_size) // Matrix A width
|
||||||
|
#define HA (6 * block_size) // Matrix A height
|
||||||
|
#define WB (4 * block_size) // Matrix B width
|
||||||
|
#define HB WA // Matrix B height
|
||||||
|
#define WC WB // Matrix C width
|
||||||
|
#define HC HA // Matrix C height
|
||||||
|
|
||||||
|
#endif // _MATRIXMUL_H_
|
436
Samples/matrixMulDrv/matrixMulDrv.cpp
Normal file
436
Samples/matrixMulDrv/matrixMulDrv.cpp
Normal file
|
@ -0,0 +1,436 @@
|
||||||
|
/* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Matrix multiplication: C = A * B.
|
||||||
|
* Host code.
|
||||||
|
*
|
||||||
|
* This sample implements matrix multiplication using the CUDA driver API.
|
||||||
|
* It has been written for clarity of exposition to illustrate various CUDA
|
||||||
|
* programming principles, not with the goal of providing the most
|
||||||
|
* performant generic kernel for matrix multiplication.
|
||||||
|
*
|
||||||
|
* CUBLAS provides high-performance matrix multiplication.
|
||||||
|
* See also:
|
||||||
|
* V. Volkov and J. Demmel, "Benchmarking GPUs to tune dense linear algebra,"
|
||||||
|
* in Proc. 2008 ACM/IEEE Conf. on Supercomputing (SC '08),
|
||||||
|
* Piscataway, NJ: IEEE Press, 2008, pp. Art. 31:1-11.
|
||||||
|
*
|
||||||
|
* Volkov, V. 2010. Better performance at lower occupancy,
|
||||||
|
* GPU Technology Conference 2~010 (GTC 2010).
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
// includes, system
|
||||||
|
#include <builtin_types.h>
|
||||||
|
#include <cuda.h>
|
||||||
|
#include <drvapi_error_string.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
// includes, project
|
||||||
|
#include <helper_cuda_drvapi.h>
|
||||||
|
#include <helper_image.h>
|
||||||
|
#include <helper_string.h>
|
||||||
|
#include <helper_timer.h>
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include "matrixMul.h"
|
||||||
|
|
||||||
|
// includes, CUDA
|
||||||
|
const bool use_64bit_memory_address = false;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// declaration, forward
|
||||||
|
void runTest(int argc, char **argv);
|
||||||
|
void randomInit(float *, int);
|
||||||
|
|
||||||
|
extern "C" void computeGold(float *, const float *, const float *, unsigned int,
|
||||||
|
unsigned int, unsigned int);
|
||||||
|
|
||||||
|
static CUresult initCUDA(int argc, char **argv, CUfunction *pMatrixMul);
|
||||||
|
|
||||||
|
// define input ptx file for different platforms
|
||||||
|
#if defined(_WIN64) || defined(__LP64__)
|
||||||
|
#define PTX_FILE "matrixMul_kernel64.ptx"
|
||||||
|
#define CUBIN_FILE "matrixMul_kernel64.cubin"
|
||||||
|
#else
|
||||||
|
#define PTX_FILE "matrixMul_kernel32.ptx"
|
||||||
|
#define CUBIN_FILE "matrixMul_kernel32.cubin"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Globals
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CUdevice cuDevice;
|
||||||
|
CUcontext cuContext;
|
||||||
|
CUmodule cuModule;
|
||||||
|
size_t totalGlobalMem;
|
||||||
|
|
||||||
|
const char *sSDKsample = "matrixMulDrv (Driver API)";
|
||||||
|
|
||||||
|
void constantInit(float *data, int size, float val) {
|
||||||
|
for (int i = 0; i < size; ++i) {
|
||||||
|
data[i] = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Program main
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
printf("[ %s ]\n", sSDKsample);
|
||||||
|
|
||||||
|
runTest(argc, argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Run a simple test for CUDA
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void runTest(int argc, char **argv) {
|
||||||
|
// initialize CUDA
|
||||||
|
CUfunction matrixMul = NULL;
|
||||||
|
int block_size = 32;
|
||||||
|
|
||||||
|
CUresult error_id = initCUDA(argc, argv, &matrixMul);
|
||||||
|
|
||||||
|
if (error_id != CUDA_SUCCESS) {
|
||||||
|
printf("initCUDA() returned %d\n-> %s\n", error_id,
|
||||||
|
getCudaDrvErrorString(error_id));
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set seed for rand()
|
||||||
|
srand(2006);
|
||||||
|
|
||||||
|
// allocate host memory for matrices A and B
|
||||||
|
unsigned int size_A = WA * HA;
|
||||||
|
unsigned int mem_size_A = sizeof(float) * size_A;
|
||||||
|
float *h_A = reinterpret_cast<float *>(malloc(mem_size_A));
|
||||||
|
unsigned int size_B = WB * HB;
|
||||||
|
unsigned int mem_size_B = sizeof(float) * size_B;
|
||||||
|
float *h_B = reinterpret_cast<float *>(malloc(mem_size_B));
|
||||||
|
|
||||||
|
// initialize host memory
|
||||||
|
const float valB = 0.01f;
|
||||||
|
constantInit(h_A, size_A, 1.0f);
|
||||||
|
constantInit(h_B, size_B, valB);
|
||||||
|
|
||||||
|
// First reserve about 4GB of memory, so we ensure that all memory allocated
|
||||||
|
// afterwards is > 4GB
|
||||||
|
CUdeviceptr d_Mem[4];
|
||||||
|
|
||||||
|
if (use_64bit_memory_address) {
|
||||||
|
unsigned int mem_size = 1024 * 1024 * 1024;
|
||||||
|
checkCudaErrors(cuMemAlloc(&d_Mem[0], mem_size));
|
||||||
|
checkCudaErrors(cuMemAlloc(&d_Mem[1], mem_size));
|
||||||
|
checkCudaErrors(cuMemAlloc(&d_Mem[2], mem_size));
|
||||||
|
checkCudaErrors(cuMemAlloc(&d_Mem[3], mem_size));
|
||||||
|
}
|
||||||
|
|
||||||
|
// allocate device memory
|
||||||
|
CUdeviceptr d_A;
|
||||||
|
checkCudaErrors(cuMemAlloc(&d_A, mem_size_A));
|
||||||
|
CUdeviceptr d_B;
|
||||||
|
checkCudaErrors(cuMemAlloc(&d_B, mem_size_B));
|
||||||
|
|
||||||
|
// copy host memory to device
|
||||||
|
checkCudaErrors(cuMemcpyHtoD(d_A, h_A, mem_size_A));
|
||||||
|
checkCudaErrors(cuMemcpyHtoD(d_B, h_B, mem_size_B));
|
||||||
|
|
||||||
|
// allocate device memory for result
|
||||||
|
size_t size_C = WC * HC;
|
||||||
|
size_t mem_size_C = sizeof(float) * size_C;
|
||||||
|
|
||||||
|
CUdeviceptr d_C;
|
||||||
|
checkCudaErrors(cuMemAlloc(&d_C, mem_size_C));
|
||||||
|
|
||||||
|
// allocate mem for the result on host side
|
||||||
|
float *h_C = reinterpret_cast<float *>(malloc(mem_size_C));
|
||||||
|
|
||||||
|
// create and start timer
|
||||||
|
StopWatchInterface *timer = NULL;
|
||||||
|
sdkCreateTimer(&timer);
|
||||||
|
|
||||||
|
// start the timer
|
||||||
|
sdkStartTimer(&timer);
|
||||||
|
|
||||||
|
// There are two ways to launch CUDA kernels via the Driver API.
|
||||||
|
// In this CUDA Sample, we illustrate both ways to pass parameters
|
||||||
|
// and specify parameters. By default we use the simpler method.
|
||||||
|
dim3 block(block_size, block_size, 1);
|
||||||
|
dim3 grid(WC / block_size, HC / block_size, 1);
|
||||||
|
|
||||||
|
if (1) {
|
||||||
|
// This is the new CUDA 4.0 API for Kernel Parameter passing and Kernel
|
||||||
|
// Launching (simplier method)
|
||||||
|
if (use_64bit_memory_address &&
|
||||||
|
(totalGlobalMem > (uint64_t)4 * 1024 * 1024 * 1024L)) {
|
||||||
|
size_t Matrix_Width_A = (size_t)WA;
|
||||||
|
size_t Matrix_Width_B = (size_t)WB;
|
||||||
|
void *args[5] = {&d_C, &d_A, &d_B, &Matrix_Width_A, &Matrix_Width_B};
|
||||||
|
// new CUDA 4.0 Driver API Kernel launch call
|
||||||
|
checkCudaErrors(cuLaunchKernel(
|
||||||
|
matrixMul, grid.x, grid.y, grid.z, block.x, block.y, block.z,
|
||||||
|
2 * block_size * block_size * sizeof(float), NULL, args, NULL));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
int Matrix_Width_A = WA;
|
||||||
|
int Matrix_Width_B = WB;
|
||||||
|
void *args[5] = {&d_C, &d_A, &d_B, &Matrix_Width_A, &Matrix_Width_B};
|
||||||
|
// new CUDA 4.0 Driver API Kernel launch call
|
||||||
|
checkCudaErrors(cuLaunchKernel(
|
||||||
|
matrixMul, grid.x, grid.y, grid.z, block.x, block.y, block.z,
|
||||||
|
2 * block_size * block_size * sizeof(float), NULL, args, NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// This is the new CUDA 4.0 API for Kernel Parameter passing and Kernel
|
||||||
|
// Launching (advanced method)
|
||||||
|
int offset = 0;
|
||||||
|
char argBuffer[256];
|
||||||
|
|
||||||
|
// pass in launch parameters (not actually de-referencing CUdeviceptr).
|
||||||
|
// CUdeviceptr is storing the value of the parameters
|
||||||
|
*(reinterpret_cast<CUdeviceptr *>(&argBuffer[offset])) = d_C;
|
||||||
|
offset += sizeof(d_C);
|
||||||
|
*(reinterpret_cast<CUdeviceptr *>(&argBuffer[offset])) = d_A;
|
||||||
|
offset += sizeof(d_A);
|
||||||
|
*(reinterpret_cast<CUdeviceptr *>(&argBuffer[offset])) = d_B;
|
||||||
|
offset += sizeof(d_B);
|
||||||
|
|
||||||
|
if (use_64bit_memory_address &&
|
||||||
|
(totalGlobalMem > (uint64_t)4 * 1024 * 1024 * 1024L)) {
|
||||||
|
size_t Matrix_Width_A = (size_t)WA;
|
||||||
|
size_t Matrix_Width_B = (size_t)WB;
|
||||||
|
|
||||||
|
*(reinterpret_cast<CUdeviceptr *>(&argBuffer[offset])) = Matrix_Width_A;
|
||||||
|
offset += sizeof(Matrix_Width_A);
|
||||||
|
*(reinterpret_cast<CUdeviceptr *>(&argBuffer[offset])) = Matrix_Width_B;
|
||||||
|
offset += sizeof(Matrix_Width_B);
|
||||||
|
} else {
|
||||||
|
int Matrix_Width_A = WA;
|
||||||
|
int Matrix_Width_B = WB;
|
||||||
|
|
||||||
|
*(reinterpret_cast<int *>(&argBuffer[offset])) = Matrix_Width_A;
|
||||||
|
offset += sizeof(Matrix_Width_A);
|
||||||
|
*(reinterpret_cast<int *>(&argBuffer[offset])) = Matrix_Width_B;
|
||||||
|
offset += sizeof(Matrix_Width_B);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *kernel_launch_config[5] = {CU_LAUNCH_PARAM_BUFFER_POINTER, argBuffer,
|
||||||
|
CU_LAUNCH_PARAM_BUFFER_SIZE, &offset,
|
||||||
|
CU_LAUNCH_PARAM_END};
|
||||||
|
|
||||||
|
// new CUDA 4.0 Driver API Kernel launch call
|
||||||
|
checkCudaErrors(cuLaunchKernel(
|
||||||
|
matrixMul, grid.x, grid.y, grid.z, block.x, block.y, block.z,
|
||||||
|
2 * block_size * block_size * sizeof(float), NULL, NULL,
|
||||||
|
reinterpret_cast<void **>(&kernel_launch_config)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy result from device to host
|
||||||
|
checkCudaErrors(cuMemcpyDtoH(reinterpret_cast<void *>(h_C), d_C, mem_size_C));
|
||||||
|
|
||||||
|
// stop and destroy timer
|
||||||
|
sdkStopTimer(&timer);
|
||||||
|
printf("Processing time: %f (ms)\n", sdkGetTimerValue(&timer));
|
||||||
|
sdkDeleteTimer(&timer);
|
||||||
|
|
||||||
|
printf("Checking computed result for correctness: ");
|
||||||
|
bool correct = true;
|
||||||
|
|
||||||
|
for (int i = 0; i < static_cast<int>(WC * HC); i++) {
|
||||||
|
if (fabs(h_C[i] - (WA * valB)) > 1e-5) {
|
||||||
|
printf("Error! Matrix[%05d]=%.8f, ref=%.8f error term is > 1e-5\n", i,
|
||||||
|
h_C[i], WA * valB);
|
||||||
|
correct = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%s\n", correct ? "Result = PASS" : "Result = FAIL");
|
||||||
|
|
||||||
|
printf(
|
||||||
|
"\nNOTE: The CUDA Samples are not meant for performance measurements. "
|
||||||
|
"Results may vary when GPU Boost is enabled.\n");
|
||||||
|
|
||||||
|
// clean up memory
|
||||||
|
if (use_64bit_memory_address) {
|
||||||
|
cuMemFree(d_Mem[0]);
|
||||||
|
cuMemFree(d_Mem[1]);
|
||||||
|
cuMemFree(d_Mem[2]);
|
||||||
|
cuMemFree(d_Mem[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(h_A);
|
||||||
|
free(h_B);
|
||||||
|
free(h_C);
|
||||||
|
checkCudaErrors(cuMemFree(d_A));
|
||||||
|
checkCudaErrors(cuMemFree(d_B));
|
||||||
|
checkCudaErrors(cuMemFree(d_C));
|
||||||
|
checkCudaErrors(cuCtxDestroy(cuContext));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allocates a matrix with random float entries.
|
||||||
|
void randomInit(float *data, int size) {
|
||||||
|
for (int i = 0; i < size; ++i) {
|
||||||
|
data[i] = rand() / static_cast<float>(RAND_MAX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool inline findModulePath(const char *module_file, std::string &module_path,
|
||||||
|
char **argv, std::string &ptx_source) {
|
||||||
|
char *actual_path = sdkFindFilePath(module_file, argv[0]);
|
||||||
|
|
||||||
|
if (actual_path) {
|
||||||
|
module_path = actual_path;
|
||||||
|
} else {
|
||||||
|
printf("> findModulePath file not found: <%s> \n", module_file);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (module_path.empty()) {
|
||||||
|
printf("> findModulePath file not found: <%s> \n", module_file);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
printf("> findModulePath <%s>\n", module_path.c_str());
|
||||||
|
|
||||||
|
if (module_path.rfind(".ptx") != std::string::npos) {
|
||||||
|
FILE *fp = fopen(module_path.c_str(), "rb");
|
||||||
|
fseek(fp, 0, SEEK_END);
|
||||||
|
int file_size = ftell(fp);
|
||||||
|
char *buf = new char[file_size + 1];
|
||||||
|
fseek(fp, 0, SEEK_SET);
|
||||||
|
fread(buf, sizeof(char), file_size, fp);
|
||||||
|
fclose(fp);
|
||||||
|
buf[file_size] = '\0';
|
||||||
|
ptx_source = buf;
|
||||||
|
delete[] buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static CUresult initCUDA(int argc, char **argv, CUfunction *pMatrixMul) {
|
||||||
|
CUfunction cuFunction = 0;
|
||||||
|
CUresult status;
|
||||||
|
int major = 0, minor = 0;
|
||||||
|
char deviceName[100];
|
||||||
|
std::string module_path, ptx_source;
|
||||||
|
|
||||||
|
cuDevice = findCudaDeviceDRV(argc, (const char **)argv);
|
||||||
|
|
||||||
|
// get compute capabilities and the devicename
|
||||||
|
checkCudaErrors(cuDeviceGetAttribute(
|
||||||
|
&major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, cuDevice));
|
||||||
|
checkCudaErrors(cuDeviceGetAttribute(
|
||||||
|
&minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, cuDevice));
|
||||||
|
checkCudaErrors(cuDeviceGetName(deviceName, 256, cuDevice));
|
||||||
|
printf("> GPU Device has SM %d.%d compute capability\n", major, minor);
|
||||||
|
|
||||||
|
checkCudaErrors(cuDeviceTotalMem(&totalGlobalMem, cuDevice));
|
||||||
|
printf(" Total amount of global memory: %llu bytes\n",
|
||||||
|
(long long unsigned int)totalGlobalMem);
|
||||||
|
printf(" 64-bit Memory Address: %s\n",
|
||||||
|
(totalGlobalMem > (uint64_t)4 * 1024 * 1024 * 1024L) ? "YES" : "NO");
|
||||||
|
|
||||||
|
status = cuCtxCreate(&cuContext, 0, cuDevice);
|
||||||
|
|
||||||
|
if (CUDA_SUCCESS != status) {
|
||||||
|
goto Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
// first search for the module path before we load the results
|
||||||
|
if (!findModulePath(PTX_FILE, module_path, argv, ptx_source)) {
|
||||||
|
if (!findModulePath(CUBIN_FILE, module_path, argv, ptx_source)) {
|
||||||
|
printf(
|
||||||
|
"> findModulePath could not find <matrixMul_kernel> ptx or cubin\n");
|
||||||
|
status = CUDA_ERROR_NOT_FOUND;
|
||||||
|
goto Error;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
printf("> initCUDA loading module: <%s>\n", module_path.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (module_path.rfind("ptx") != std::string::npos) {
|
||||||
|
// in this branch we use compilation with parameters
|
||||||
|
const unsigned int jitNumOptions = 3;
|
||||||
|
CUjit_option *jitOptions = new CUjit_option[jitNumOptions];
|
||||||
|
void **jitOptVals = new void *[jitNumOptions];
|
||||||
|
|
||||||
|
// set up size of compilation log buffer
|
||||||
|
jitOptions[0] = CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES;
|
||||||
|
int jitLogBufferSize = 1024;
|
||||||
|
jitOptVals[0] = reinterpret_cast<void *>(jitLogBufferSize);
|
||||||
|
|
||||||
|
// set up pointer to the compilation log buffer
|
||||||
|
jitOptions[1] = CU_JIT_INFO_LOG_BUFFER;
|
||||||
|
char *jitLogBuffer = new char[jitLogBufferSize];
|
||||||
|
jitOptVals[1] = jitLogBuffer;
|
||||||
|
|
||||||
|
// set up pointer to set the Maximum # of registers for a particular kernel
|
||||||
|
jitOptions[2] = CU_JIT_MAX_REGISTERS;
|
||||||
|
int jitRegCount = 32;
|
||||||
|
jitOptVals[2] = reinterpret_cast<void *>(jitRegCount);
|
||||||
|
|
||||||
|
status =
|
||||||
|
cuModuleLoadDataEx(&cuModule, ptx_source.c_str(), jitNumOptions,
|
||||||
|
jitOptions, reinterpret_cast<void **>(jitOptVals));
|
||||||
|
|
||||||
|
printf("> PTX JIT log:\n%s\n", jitLogBuffer);
|
||||||
|
} else {
|
||||||
|
status = cuModuleLoad(&cuModule, module_path.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CUDA_SUCCESS != status) {
|
||||||
|
goto Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if USE_64BIT_MEMORY_ADDRESS
|
||||||
|
|
||||||
|
if (totalGlobalMem > (uint64_t)4 * 1024 * 1024 * 1024L) {
|
||||||
|
status = cuModuleGetFunction(&cuFunction, cuModule, "matrixMul_bs32_64bit");
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
status = cuModuleGetFunction(&cuFunction, cuModule, "matrixMul_bs32_32bit");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CUDA_SUCCESS != status) {
|
||||||
|
goto Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pMatrixMul = cuFunction;
|
||||||
|
|
||||||
|
return CUDA_SUCCESS;
|
||||||
|
Error:
|
||||||
|
cuCtxDestroy(cuContext);
|
||||||
|
return status;
|
||||||
|
}
|
20
Samples/matrixMulDrv/matrixMulDrv_vs2010.sln
Normal file
20
Samples/matrixMulDrv/matrixMulDrv_vs2010.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||||
|
# Visual Studio 2010
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "matrixMulDrv", "matrixMulDrv_vs2010.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
110
Samples/matrixMulDrv/matrixMulDrv_vs2010.vcxproj
Normal file
110
Samples/matrixMulDrv/matrixMulDrv_vs2010.vcxproj
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>matrixMulDrv_vs2010</RootNamespace>
|
||||||
|
<ProjectName>matrixMulDrv</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>cuda.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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/matrixMulDrv.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,compute_30;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="matrixMulDrv.cpp" />
|
||||||
|
<CudaCompile Include="matrixMul_kernel.cu">
|
||||||
|
<CompileOut Condition="'$(Platform)'=='x64'">data/%(Filename)64.ptx</CompileOut>
|
||||||
|
<NvccCompilation>ptx</NvccCompilation>
|
||||||
|
</CudaCompile>
|
||||||
|
<ClInclude Include="matrixMul.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/matrixMulDrv/matrixMulDrv_vs2012.sln
Normal file
20
Samples/matrixMulDrv/matrixMulDrv_vs2012.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2012
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "matrixMulDrv", "matrixMulDrv_vs2012.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
111
Samples/matrixMulDrv/matrixMulDrv_vs2012.vcxproj
Normal file
111
Samples/matrixMulDrv/matrixMulDrv_vs2012.vcxproj
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>matrixMulDrv_vs2012</RootNamespace>
|
||||||
|
<ProjectName>matrixMulDrv</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>cuda.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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/matrixMulDrv.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,compute_30;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="matrixMulDrv.cpp" />
|
||||||
|
<CudaCompile Include="matrixMul_kernel.cu">
|
||||||
|
<CompileOut Condition="'$(Platform)'=='x64'">data/%(Filename)64.ptx</CompileOut>
|
||||||
|
<NvccCompilation>ptx</NvccCompilation>
|
||||||
|
</CudaCompile>
|
||||||
|
<ClInclude Include="matrixMul.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/matrixMulDrv/matrixMulDrv_vs2013.sln
Normal file
20
Samples/matrixMulDrv/matrixMulDrv_vs2013.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 13.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "matrixMulDrv", "matrixMulDrv_vs2013.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
111
Samples/matrixMulDrv/matrixMulDrv_vs2013.vcxproj
Normal file
111
Samples/matrixMulDrv/matrixMulDrv_vs2013.vcxproj
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>matrixMulDrv_vs2013</RootNamespace>
|
||||||
|
<ProjectName>matrixMulDrv</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>cuda.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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/matrixMulDrv.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,compute_30;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="matrixMulDrv.cpp" />
|
||||||
|
<CudaCompile Include="matrixMul_kernel.cu">
|
||||||
|
<CompileOut Condition="'$(Platform)'=='x64'">data/%(Filename)64.ptx</CompileOut>
|
||||||
|
<NvccCompilation>ptx</NvccCompilation>
|
||||||
|
</CudaCompile>
|
||||||
|
<ClInclude Include="matrixMul.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/matrixMulDrv/matrixMulDrv_vs2015.sln
Normal file
20
Samples/matrixMulDrv/matrixMulDrv_vs2015.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 14.00
|
||||||
|
# Visual Studio 2015
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "matrixMulDrv", "matrixMulDrv_vs2015.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
111
Samples/matrixMulDrv/matrixMulDrv_vs2015.vcxproj
Normal file
111
Samples/matrixMulDrv/matrixMulDrv_vs2015.vcxproj
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>matrixMulDrv_vs2015</RootNamespace>
|
||||||
|
<ProjectName>matrixMulDrv</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>cuda.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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/matrixMulDrv.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,compute_30;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="matrixMulDrv.cpp" />
|
||||||
|
<CudaCompile Include="matrixMul_kernel.cu">
|
||||||
|
<CompileOut Condition="'$(Platform)'=='x64'">data/%(Filename)64.ptx</CompileOut>
|
||||||
|
<NvccCompilation>ptx</NvccCompilation>
|
||||||
|
</CudaCompile>
|
||||||
|
<ClInclude Include="matrixMul.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/matrixMulDrv/matrixMulDrv_vs2017.sln
Normal file
20
Samples/matrixMulDrv/matrixMulDrv_vs2017.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2017
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "matrixMulDrv", "matrixMulDrv_vs2017.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
112
Samples/matrixMulDrv/matrixMulDrv_vs2017.vcxproj
Normal file
112
Samples/matrixMulDrv/matrixMulDrv_vs2017.vcxproj
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>matrixMulDrv_vs2017</RootNamespace>
|
||||||
|
<ProjectName>matrixMulDrv</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>cuda.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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/matrixMulDrv.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,compute_30;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="matrixMulDrv.cpp" />
|
||||||
|
<CudaCompile Include="matrixMul_kernel.cu">
|
||||||
|
<CompileOut Condition="'$(Platform)'=='x64'">data/%(Filename)64.ptx</CompileOut>
|
||||||
|
<NvccCompilation>ptx</NvccCompilation>
|
||||||
|
</CudaCompile>
|
||||||
|
<ClInclude Include="matrixMul.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
139
Samples/matrixMulDrv/matrixMul_kernel.cu
Normal file
139
Samples/matrixMulDrv/matrixMul_kernel.cu
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
/* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Matrix multiplication: C = A * B.
|
||||||
|
* Device code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _MATRIXMUL_KERNEL_H_
|
||||||
|
#define _MATRIXMUL_KERNEL_H_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define CHECK_BANK_CONFLICTS 0
|
||||||
|
#if CHECK_BANK_CONFLICTS
|
||||||
|
#define AS(i, j) \
|
||||||
|
cutilBankChecker((reinterpret_cast<float *>(&As[0][0])), (block_size * i + j))
|
||||||
|
#define BS(i, j) \
|
||||||
|
cutilBankChecker((reinterpret_cast<float *>(&Bs[0][0])), (block_size * i + j))
|
||||||
|
#else
|
||||||
|
#define AS(i, j) As[i][j]
|
||||||
|
#define BS(i, j) Bs[i][j]
|
||||||
|
#endif
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Matrix multiplication on the device: C = A * B
|
||||||
|
//! wA is A's width and wB is B's width
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <int block_size, typename size_type>
|
||||||
|
__device__ void matrixMul(float *C, float *A, float *B, size_type wA,
|
||||||
|
size_type wB) {
|
||||||
|
// Block index
|
||||||
|
size_type bx = blockIdx.x;
|
||||||
|
size_type by = blockIdx.y;
|
||||||
|
|
||||||
|
// Thread index
|
||||||
|
size_type tx = threadIdx.x;
|
||||||
|
size_type ty = threadIdx.y;
|
||||||
|
|
||||||
|
// Index of the first sub-matrix of A processed by the block
|
||||||
|
size_type aBegin = wA * block_size * by;
|
||||||
|
|
||||||
|
// Index of the last sub-matrix of A processed by the block
|
||||||
|
size_type aEnd = aBegin + wA - 1;
|
||||||
|
|
||||||
|
// Step size used to iterate through the sub-matrices of A
|
||||||
|
size_type aStep = block_size;
|
||||||
|
|
||||||
|
// Index of the first sub-matrix of B processed by the block
|
||||||
|
size_type bBegin = block_size * bx;
|
||||||
|
|
||||||
|
// Step size used to iterate through the sub-matrices of B
|
||||||
|
size_type bStep = block_size * wB;
|
||||||
|
|
||||||
|
// Csub is used to store the element of the block sub-matrix
|
||||||
|
// that is computed by the thread
|
||||||
|
float Csub = 0;
|
||||||
|
|
||||||
|
// Loop over all the sub-matrices of A and B
|
||||||
|
// required to compute the block sub-matrix
|
||||||
|
for (size_type a = aBegin, b = bBegin; a <= aEnd; a += aStep, b += bStep) {
|
||||||
|
// Declaration of the shared memory array As used to
|
||||||
|
// store the sub-matrix of A
|
||||||
|
__shared__ float As[block_size][block_size];
|
||||||
|
|
||||||
|
// Declaration of the shared memory array Bs used to
|
||||||
|
// store the sub-matrix of B
|
||||||
|
__shared__ float Bs[block_size][block_size];
|
||||||
|
|
||||||
|
// Load the matrices from device memory
|
||||||
|
// to shared memory; each thread loads
|
||||||
|
// one element of each matrix
|
||||||
|
AS(ty, tx) = A[a + wA * ty + tx];
|
||||||
|
BS(ty, tx) = B[b + wB * ty + tx];
|
||||||
|
|
||||||
|
// Synchronize to make sure the matrices are loaded
|
||||||
|
__syncthreads();
|
||||||
|
|
||||||
|
// Multiply the two matrices together;
|
||||||
|
// each thread computes one element
|
||||||
|
// of the block sub-matrix
|
||||||
|
#pragma unroll
|
||||||
|
|
||||||
|
for (size_type k = 0; k < block_size; ++k) Csub += AS(ty, k) * BS(k, tx);
|
||||||
|
|
||||||
|
// Synchronize to make sure that the preceding
|
||||||
|
// computation is done before loading two new
|
||||||
|
// sub-matrices of A and B in the next iteration
|
||||||
|
__syncthreads();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write the block sub-matrix to device memory;
|
||||||
|
// each thread writes one element
|
||||||
|
size_type c = wB * block_size * by + block_size * bx;
|
||||||
|
C[c + wB * ty + tx] = Csub;
|
||||||
|
}
|
||||||
|
|
||||||
|
// C wrappers around our template kernel
|
||||||
|
extern "C" __global__ void matrixMul_bs16_32bit(float *C, float *A, float *B,
|
||||||
|
int wA, int wB) {
|
||||||
|
matrixMul<16, int>(C, A, B, wA, wB);
|
||||||
|
}
|
||||||
|
extern "C" __global__ void matrixMul_bs16_64bit(float *C, float *A, float *B,
|
||||||
|
size_t wA, size_t wB) {
|
||||||
|
matrixMul<16, size_t>(C, A, B, wA, wB);
|
||||||
|
}
|
||||||
|
extern "C" __global__ void matrixMul_bs32_32bit(float *C, float *A, float *B,
|
||||||
|
int wA, int wB) {
|
||||||
|
matrixMul<32, int>(C, A, B, wA, wB);
|
||||||
|
}
|
||||||
|
extern "C" __global__ void matrixMul_bs32_64bit(float *C, float *A, float *B,
|
||||||
|
size_t wA, size_t wB) {
|
||||||
|
matrixMul<32, size_t>(C, A, B, wA, wB);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // #ifndef _MATRIXMUL_KERNEL_H_
|
276
Samples/simpleCUBLAS/Makefile
Normal file
276
Samples/simpleCUBLAS/Makefile
Normal file
|
@ -0,0 +1,276 @@
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Copyright 1993-2015 NVIDIA Corporation. All rights reserved.
|
||||||
|
#
|
||||||
|
# NOTICE TO USER:
|
||||||
|
#
|
||||||
|
# This source code is subject to NVIDIA ownership rights under U.S. and
|
||||||
|
# international Copyright laws.
|
||||||
|
#
|
||||||
|
# NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
|
||||||
|
# CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
|
||||||
|
# IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
# REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
# MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
# IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
||||||
|
# OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||||
|
# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||||
|
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|
||||||
|
# OR PERFORMANCE OF THIS SOURCE CODE.
|
||||||
|
#
|
||||||
|
# U.S. Government End Users. This source code is a "commercial item" as
|
||||||
|
# that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
|
||||||
|
# "commercial computer software" and "commercial computer software
|
||||||
|
# documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
|
||||||
|
# and is provided to the U.S. Government only as a commercial end item.
|
||||||
|
# Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
|
||||||
|
# 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
|
||||||
|
# source code with only those rights set forth herein.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Makefile project only supported on Mac OS X and Linux Platforms)
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Location of the CUDA Toolkit
|
||||||
|
CUDA_PATH ?= /usr/local/cuda
|
||||||
|
|
||||||
|
##############################
|
||||||
|
# start deprecated interface #
|
||||||
|
##############################
|
||||||
|
ifeq ($(x86_64),1)
|
||||||
|
$(info WARNING - x86_64 variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=x86_64 instead)
|
||||||
|
TARGET_ARCH ?= x86_64
|
||||||
|
endif
|
||||||
|
ifeq ($(ARMv7),1)
|
||||||
|
$(info WARNING - ARMv7 variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=armv7l instead)
|
||||||
|
TARGET_ARCH ?= armv7l
|
||||||
|
endif
|
||||||
|
ifeq ($(aarch64),1)
|
||||||
|
$(info WARNING - aarch64 variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=aarch64 instead)
|
||||||
|
TARGET_ARCH ?= aarch64
|
||||||
|
endif
|
||||||
|
ifeq ($(ppc64le),1)
|
||||||
|
$(info WARNING - ppc64le variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=ppc64le instead)
|
||||||
|
TARGET_ARCH ?= ppc64le
|
||||||
|
endif
|
||||||
|
ifneq ($(GCC),)
|
||||||
|
$(info WARNING - GCC variable has been deprecated)
|
||||||
|
$(info WARNING - please use HOST_COMPILER=$(GCC) instead)
|
||||||
|
HOST_COMPILER ?= $(GCC)
|
||||||
|
endif
|
||||||
|
ifneq ($(abi),)
|
||||||
|
$(error ERROR - abi variable has been removed)
|
||||||
|
endif
|
||||||
|
############################
|
||||||
|
# end deprecated interface #
|
||||||
|
############################
|
||||||
|
|
||||||
|
# architecture
|
||||||
|
HOST_ARCH := $(shell uname -m)
|
||||||
|
TARGET_ARCH ?= $(HOST_ARCH)
|
||||||
|
ifneq (,$(filter $(TARGET_ARCH),x86_64 aarch64 ppc64le armv7l))
|
||||||
|
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifneq (,$(filter $(TARGET_ARCH),x86_64 aarch64 ppc64le))
|
||||||
|
TARGET_SIZE := 64
|
||||||
|
else ifneq (,$(filter $(TARGET_ARCH),armv7l))
|
||||||
|
TARGET_SIZE := 32
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
TARGET_SIZE := $(shell getconf LONG_BIT)
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
$(error ERROR - unsupported value $(TARGET_ARCH) for TARGET_ARCH!)
|
||||||
|
endif
|
||||||
|
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifeq (,$(filter $(HOST_ARCH)-$(TARGET_ARCH),aarch64-armv7l x86_64-armv7l x86_64-aarch64 x86_64-ppc64le))
|
||||||
|
$(error ERROR - cross compiling from $(HOST_ARCH) to $(TARGET_ARCH) is not supported!)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# When on native aarch64 system with userspace of 32-bit, change TARGET_ARCH to armv7l
|
||||||
|
ifeq ($(HOST_ARCH)-$(TARGET_ARCH)-$(TARGET_SIZE),aarch64-aarch64-32)
|
||||||
|
TARGET_ARCH = armv7l
|
||||||
|
endif
|
||||||
|
|
||||||
|
# operating system
|
||||||
|
HOST_OS := $(shell uname -s 2>/dev/null | tr "[:upper:]" "[:lower:]")
|
||||||
|
TARGET_OS ?= $(HOST_OS)
|
||||||
|
ifeq (,$(filter $(TARGET_OS),linux darwin qnx android))
|
||||||
|
$(error ERROR - unsupported value $(TARGET_OS) for TARGET_OS!)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# host compiler
|
||||||
|
ifeq ($(TARGET_OS),darwin)
|
||||||
|
ifeq ($(shell expr `xcodebuild -version | grep -i xcode | awk '{print $$2}' | cut -d'.' -f1` \>= 5),1)
|
||||||
|
HOST_COMPILER ?= clang++
|
||||||
|
endif
|
||||||
|
else ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifeq ($(HOST_ARCH)-$(TARGET_ARCH),x86_64-armv7l)
|
||||||
|
ifeq ($(TARGET_OS),linux)
|
||||||
|
HOST_COMPILER ?= arm-linux-gnueabihf-g++
|
||||||
|
else ifeq ($(TARGET_OS),qnx)
|
||||||
|
ifeq ($(QNX_HOST),)
|
||||||
|
$(error ERROR - QNX_HOST must be passed to the QNX host toolchain)
|
||||||
|
endif
|
||||||
|
ifeq ($(QNX_TARGET),)
|
||||||
|
$(error ERROR - QNX_TARGET must be passed to the QNX target toolchain)
|
||||||
|
endif
|
||||||
|
export QNX_HOST
|
||||||
|
export QNX_TARGET
|
||||||
|
HOST_COMPILER ?= $(QNX_HOST)/usr/bin/arm-unknown-nto-qnx6.6.0eabi-g++
|
||||||
|
else ifeq ($(TARGET_OS),android)
|
||||||
|
HOST_COMPILER ?= arm-linux-androideabi-g++
|
||||||
|
endif
|
||||||
|
else ifeq ($(TARGET_ARCH),aarch64)
|
||||||
|
ifeq ($(TARGET_OS), linux)
|
||||||
|
HOST_COMPILER ?= aarch64-linux-gnu-g++
|
||||||
|
else ifeq ($(TARGET_OS),qnx)
|
||||||
|
ifeq ($(QNX_HOST),)
|
||||||
|
$(error ERROR - QNX_HOST must be passed to the QNX host toolchain)
|
||||||
|
endif
|
||||||
|
ifeq ($(QNX_TARGET),)
|
||||||
|
$(error ERROR - QNX_TARGET must be passed to the QNX target toolchain)
|
||||||
|
endif
|
||||||
|
export QNX_HOST
|
||||||
|
export QNX_TARGET
|
||||||
|
HOST_COMPILER ?= $(QNX_HOST)/usr/bin/aarch64-unknown-nto-qnx7.0.0-g++
|
||||||
|
else ifeq ($(TARGET_OS), android)
|
||||||
|
HOST_COMPILER ?= aarch64-linux-android-g++
|
||||||
|
endif
|
||||||
|
else ifeq ($(TARGET_ARCH),ppc64le)
|
||||||
|
HOST_COMPILER ?= powerpc64le-linux-gnu-g++
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
HOST_COMPILER ?= g++
|
||||||
|
NVCC := $(CUDA_PATH)/bin/nvcc -ccbin $(HOST_COMPILER)
|
||||||
|
|
||||||
|
# internal flags
|
||||||
|
NVCCFLAGS := -m${TARGET_SIZE}
|
||||||
|
CCFLAGS :=
|
||||||
|
LDFLAGS :=
|
||||||
|
|
||||||
|
# build flags
|
||||||
|
ifeq ($(TARGET_OS),darwin)
|
||||||
|
LDFLAGS += -rpath $(CUDA_PATH)/lib
|
||||||
|
CCFLAGS += -arch $(HOST_ARCH)
|
||||||
|
else ifeq ($(HOST_ARCH)-$(TARGET_ARCH)-$(TARGET_OS),x86_64-armv7l-linux)
|
||||||
|
LDFLAGS += --dynamic-linker=/lib/ld-linux-armhf.so.3
|
||||||
|
CCFLAGS += -mfloat-abi=hard
|
||||||
|
else ifeq ($(TARGET_OS),android)
|
||||||
|
LDFLAGS += -pie
|
||||||
|
CCFLAGS += -fpie -fpic -fexceptions
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
||||||
|
ifneq ($(TARGET_FS),)
|
||||||
|
GCCVERSIONLTEQ46 := $(shell expr `$(HOST_COMPILER) -dumpversion` \<= 4.6)
|
||||||
|
ifeq ($(GCCVERSIONLTEQ46),1)
|
||||||
|
CCFLAGS += --sysroot=$(TARGET_FS)
|
||||||
|
endif
|
||||||
|
LDFLAGS += --sysroot=$(TARGET_FS)
|
||||||
|
LDFLAGS += -rpath-link=$(TARGET_FS)/lib
|
||||||
|
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib
|
||||||
|
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib/arm-linux-gnueabihf
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_OS),qnx)
|
||||||
|
CCFLAGS += -DWIN_INTERFACE_CUSTOM
|
||||||
|
LDFLAGS += -lsocket
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Install directory of different arch
|
||||||
|
CUDA_INSTALL_TARGET_DIR :=
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/armv7-linux-gnueabihf/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-linux)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/aarch64-linux/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-android)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/armv7-linux-androideabi/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-android)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/aarch64-linux-androideabi/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-qnx)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/ARMv7-linux-QNX/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-qnx)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/aarch64-qnx/
|
||||||
|
else ifeq ($(TARGET_ARCH),ppc64le)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/ppc64le-linux/
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Debug build flags
|
||||||
|
ifeq ($(dbg),1)
|
||||||
|
NVCCFLAGS += -g -G
|
||||||
|
BUILD_TYPE := debug
|
||||||
|
else
|
||||||
|
BUILD_TYPE := release
|
||||||
|
endif
|
||||||
|
|
||||||
|
ALL_CCFLAGS :=
|
||||||
|
ALL_CCFLAGS += $(NVCCFLAGS)
|
||||||
|
ALL_CCFLAGS += $(EXTRA_NVCCFLAGS)
|
||||||
|
ALL_CCFLAGS += $(addprefix -Xcompiler ,$(CCFLAGS))
|
||||||
|
ALL_CCFLAGS += $(addprefix -Xcompiler ,$(EXTRA_CCFLAGS))
|
||||||
|
|
||||||
|
ALL_LDFLAGS :=
|
||||||
|
ALL_LDFLAGS += $(ALL_CCFLAGS)
|
||||||
|
ALL_LDFLAGS += $(addprefix -Xlinker ,$(LDFLAGS))
|
||||||
|
ALL_LDFLAGS += $(addprefix -Xlinker ,$(EXTRA_LDFLAGS))
|
||||||
|
|
||||||
|
# Common includes and paths for CUDA
|
||||||
|
INCLUDES := -I../../Common
|
||||||
|
LIBRARIES :=
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Gencode arguments
|
||||||
|
SMS ?=
|
||||||
|
|
||||||
|
ifeq ($(GENCODE_FLAGS),)
|
||||||
|
# Generate SASS code for each SM architecture listed in $(SMS)
|
||||||
|
$(foreach sm,$(SMS),$(eval GENCODE_FLAGS += -gencode arch=compute_$(sm),code=sm_$(sm)))
|
||||||
|
|
||||||
|
ifeq ($(SMS),)
|
||||||
|
# Generate PTX code from SM 30
|
||||||
|
GENCODE_FLAGS += -gencode arch=compute_30,code=compute_30
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Generate PTX code from the highest SM architecture in $(SMS) to guarantee forward-compatibility
|
||||||
|
HIGHEST_SM := $(lastword $(sort $(SMS)))
|
||||||
|
ifneq ($(HIGHEST_SM),)
|
||||||
|
GENCODE_FLAGS += -gencode arch=compute_$(HIGHEST_SM),code=compute_$(HIGHEST_SM)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
LIBRARIES += -lcublas
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Target rules
|
||||||
|
all: build
|
||||||
|
|
||||||
|
build: simpleCUBLAS
|
||||||
|
|
||||||
|
simpleCUBLAS.o:simpleCUBLAS.cpp
|
||||||
|
$(NVCC) $(INCLUDES) $(ALL_CCFLAGS) $(GENCODE_FLAGS) -o $@ -c $<
|
||||||
|
|
||||||
|
simpleCUBLAS: simpleCUBLAS.o
|
||||||
|
$(NVCC) $(ALL_LDFLAGS) $(GENCODE_FLAGS) -o $@ $+ $(LIBRARIES)
|
||||||
|
mkdir -p ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
||||||
|
cp $@ ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
||||||
|
|
||||||
|
run: build
|
||||||
|
./simpleCUBLAS
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f simpleCUBLAS simpleCUBLAS.o
|
||||||
|
rm -rf ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)/simpleCUBLAS
|
||||||
|
|
||||||
|
clobber: clean
|
71
Samples/simpleCUBLAS/NsightEclipse.xml
Normal file
71
Samples/simpleCUBLAS/NsightEclipse.xml
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE entry SYSTEM "SamplesInfo.dtd">
|
||||||
|
<entry>
|
||||||
|
<name>simpleCUBLAS</name>
|
||||||
|
<description><![CDATA[Example of using CUBLAS using the new CUBLAS API interface available in CUDA 4.0.]]></description>
|
||||||
|
<devicecompilation>whole</devicecompilation>
|
||||||
|
<fallback_min_ptx>true</fallback_min_ptx>
|
||||||
|
<includepaths>
|
||||||
|
<path>./</path>
|
||||||
|
<path>../</path>
|
||||||
|
<path>../../common/inc</path>
|
||||||
|
</includepaths>
|
||||||
|
<keyconcepts>
|
||||||
|
<concept level="basic">Image Processing</concept>
|
||||||
|
<concept level="basic">CUBLAS Library</concept>
|
||||||
|
</keyconcepts>
|
||||||
|
<keywords>
|
||||||
|
<keyword>CUDA</keyword>
|
||||||
|
<keyword>CUBLAS</keyword>
|
||||||
|
<keyword>Linear Algebra</keyword>
|
||||||
|
</keywords>
|
||||||
|
<libraries>
|
||||||
|
<library>cublas</library>
|
||||||
|
</libraries>
|
||||||
|
<librarypaths>
|
||||||
|
</librarypaths>
|
||||||
|
<nsight_eclipse>true</nsight_eclipse>
|
||||||
|
<primary_file>simpleCUBLAS.cpp</primary_file>
|
||||||
|
<required_dependencies>
|
||||||
|
<dependency>CUBLAS</dependency>
|
||||||
|
</required_dependencies>
|
||||||
|
<scopes>
|
||||||
|
<scope>1:CUDA Basic Topics</scope>
|
||||||
|
<scope>3:Linear Algebra</scope>
|
||||||
|
</scopes>
|
||||||
|
<sm-arch>sm30</sm-arch>
|
||||||
|
<sm-arch>sm35</sm-arch>
|
||||||
|
<sm-arch>sm37</sm-arch>
|
||||||
|
<sm-arch>sm50</sm-arch>
|
||||||
|
<sm-arch>sm52</sm-arch>
|
||||||
|
<sm-arch>sm60</sm-arch>
|
||||||
|
<sm-arch>sm61</sm-arch>
|
||||||
|
<sm-arch>sm70</sm-arch>
|
||||||
|
<supported_envs>
|
||||||
|
<env>
|
||||||
|
<arch>x86_64</arch>
|
||||||
|
<platform>linux</platform>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<platform>windows7</platform>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<arch>x86_64</arch>
|
||||||
|
<platform>macosx</platform>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<arch>arm</arch>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<arch>aarch64</arch>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<arch>ppc64le</arch>
|
||||||
|
<platform>linux</platform>
|
||||||
|
</env>
|
||||||
|
</supported_envs>
|
||||||
|
<supported_sm_architectures>
|
||||||
|
<include>all</include>
|
||||||
|
</supported_sm_architectures>
|
||||||
|
<title>Simple CUBLAS</title>
|
||||||
|
</entry>
|
95
Samples/simpleCUBLAS/README.md
Normal file
95
Samples/simpleCUBLAS/README.md
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
# simpleCUBLAS - Simple CUBLAS
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
Example of using CUBLAS using the new CUBLAS API interface available in CUDA 4.0.
|
||||||
|
|
||||||
|
## Key Concepts
|
||||||
|
|
||||||
|
Image Processing, CUBLAS Library
|
||||||
|
|
||||||
|
## Supported SM Architectures
|
||||||
|
|
||||||
|
[SM 3.0 ](https://developer.nvidia.com/cuda-gpus) [SM 3.5 ](https://developer.nvidia.com/cuda-gpus) [SM 3.7 ](https://developer.nvidia.com/cuda-gpus) [SM 5.0 ](https://developer.nvidia.com/cuda-gpus) [SM 5.2 ](https://developer.nvidia.com/cuda-gpus) [SM 6.0 ](https://developer.nvidia.com/cuda-gpus) [SM 6.1 ](https://developer.nvidia.com/cuda-gpus) [SM 7.0 ](https://developer.nvidia.com/cuda-gpus)
|
||||||
|
|
||||||
|
## Supported OSes
|
||||||
|
|
||||||
|
Linux, Windows, MacOSX
|
||||||
|
|
||||||
|
## Supported CPU Architecture
|
||||||
|
|
||||||
|
x86_64, ppc64le, armv7l, aarch64
|
||||||
|
|
||||||
|
## CUDA APIs involved
|
||||||
|
|
||||||
|
## Dependencies needed to build/run
|
||||||
|
[CUBLAS](../../README.md#cublas)
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
Download and install the [CUDA Toolkit 9.2](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
|
||||||
|
Make sure the dependencies mentioned in [Dependencies]() section above are installed.
|
||||||
|
|
||||||
|
## Build and Run
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
The Windows samples are built using the Visual Studio IDE. Solution files (.sln) are provided for each supported version of Visual Studio, using the format:
|
||||||
|
```
|
||||||
|
*_vs<version>.sln - for Visual Studio <version>
|
||||||
|
```
|
||||||
|
Each individual sample has its own set of solution files in its directory:
|
||||||
|
|
||||||
|
To build/examine all the samples at once, the complete solution files should be used. To build/examine a single sample, the individual sample solution files should be used.
|
||||||
|
> **Note:** Some samples require that the Microsoft DirectX SDK (June 2010 or newer) be installed and that the VC++ directory paths are properly set up (**Tools > Options...**). Check DirectX Dependencies section for details."
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
The Linux samples are built using makefiles. To use the makefiles, change the current directory to the sample directory you wish to build, and run make:
|
||||||
|
```
|
||||||
|
$ cd <sample_dir>
|
||||||
|
$ make
|
||||||
|
```
|
||||||
|
The samples makefiles can take advantage of certain options:
|
||||||
|
* **TARGET_ARCH=<arch>** - cross-compile targeting a specific architecture. Allowed architectures are x86_64, ppc64le, armv7l, aarch64.
|
||||||
|
By default, TARGET_ARCH is set to HOST_ARCH. On a x86_64 machine, not setting TARGET_ARCH is the equivalent of setting TARGET_ARCH=x86_64.<br/>
|
||||||
|
`$ make TARGET_ARCH=x86_64` <br/> `$ make TARGET_ARCH=ppc64le` <br/> `$ make TARGET_ARCH=armv7l` <br/> `$ make TARGET_ARCH=aarch64` <br/>
|
||||||
|
See [here](http://docs.nvidia.com/cuda/cuda-samples/index.html#cross-samples) for more details.
|
||||||
|
* **dbg=1** - build with debug symbols
|
||||||
|
```
|
||||||
|
$ make dbg=1
|
||||||
|
```
|
||||||
|
* **SMS="A B ..."** - override the SM architectures for which the sample will be built, where `"A B ..."` is a space-delimited list of SM architectures. For example, to generate SASS for SM 50 and SM 60, use `SMS="50 60"`.
|
||||||
|
```
|
||||||
|
$ make SMS="50 60"
|
||||||
|
```
|
||||||
|
|
||||||
|
* **HOST_COMPILER=<host_compiler>** - override the default g++ host compiler. See the [Linux Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements) for a list of supported host compilers.
|
||||||
|
```
|
||||||
|
$ make HOST_COMPILER=g++
|
||||||
|
```
|
||||||
|
|
||||||
|
### Mac
|
||||||
|
The Mac samples are built using makefiles. To use the makefiles, change directory into the sample directory you wish to build, and run make:
|
||||||
|
```
|
||||||
|
$ cd <sample_dir>
|
||||||
|
$ make
|
||||||
|
```
|
||||||
|
|
||||||
|
The samples makefiles can take advantage of certain options:
|
||||||
|
|
||||||
|
* **dbg=1** - build with debug symbols
|
||||||
|
```
|
||||||
|
$ make dbg=1
|
||||||
|
```
|
||||||
|
|
||||||
|
* **SMS="A B ..."** - override the SM architectures for which the sample will be built, where "A B ..." is a space-delimited list of SM architectures. For example, to generate SASS for SM 50 and SM 60, use SMS="50 60".
|
||||||
|
```
|
||||||
|
$ make SMS="A B ..."
|
||||||
|
```
|
||||||
|
|
||||||
|
* **HOST_COMPILER=<host_compiler>** - override the default clang host compiler. See the [Mac Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html#system-requirements) for a list of supported host compilers.
|
||||||
|
```
|
||||||
|
$ make HOST_COMPILER=clang
|
||||||
|
```
|
||||||
|
|
||||||
|
## References (for more details)
|
||||||
|
|
255
Samples/simpleCUBLAS/simpleCUBLAS.cpp
Normal file
255
Samples/simpleCUBLAS/simpleCUBLAS.cpp
Normal file
|
@ -0,0 +1,255 @@
|
||||||
|
/* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This example demonstrates how to use the CUBLAS library
|
||||||
|
* by scaling an array of floating-point values on the device
|
||||||
|
* and comparing the result to the same operation performed
|
||||||
|
* on the host.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Includes, system */
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/* Includes, cuda */
|
||||||
|
#include <cublas_v2.h>
|
||||||
|
#include <cuda_runtime.h>
|
||||||
|
#include <helper_cuda.h>
|
||||||
|
|
||||||
|
/* Matrix size */
|
||||||
|
#define N (275)
|
||||||
|
|
||||||
|
/* Host implementation of a simple version of sgemm */
|
||||||
|
static void simple_sgemm(int n, float alpha, const float *A, const float *B,
|
||||||
|
float beta, float *C) {
|
||||||
|
int i;
|
||||||
|
int j;
|
||||||
|
int k;
|
||||||
|
|
||||||
|
for (i = 0; i < n; ++i) {
|
||||||
|
for (j = 0; j < n; ++j) {
|
||||||
|
float prod = 0;
|
||||||
|
|
||||||
|
for (k = 0; k < n; ++k) {
|
||||||
|
prod += A[k * n + i] * B[j * n + k];
|
||||||
|
}
|
||||||
|
|
||||||
|
C[j * n + i] = alpha * prod + beta * C[j * n + i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Main */
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
cublasStatus_t status;
|
||||||
|
float *h_A;
|
||||||
|
float *h_B;
|
||||||
|
float *h_C;
|
||||||
|
float *h_C_ref;
|
||||||
|
float *d_A = 0;
|
||||||
|
float *d_B = 0;
|
||||||
|
float *d_C = 0;
|
||||||
|
float alpha = 1.0f;
|
||||||
|
float beta = 0.0f;
|
||||||
|
int n2 = N * N;
|
||||||
|
int i;
|
||||||
|
float error_norm;
|
||||||
|
float ref_norm;
|
||||||
|
float diff;
|
||||||
|
cublasHandle_t handle;
|
||||||
|
|
||||||
|
int dev = findCudaDevice(argc, (const char **)argv);
|
||||||
|
|
||||||
|
if (dev == -1) {
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize CUBLAS */
|
||||||
|
printf("simpleCUBLAS test running..\n");
|
||||||
|
|
||||||
|
status = cublasCreate(&handle);
|
||||||
|
|
||||||
|
if (status != CUBLAS_STATUS_SUCCESS) {
|
||||||
|
fprintf(stderr, "!!!! CUBLAS initialization error\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocate host memory for the matrices */
|
||||||
|
h_A = reinterpret_cast<float *>(malloc(n2 * sizeof(h_A[0])));
|
||||||
|
|
||||||
|
if (h_A == 0) {
|
||||||
|
fprintf(stderr, "!!!! host memory allocation error (A)\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
h_B = reinterpret_cast<float *>(malloc(n2 * sizeof(h_B[0])));
|
||||||
|
|
||||||
|
if (h_B == 0) {
|
||||||
|
fprintf(stderr, "!!!! host memory allocation error (B)\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
h_C = reinterpret_cast<float *>(malloc(n2 * sizeof(h_C[0])));
|
||||||
|
|
||||||
|
if (h_C == 0) {
|
||||||
|
fprintf(stderr, "!!!! host memory allocation error (C)\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fill the matrices with test data */
|
||||||
|
for (i = 0; i < n2; i++) {
|
||||||
|
h_A[i] = rand() / static_cast<float>(RAND_MAX);
|
||||||
|
h_B[i] = rand() / static_cast<float>(RAND_MAX);
|
||||||
|
h_C[i] = rand() / static_cast<float>(RAND_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocate device memory for the matrices */
|
||||||
|
if (cudaMalloc(reinterpret_cast<void **>(&d_A), n2 * sizeof(d_A[0])) !=
|
||||||
|
cudaSuccess) {
|
||||||
|
fprintf(stderr, "!!!! device memory allocation error (allocate A)\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cudaMalloc(reinterpret_cast<void **>(&d_B), n2 * sizeof(d_B[0])) !=
|
||||||
|
cudaSuccess) {
|
||||||
|
fprintf(stderr, "!!!! device memory allocation error (allocate B)\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cudaMalloc(reinterpret_cast<void **>(&d_C), n2 * sizeof(d_C[0])) !=
|
||||||
|
cudaSuccess) {
|
||||||
|
fprintf(stderr, "!!!! device memory allocation error (allocate C)\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize the device matrices with the host matrices */
|
||||||
|
status = cublasSetVector(n2, sizeof(h_A[0]), h_A, 1, d_A, 1);
|
||||||
|
|
||||||
|
if (status != CUBLAS_STATUS_SUCCESS) {
|
||||||
|
fprintf(stderr, "!!!! device access error (write A)\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = cublasSetVector(n2, sizeof(h_B[0]), h_B, 1, d_B, 1);
|
||||||
|
|
||||||
|
if (status != CUBLAS_STATUS_SUCCESS) {
|
||||||
|
fprintf(stderr, "!!!! device access error (write B)\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = cublasSetVector(n2, sizeof(h_C[0]), h_C, 1, d_C, 1);
|
||||||
|
|
||||||
|
if (status != CUBLAS_STATUS_SUCCESS) {
|
||||||
|
fprintf(stderr, "!!!! device access error (write C)\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Performs operation using plain C code */
|
||||||
|
simple_sgemm(N, alpha, h_A, h_B, beta, h_C);
|
||||||
|
h_C_ref = h_C;
|
||||||
|
|
||||||
|
/* Performs operation using cublas */
|
||||||
|
status = cublasSgemm(handle, CUBLAS_OP_N, CUBLAS_OP_N, N, N, N, &alpha, d_A,
|
||||||
|
N, d_B, N, &beta, d_C, N);
|
||||||
|
|
||||||
|
if (status != CUBLAS_STATUS_SUCCESS) {
|
||||||
|
fprintf(stderr, "!!!! kernel execution error.\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocate host memory for reading back the result from device memory */
|
||||||
|
h_C = reinterpret_cast<float *>(malloc(n2 * sizeof(h_C[0])));
|
||||||
|
|
||||||
|
if (h_C == 0) {
|
||||||
|
fprintf(stderr, "!!!! host memory allocation error (C)\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read the result back */
|
||||||
|
status = cublasGetVector(n2, sizeof(h_C[0]), d_C, 1, h_C, 1);
|
||||||
|
|
||||||
|
if (status != CUBLAS_STATUS_SUCCESS) {
|
||||||
|
fprintf(stderr, "!!!! device access error (read C)\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check result against reference */
|
||||||
|
error_norm = 0;
|
||||||
|
ref_norm = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < n2; ++i) {
|
||||||
|
diff = h_C_ref[i] - h_C[i];
|
||||||
|
error_norm += diff * diff;
|
||||||
|
ref_norm += h_C_ref[i] * h_C_ref[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
error_norm = static_cast<float>(sqrt(static_cast<double>(error_norm)));
|
||||||
|
ref_norm = static_cast<float>(sqrt(static_cast<double>(ref_norm)));
|
||||||
|
|
||||||
|
if (fabs(ref_norm) < 1e-7) {
|
||||||
|
fprintf(stderr, "!!!! reference norm is 0\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Memory clean up */
|
||||||
|
free(h_A);
|
||||||
|
free(h_B);
|
||||||
|
free(h_C);
|
||||||
|
free(h_C_ref);
|
||||||
|
|
||||||
|
if (cudaFree(d_A) != cudaSuccess) {
|
||||||
|
fprintf(stderr, "!!!! memory free error (A)\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cudaFree(d_B) != cudaSuccess) {
|
||||||
|
fprintf(stderr, "!!!! memory free error (B)\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cudaFree(d_C) != cudaSuccess) {
|
||||||
|
fprintf(stderr, "!!!! memory free error (C)\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Shutdown */
|
||||||
|
status = cublasDestroy(handle);
|
||||||
|
|
||||||
|
if (status != CUBLAS_STATUS_SUCCESS) {
|
||||||
|
fprintf(stderr, "!!!! shutdown error (A)\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error_norm / ref_norm < 1e-6f) {
|
||||||
|
printf("simpleCUBLAS test passed.\n");
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
} else {
|
||||||
|
printf("simpleCUBLAS test failed.\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
20
Samples/simpleCUBLAS/simpleCUBLAS_vs2010.sln
Normal file
20
Samples/simpleCUBLAS/simpleCUBLAS_vs2010.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||||
|
# Visual Studio 2010
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simpleCUBLAS", "simpleCUBLAS_vs2010.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
106
Samples/simpleCUBLAS/simpleCUBLAS_vs2010.vcxproj
Normal file
106
Samples/simpleCUBLAS/simpleCUBLAS_vs2010.vcxproj
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>simpleCUBLAS_vs2010</RootNamespace>
|
||||||
|
<ProjectName>simpleCUBLAS</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;$(CudaToolkitIncludeDir);</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>cublas.lib;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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/simpleCUBLAS.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,compute_30;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="simpleCUBLAS.cpp" />
|
||||||
|
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/simpleCUBLAS/simpleCUBLAS_vs2012.sln
Normal file
20
Samples/simpleCUBLAS/simpleCUBLAS_vs2012.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2012
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simpleCUBLAS", "simpleCUBLAS_vs2012.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
107
Samples/simpleCUBLAS/simpleCUBLAS_vs2012.vcxproj
Normal file
107
Samples/simpleCUBLAS/simpleCUBLAS_vs2012.vcxproj
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>simpleCUBLAS_vs2012</RootNamespace>
|
||||||
|
<ProjectName>simpleCUBLAS</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;$(CudaToolkitIncludeDir);</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>cublas.lib;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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/simpleCUBLAS.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,compute_30;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="simpleCUBLAS.cpp" />
|
||||||
|
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/simpleCUBLAS/simpleCUBLAS_vs2013.sln
Normal file
20
Samples/simpleCUBLAS/simpleCUBLAS_vs2013.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 13.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simpleCUBLAS", "simpleCUBLAS_vs2013.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
107
Samples/simpleCUBLAS/simpleCUBLAS_vs2013.vcxproj
Normal file
107
Samples/simpleCUBLAS/simpleCUBLAS_vs2013.vcxproj
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>simpleCUBLAS_vs2013</RootNamespace>
|
||||||
|
<ProjectName>simpleCUBLAS</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;$(CudaToolkitIncludeDir);</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>cublas.lib;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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/simpleCUBLAS.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,compute_30;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="simpleCUBLAS.cpp" />
|
||||||
|
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/simpleCUBLAS/simpleCUBLAS_vs2015.sln
Normal file
20
Samples/simpleCUBLAS/simpleCUBLAS_vs2015.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 14.00
|
||||||
|
# Visual Studio 2015
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simpleCUBLAS", "simpleCUBLAS_vs2015.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
107
Samples/simpleCUBLAS/simpleCUBLAS_vs2015.vcxproj
Normal file
107
Samples/simpleCUBLAS/simpleCUBLAS_vs2015.vcxproj
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>simpleCUBLAS_vs2015</RootNamespace>
|
||||||
|
<ProjectName>simpleCUBLAS</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;$(CudaToolkitIncludeDir);</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>cublas.lib;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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/simpleCUBLAS.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,compute_30;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="simpleCUBLAS.cpp" />
|
||||||
|
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/simpleCUBLAS/simpleCUBLAS_vs2017.sln
Normal file
20
Samples/simpleCUBLAS/simpleCUBLAS_vs2017.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2017
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simpleCUBLAS", "simpleCUBLAS_vs2017.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
108
Samples/simpleCUBLAS/simpleCUBLAS_vs2017.vcxproj
Normal file
108
Samples/simpleCUBLAS/simpleCUBLAS_vs2017.vcxproj
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>simpleCUBLAS_vs2017</RootNamespace>
|
||||||
|
<ProjectName>simpleCUBLAS</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;$(CudaToolkitIncludeDir);</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>cublas.lib;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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/simpleCUBLAS.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,compute_30;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="simpleCUBLAS.cpp" />
|
||||||
|
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
289
Samples/simpleCUFFT/Makefile
Normal file
289
Samples/simpleCUFFT/Makefile
Normal file
|
@ -0,0 +1,289 @@
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Copyright 1993-2015 NVIDIA Corporation. All rights reserved.
|
||||||
|
#
|
||||||
|
# NOTICE TO USER:
|
||||||
|
#
|
||||||
|
# This source code is subject to NVIDIA ownership rights under U.S. and
|
||||||
|
# international Copyright laws.
|
||||||
|
#
|
||||||
|
# NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
|
||||||
|
# CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
|
||||||
|
# IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
# REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
# MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
# IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
||||||
|
# OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||||
|
# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||||
|
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|
||||||
|
# OR PERFORMANCE OF THIS SOURCE CODE.
|
||||||
|
#
|
||||||
|
# U.S. Government End Users. This source code is a "commercial item" as
|
||||||
|
# that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
|
||||||
|
# "commercial computer software" and "commercial computer software
|
||||||
|
# documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
|
||||||
|
# and is provided to the U.S. Government only as a commercial end item.
|
||||||
|
# Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
|
||||||
|
# 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
|
||||||
|
# source code with only those rights set forth herein.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Makefile project only supported on Mac OS X and Linux Platforms)
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Location of the CUDA Toolkit
|
||||||
|
CUDA_PATH ?= /usr/local/cuda
|
||||||
|
|
||||||
|
##############################
|
||||||
|
# start deprecated interface #
|
||||||
|
##############################
|
||||||
|
ifeq ($(x86_64),1)
|
||||||
|
$(info WARNING - x86_64 variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=x86_64 instead)
|
||||||
|
TARGET_ARCH ?= x86_64
|
||||||
|
endif
|
||||||
|
ifeq ($(ARMv7),1)
|
||||||
|
$(info WARNING - ARMv7 variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=armv7l instead)
|
||||||
|
TARGET_ARCH ?= armv7l
|
||||||
|
endif
|
||||||
|
ifeq ($(aarch64),1)
|
||||||
|
$(info WARNING - aarch64 variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=aarch64 instead)
|
||||||
|
TARGET_ARCH ?= aarch64
|
||||||
|
endif
|
||||||
|
ifeq ($(ppc64le),1)
|
||||||
|
$(info WARNING - ppc64le variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=ppc64le instead)
|
||||||
|
TARGET_ARCH ?= ppc64le
|
||||||
|
endif
|
||||||
|
ifneq ($(GCC),)
|
||||||
|
$(info WARNING - GCC variable has been deprecated)
|
||||||
|
$(info WARNING - please use HOST_COMPILER=$(GCC) instead)
|
||||||
|
HOST_COMPILER ?= $(GCC)
|
||||||
|
endif
|
||||||
|
ifneq ($(abi),)
|
||||||
|
$(error ERROR - abi variable has been removed)
|
||||||
|
endif
|
||||||
|
############################
|
||||||
|
# end deprecated interface #
|
||||||
|
############################
|
||||||
|
|
||||||
|
# architecture
|
||||||
|
HOST_ARCH := $(shell uname -m)
|
||||||
|
TARGET_ARCH ?= $(HOST_ARCH)
|
||||||
|
ifneq (,$(filter $(TARGET_ARCH),x86_64 aarch64 ppc64le armv7l))
|
||||||
|
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifneq (,$(filter $(TARGET_ARCH),x86_64 aarch64 ppc64le))
|
||||||
|
TARGET_SIZE := 64
|
||||||
|
else ifneq (,$(filter $(TARGET_ARCH),armv7l))
|
||||||
|
TARGET_SIZE := 32
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
TARGET_SIZE := $(shell getconf LONG_BIT)
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
$(error ERROR - unsupported value $(TARGET_ARCH) for TARGET_ARCH!)
|
||||||
|
endif
|
||||||
|
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifeq (,$(filter $(HOST_ARCH)-$(TARGET_ARCH),aarch64-armv7l x86_64-armv7l x86_64-aarch64 x86_64-ppc64le))
|
||||||
|
$(error ERROR - cross compiling from $(HOST_ARCH) to $(TARGET_ARCH) is not supported!)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# When on native aarch64 system with userspace of 32-bit, change TARGET_ARCH to armv7l
|
||||||
|
ifeq ($(HOST_ARCH)-$(TARGET_ARCH)-$(TARGET_SIZE),aarch64-aarch64-32)
|
||||||
|
TARGET_ARCH = armv7l
|
||||||
|
endif
|
||||||
|
|
||||||
|
# operating system
|
||||||
|
HOST_OS := $(shell uname -s 2>/dev/null | tr "[:upper:]" "[:lower:]")
|
||||||
|
TARGET_OS ?= $(HOST_OS)
|
||||||
|
ifeq (,$(filter $(TARGET_OS),linux darwin qnx android))
|
||||||
|
$(error ERROR - unsupported value $(TARGET_OS) for TARGET_OS!)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# host compiler
|
||||||
|
ifeq ($(TARGET_OS),darwin)
|
||||||
|
ifeq ($(shell expr `xcodebuild -version | grep -i xcode | awk '{print $$2}' | cut -d'.' -f1` \>= 5),1)
|
||||||
|
HOST_COMPILER ?= clang++
|
||||||
|
endif
|
||||||
|
else ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifeq ($(HOST_ARCH)-$(TARGET_ARCH),x86_64-armv7l)
|
||||||
|
ifeq ($(TARGET_OS),linux)
|
||||||
|
HOST_COMPILER ?= arm-linux-gnueabihf-g++
|
||||||
|
else ifeq ($(TARGET_OS),qnx)
|
||||||
|
ifeq ($(QNX_HOST),)
|
||||||
|
$(error ERROR - QNX_HOST must be passed to the QNX host toolchain)
|
||||||
|
endif
|
||||||
|
ifeq ($(QNX_TARGET),)
|
||||||
|
$(error ERROR - QNX_TARGET must be passed to the QNX target toolchain)
|
||||||
|
endif
|
||||||
|
export QNX_HOST
|
||||||
|
export QNX_TARGET
|
||||||
|
HOST_COMPILER ?= $(QNX_HOST)/usr/bin/arm-unknown-nto-qnx6.6.0eabi-g++
|
||||||
|
else ifeq ($(TARGET_OS),android)
|
||||||
|
HOST_COMPILER ?= arm-linux-androideabi-g++
|
||||||
|
endif
|
||||||
|
else ifeq ($(TARGET_ARCH),aarch64)
|
||||||
|
ifeq ($(TARGET_OS), linux)
|
||||||
|
HOST_COMPILER ?= aarch64-linux-gnu-g++
|
||||||
|
else ifeq ($(TARGET_OS),qnx)
|
||||||
|
ifeq ($(QNX_HOST),)
|
||||||
|
$(error ERROR - QNX_HOST must be passed to the QNX host toolchain)
|
||||||
|
endif
|
||||||
|
ifeq ($(QNX_TARGET),)
|
||||||
|
$(error ERROR - QNX_TARGET must be passed to the QNX target toolchain)
|
||||||
|
endif
|
||||||
|
export QNX_HOST
|
||||||
|
export QNX_TARGET
|
||||||
|
HOST_COMPILER ?= $(QNX_HOST)/usr/bin/aarch64-unknown-nto-qnx7.0.0-g++
|
||||||
|
else ifeq ($(TARGET_OS), android)
|
||||||
|
HOST_COMPILER ?= aarch64-linux-android-g++
|
||||||
|
endif
|
||||||
|
else ifeq ($(TARGET_ARCH),ppc64le)
|
||||||
|
HOST_COMPILER ?= powerpc64le-linux-gnu-g++
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
HOST_COMPILER ?= g++
|
||||||
|
NVCC := $(CUDA_PATH)/bin/nvcc -ccbin $(HOST_COMPILER)
|
||||||
|
|
||||||
|
# internal flags
|
||||||
|
NVCCFLAGS := -m${TARGET_SIZE}
|
||||||
|
CCFLAGS :=
|
||||||
|
LDFLAGS :=
|
||||||
|
|
||||||
|
# build flags
|
||||||
|
ifeq ($(TARGET_OS),darwin)
|
||||||
|
LDFLAGS += -rpath $(CUDA_PATH)/lib
|
||||||
|
CCFLAGS += -arch $(HOST_ARCH)
|
||||||
|
else ifeq ($(HOST_ARCH)-$(TARGET_ARCH)-$(TARGET_OS),x86_64-armv7l-linux)
|
||||||
|
LDFLAGS += --dynamic-linker=/lib/ld-linux-armhf.so.3
|
||||||
|
CCFLAGS += -mfloat-abi=hard
|
||||||
|
else ifeq ($(TARGET_OS),android)
|
||||||
|
LDFLAGS += -pie
|
||||||
|
CCFLAGS += -fpie -fpic -fexceptions
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
||||||
|
ifneq ($(TARGET_FS),)
|
||||||
|
GCCVERSIONLTEQ46 := $(shell expr `$(HOST_COMPILER) -dumpversion` \<= 4.6)
|
||||||
|
ifeq ($(GCCVERSIONLTEQ46),1)
|
||||||
|
CCFLAGS += --sysroot=$(TARGET_FS)
|
||||||
|
endif
|
||||||
|
LDFLAGS += --sysroot=$(TARGET_FS)
|
||||||
|
LDFLAGS += -rpath-link=$(TARGET_FS)/lib
|
||||||
|
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib
|
||||||
|
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib/arm-linux-gnueabihf
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_OS),qnx)
|
||||||
|
CCFLAGS += -DWIN_INTERFACE_CUSTOM
|
||||||
|
LDFLAGS += -lsocket
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Install directory of different arch
|
||||||
|
CUDA_INSTALL_TARGET_DIR :=
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/armv7-linux-gnueabihf/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-linux)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/aarch64-linux/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-android)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/armv7-linux-androideabi/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-android)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/aarch64-linux-androideabi/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-qnx)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/ARMv7-linux-QNX/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-qnx)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/aarch64-qnx/
|
||||||
|
else ifeq ($(TARGET_ARCH),ppc64le)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/ppc64le-linux/
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Debug build flags
|
||||||
|
ifeq ($(dbg),1)
|
||||||
|
NVCCFLAGS += -g -G
|
||||||
|
BUILD_TYPE := debug
|
||||||
|
else
|
||||||
|
BUILD_TYPE := release
|
||||||
|
endif
|
||||||
|
|
||||||
|
ALL_CCFLAGS :=
|
||||||
|
ALL_CCFLAGS += $(NVCCFLAGS)
|
||||||
|
ALL_CCFLAGS += $(EXTRA_NVCCFLAGS)
|
||||||
|
ALL_CCFLAGS += $(addprefix -Xcompiler ,$(CCFLAGS))
|
||||||
|
ALL_CCFLAGS += $(addprefix -Xcompiler ,$(EXTRA_CCFLAGS))
|
||||||
|
|
||||||
|
SAMPLE_ENABLED := 1
|
||||||
|
|
||||||
|
ALL_LDFLAGS :=
|
||||||
|
ALL_LDFLAGS += $(ALL_CCFLAGS)
|
||||||
|
ALL_LDFLAGS += $(addprefix -Xlinker ,$(LDFLAGS))
|
||||||
|
ALL_LDFLAGS += $(addprefix -Xlinker ,$(EXTRA_LDFLAGS))
|
||||||
|
|
||||||
|
# Common includes and paths for CUDA
|
||||||
|
INCLUDES := -I../../Common
|
||||||
|
LIBRARIES :=
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Gencode arguments
|
||||||
|
SMS ?= 30 35 37 50 52 60 61 70
|
||||||
|
|
||||||
|
ifeq ($(SMS),)
|
||||||
|
$(info >>> WARNING - no SM architectures have been specified - waiving sample <<<)
|
||||||
|
SAMPLE_ENABLED := 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(GENCODE_FLAGS),)
|
||||||
|
# Generate SASS code for each SM architecture listed in $(SMS)
|
||||||
|
$(foreach sm,$(SMS),$(eval GENCODE_FLAGS += -gencode arch=compute_$(sm),code=sm_$(sm)))
|
||||||
|
|
||||||
|
# Generate PTX code from the highest SM architecture in $(SMS) to guarantee forward-compatibility
|
||||||
|
HIGHEST_SM := $(lastword $(sort $(SMS)))
|
||||||
|
ifneq ($(HIGHEST_SM),)
|
||||||
|
GENCODE_FLAGS += -gencode arch=compute_$(HIGHEST_SM),code=compute_$(HIGHEST_SM)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
LIBRARIES += -lcufft
|
||||||
|
|
||||||
|
ifeq ($(SAMPLE_ENABLED),0)
|
||||||
|
EXEC ?= @echo "[@]"
|
||||||
|
endif
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Target rules
|
||||||
|
all: build
|
||||||
|
|
||||||
|
build: simpleCUFFT
|
||||||
|
|
||||||
|
check.deps:
|
||||||
|
ifeq ($(SAMPLE_ENABLED),0)
|
||||||
|
@echo "Sample will be waived due to the above missing dependencies"
|
||||||
|
else
|
||||||
|
@echo "Sample is ready - all dependencies have been met"
|
||||||
|
endif
|
||||||
|
|
||||||
|
simpleCUFFT.o:simpleCUFFT.cu
|
||||||
|
$(EXEC) $(NVCC) $(INCLUDES) $(ALL_CCFLAGS) $(GENCODE_FLAGS) -o $@ -c $<
|
||||||
|
|
||||||
|
simpleCUFFT: simpleCUFFT.o
|
||||||
|
$(EXEC) $(NVCC) $(ALL_LDFLAGS) $(GENCODE_FLAGS) -o $@ $+ $(LIBRARIES)
|
||||||
|
$(EXEC) mkdir -p ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
||||||
|
$(EXEC) cp $@ ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
||||||
|
|
||||||
|
run: build
|
||||||
|
$(EXEC) ./simpleCUFFT
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f simpleCUFFT simpleCUFFT.o
|
||||||
|
rm -rf ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)/simpleCUFFT
|
||||||
|
|
||||||
|
clobber: clean
|
70
Samples/simpleCUFFT/NsightEclipse.xml
Normal file
70
Samples/simpleCUFFT/NsightEclipse.xml
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE entry SYSTEM "SamplesInfo.dtd">
|
||||||
|
<entry>
|
||||||
|
<name>simpleCUFFT</name>
|
||||||
|
<description><![CDATA[Example of using CUFFT. In this example, CUFFT is used to compute the 1D-convolution of some signal with some filter by transforming both into frequency domain, multiplying them together, and transforming the signal back to time domain. cuFFT plans are created using simple and advanced API functions.]]></description>
|
||||||
|
<devicecompilation>whole</devicecompilation>
|
||||||
|
<includepaths>
|
||||||
|
<path>./</path>
|
||||||
|
<path>../</path>
|
||||||
|
<path>../../common/inc</path>
|
||||||
|
</includepaths>
|
||||||
|
<keyconcepts>
|
||||||
|
<concept level="basic">Image Processing</concept>
|
||||||
|
<concept level="basic">CUFFT Library</concept>
|
||||||
|
</keyconcepts>
|
||||||
|
<keywords>
|
||||||
|
<keyword>CUDA</keyword>
|
||||||
|
<keyword>CUFFT</keyword>
|
||||||
|
</keywords>
|
||||||
|
<libraries>
|
||||||
|
<library>cufft</library>
|
||||||
|
</libraries>
|
||||||
|
<librarypaths>
|
||||||
|
</librarypaths>
|
||||||
|
<nsight_eclipse>true</nsight_eclipse>
|
||||||
|
<primary_file>simpleCUFFT.cu</primary_file>
|
||||||
|
<required_dependencies>
|
||||||
|
<dependency>CUFFT</dependency>
|
||||||
|
</required_dependencies>
|
||||||
|
<scopes>
|
||||||
|
<scope>1:CUDA Basic Topics</scope>
|
||||||
|
<scope>2:Image Processing</scope>
|
||||||
|
</scopes>
|
||||||
|
<sm-arch>sm30</sm-arch>
|
||||||
|
<sm-arch>sm35</sm-arch>
|
||||||
|
<sm-arch>sm37</sm-arch>
|
||||||
|
<sm-arch>sm50</sm-arch>
|
||||||
|
<sm-arch>sm52</sm-arch>
|
||||||
|
<sm-arch>sm60</sm-arch>
|
||||||
|
<sm-arch>sm61</sm-arch>
|
||||||
|
<sm-arch>sm70</sm-arch>
|
||||||
|
<supported_envs>
|
||||||
|
<env>
|
||||||
|
<arch>x86_64</arch>
|
||||||
|
<platform>linux</platform>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<platform>windows7</platform>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<arch>x86_64</arch>
|
||||||
|
<platform>macosx</platform>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<arch>arm</arch>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<arch>aarch64</arch>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<arch>ppc64le</arch>
|
||||||
|
<platform>linux</platform>
|
||||||
|
</env>
|
||||||
|
</supported_envs>
|
||||||
|
<supported_sm_architectures>
|
||||||
|
<include>all</include>
|
||||||
|
</supported_sm_architectures>
|
||||||
|
<title>Simple CUFFT</title>
|
||||||
|
<type>exe</type>
|
||||||
|
</entry>
|
95
Samples/simpleCUFFT/README.md
Normal file
95
Samples/simpleCUFFT/README.md
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
# simpleCUFFT - Simple CUFFT
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
Example of using CUFFT. In this example, CUFFT is used to compute the 1D-convolution of some signal with some filter by transforming both into frequency domain, multiplying them together, and transforming the signal back to time domain. cuFFT plans are created using simple and advanced API functions.
|
||||||
|
|
||||||
|
## Key Concepts
|
||||||
|
|
||||||
|
Image Processing, CUFFT Library
|
||||||
|
|
||||||
|
## Supported SM Architectures
|
||||||
|
|
||||||
|
[SM 3.0 ](https://developer.nvidia.com/cuda-gpus) [SM 3.5 ](https://developer.nvidia.com/cuda-gpus) [SM 3.7 ](https://developer.nvidia.com/cuda-gpus) [SM 5.0 ](https://developer.nvidia.com/cuda-gpus) [SM 5.2 ](https://developer.nvidia.com/cuda-gpus) [SM 6.0 ](https://developer.nvidia.com/cuda-gpus) [SM 6.1 ](https://developer.nvidia.com/cuda-gpus) [SM 7.0 ](https://developer.nvidia.com/cuda-gpus)
|
||||||
|
|
||||||
|
## Supported OSes
|
||||||
|
|
||||||
|
Linux, Windows, MacOSX
|
||||||
|
|
||||||
|
## Supported CPU Architecture
|
||||||
|
|
||||||
|
x86_64, ppc64le, armv7l, aarch64
|
||||||
|
|
||||||
|
## CUDA APIs involved
|
||||||
|
|
||||||
|
## Dependencies needed to build/run
|
||||||
|
[CUFFT](../../README.md#cufft)
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
Download and install the [CUDA Toolkit 9.2](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
|
||||||
|
Make sure the dependencies mentioned in [Dependencies]() section above are installed.
|
||||||
|
|
||||||
|
## Build and Run
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
The Windows samples are built using the Visual Studio IDE. Solution files (.sln) are provided for each supported version of Visual Studio, using the format:
|
||||||
|
```
|
||||||
|
*_vs<version>.sln - for Visual Studio <version>
|
||||||
|
```
|
||||||
|
Each individual sample has its own set of solution files in its directory:
|
||||||
|
|
||||||
|
To build/examine all the samples at once, the complete solution files should be used. To build/examine a single sample, the individual sample solution files should be used.
|
||||||
|
> **Note:** Some samples require that the Microsoft DirectX SDK (June 2010 or newer) be installed and that the VC++ directory paths are properly set up (**Tools > Options...**). Check DirectX Dependencies section for details."
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
The Linux samples are built using makefiles. To use the makefiles, change the current directory to the sample directory you wish to build, and run make:
|
||||||
|
```
|
||||||
|
$ cd <sample_dir>
|
||||||
|
$ make
|
||||||
|
```
|
||||||
|
The samples makefiles can take advantage of certain options:
|
||||||
|
* **TARGET_ARCH=<arch>** - cross-compile targeting a specific architecture. Allowed architectures are x86_64, ppc64le, armv7l, aarch64.
|
||||||
|
By default, TARGET_ARCH is set to HOST_ARCH. On a x86_64 machine, not setting TARGET_ARCH is the equivalent of setting TARGET_ARCH=x86_64.<br/>
|
||||||
|
`$ make TARGET_ARCH=x86_64` <br/> `$ make TARGET_ARCH=ppc64le` <br/> `$ make TARGET_ARCH=armv7l` <br/> `$ make TARGET_ARCH=aarch64` <br/>
|
||||||
|
See [here](http://docs.nvidia.com/cuda/cuda-samples/index.html#cross-samples) for more details.
|
||||||
|
* **dbg=1** - build with debug symbols
|
||||||
|
```
|
||||||
|
$ make dbg=1
|
||||||
|
```
|
||||||
|
* **SMS="A B ..."** - override the SM architectures for which the sample will be built, where `"A B ..."` is a space-delimited list of SM architectures. For example, to generate SASS for SM 50 and SM 60, use `SMS="50 60"`.
|
||||||
|
```
|
||||||
|
$ make SMS="50 60"
|
||||||
|
```
|
||||||
|
|
||||||
|
* **HOST_COMPILER=<host_compiler>** - override the default g++ host compiler. See the [Linux Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements) for a list of supported host compilers.
|
||||||
|
```
|
||||||
|
$ make HOST_COMPILER=g++
|
||||||
|
```
|
||||||
|
|
||||||
|
### Mac
|
||||||
|
The Mac samples are built using makefiles. To use the makefiles, change directory into the sample directory you wish to build, and run make:
|
||||||
|
```
|
||||||
|
$ cd <sample_dir>
|
||||||
|
$ make
|
||||||
|
```
|
||||||
|
|
||||||
|
The samples makefiles can take advantage of certain options:
|
||||||
|
|
||||||
|
* **dbg=1** - build with debug symbols
|
||||||
|
```
|
||||||
|
$ make dbg=1
|
||||||
|
```
|
||||||
|
|
||||||
|
* **SMS="A B ..."** - override the SM architectures for which the sample will be built, where "A B ..." is a space-delimited list of SM architectures. For example, to generate SASS for SM 50 and SM 60, use SMS="50 60".
|
||||||
|
```
|
||||||
|
$ make SMS="A B ..."
|
||||||
|
```
|
||||||
|
|
||||||
|
* **HOST_COMPILER=<host_compiler>** - override the default clang host compiler. See the [Mac Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html#system-requirements) for a list of supported host compilers.
|
||||||
|
```
|
||||||
|
$ make HOST_COMPILER=clang
|
||||||
|
```
|
||||||
|
|
||||||
|
## References (for more details)
|
||||||
|
|
286
Samples/simpleCUFFT/simpleCUFFT.cu
Normal file
286
Samples/simpleCUFFT/simpleCUFFT.cu
Normal file
|
@ -0,0 +1,286 @@
|
||||||
|
/* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Example showing the use of CUFFT for fast 1D-convolution using FFT. */
|
||||||
|
|
||||||
|
// includes, system
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
// includes, project
|
||||||
|
#include <cuda_runtime.h>
|
||||||
|
#include <cufft.h>
|
||||||
|
#include <cufftXt.h>
|
||||||
|
#include <helper_cuda.h>
|
||||||
|
#include <helper_functions.h>
|
||||||
|
|
||||||
|
// Complex data type
|
||||||
|
typedef float2 Complex;
|
||||||
|
static __device__ __host__ inline Complex ComplexAdd(Complex, Complex);
|
||||||
|
static __device__ __host__ inline Complex ComplexScale(Complex, float);
|
||||||
|
static __device__ __host__ inline Complex ComplexMul(Complex, Complex);
|
||||||
|
static __global__ void ComplexPointwiseMulAndScale(Complex *, const Complex *,
|
||||||
|
int, float);
|
||||||
|
|
||||||
|
// Filtering functions
|
||||||
|
void Convolve(const Complex *, int, const Complex *, int, Complex *);
|
||||||
|
|
||||||
|
// Padding functions
|
||||||
|
int PadData(const Complex *, Complex **, int, const Complex *, Complex **, int);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// declaration, forward
|
||||||
|
void runTest(int argc, char **argv);
|
||||||
|
|
||||||
|
// The filter size is assumed to be a number smaller than the signal size
|
||||||
|
#define SIGNAL_SIZE 50
|
||||||
|
#define FILTER_KERNEL_SIZE 11
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Program main
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
int main(int argc, char **argv) { runTest(argc, argv); }
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//! Run a simple test for CUDA
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void runTest(int argc, char **argv) {
|
||||||
|
printf("[simpleCUFFT] is starting...\n");
|
||||||
|
|
||||||
|
findCudaDevice(argc, (const char **)argv);
|
||||||
|
|
||||||
|
// Allocate host memory for the signal
|
||||||
|
Complex *h_signal =
|
||||||
|
reinterpret_cast<Complex *>(malloc(sizeof(Complex) * SIGNAL_SIZE));
|
||||||
|
|
||||||
|
// Initialize the memory for the signal
|
||||||
|
for (unsigned int i = 0; i < SIGNAL_SIZE; ++i) {
|
||||||
|
h_signal[i].x = rand() / static_cast<float>(RAND_MAX);
|
||||||
|
h_signal[i].y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allocate host memory for the filter
|
||||||
|
Complex *h_filter_kernel =
|
||||||
|
reinterpret_cast<Complex *>(malloc(sizeof(Complex) * FILTER_KERNEL_SIZE));
|
||||||
|
|
||||||
|
// Initialize the memory for the filter
|
||||||
|
for (unsigned int i = 0; i < FILTER_KERNEL_SIZE; ++i) {
|
||||||
|
h_filter_kernel[i].x = rand() / static_cast<float>(RAND_MAX);
|
||||||
|
h_filter_kernel[i].y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pad signal and filter kernel
|
||||||
|
Complex *h_padded_signal;
|
||||||
|
Complex *h_padded_filter_kernel;
|
||||||
|
int new_size =
|
||||||
|
PadData(h_signal, &h_padded_signal, SIGNAL_SIZE, h_filter_kernel,
|
||||||
|
&h_padded_filter_kernel, FILTER_KERNEL_SIZE);
|
||||||
|
int mem_size = sizeof(Complex) * new_size;
|
||||||
|
|
||||||
|
// Allocate device memory for signal
|
||||||
|
Complex *d_signal;
|
||||||
|
checkCudaErrors(cudaMalloc(reinterpret_cast<void **>(&d_signal), mem_size));
|
||||||
|
// Copy host memory to device
|
||||||
|
checkCudaErrors(
|
||||||
|
cudaMemcpy(d_signal, h_padded_signal, mem_size, cudaMemcpyHostToDevice));
|
||||||
|
|
||||||
|
// Allocate device memory for filter kernel
|
||||||
|
Complex *d_filter_kernel;
|
||||||
|
checkCudaErrors(
|
||||||
|
cudaMalloc(reinterpret_cast<void **>(&d_filter_kernel), mem_size));
|
||||||
|
|
||||||
|
// Copy host memory to device
|
||||||
|
checkCudaErrors(cudaMemcpy(d_filter_kernel, h_padded_filter_kernel, mem_size,
|
||||||
|
cudaMemcpyHostToDevice));
|
||||||
|
|
||||||
|
// CUFFT plan simple API
|
||||||
|
cufftHandle plan;
|
||||||
|
checkCudaErrors(cufftPlan1d(&plan, new_size, CUFFT_C2C, 1));
|
||||||
|
|
||||||
|
// CUFFT plan advanced API
|
||||||
|
cufftHandle plan_adv;
|
||||||
|
size_t workSize;
|
||||||
|
long long int new_size_long = new_size;
|
||||||
|
|
||||||
|
checkCudaErrors(cufftCreate(&plan_adv));
|
||||||
|
checkCudaErrors(cufftXtMakePlanMany(plan_adv, 1, &new_size_long, NULL, 1, 1,
|
||||||
|
CUDA_C_32F, NULL, 1, 1, CUDA_C_32F, 1,
|
||||||
|
&workSize, CUDA_C_32F));
|
||||||
|
printf("Temporary buffer size %li bytes\n", workSize);
|
||||||
|
|
||||||
|
// Transform signal and kernel
|
||||||
|
printf("Transforming signal cufftExecC2C\n");
|
||||||
|
checkCudaErrors(cufftExecC2C(plan, reinterpret_cast<cufftComplex *>(d_signal),
|
||||||
|
reinterpret_cast<cufftComplex *>(d_signal),
|
||||||
|
CUFFT_FORWARD));
|
||||||
|
checkCudaErrors(cufftExecC2C(
|
||||||
|
plan_adv, reinterpret_cast<cufftComplex *>(d_filter_kernel),
|
||||||
|
reinterpret_cast<cufftComplex *>(d_filter_kernel), CUFFT_FORWARD));
|
||||||
|
|
||||||
|
// Multiply the coefficients together and normalize the result
|
||||||
|
printf("Launching ComplexPointwiseMulAndScale<<< >>>\n");
|
||||||
|
ComplexPointwiseMulAndScale<<<32, 256>>>(d_signal, d_filter_kernel, new_size,
|
||||||
|
1.0f / new_size);
|
||||||
|
|
||||||
|
// Check if kernel execution generated and error
|
||||||
|
getLastCudaError("Kernel execution failed [ ComplexPointwiseMulAndScale ]");
|
||||||
|
|
||||||
|
// Transform signal back
|
||||||
|
printf("Transforming signal back cufftExecC2C\n");
|
||||||
|
checkCudaErrors(cufftExecC2C(plan, reinterpret_cast<cufftComplex *>(d_signal),
|
||||||
|
reinterpret_cast<cufftComplex *>(d_signal),
|
||||||
|
CUFFT_INVERSE));
|
||||||
|
|
||||||
|
// Copy device memory to host
|
||||||
|
Complex *h_convolved_signal = h_padded_signal;
|
||||||
|
checkCudaErrors(cudaMemcpy(h_convolved_signal, d_signal, mem_size,
|
||||||
|
cudaMemcpyDeviceToHost));
|
||||||
|
|
||||||
|
// Allocate host memory for the convolution result
|
||||||
|
Complex *h_convolved_signal_ref =
|
||||||
|
reinterpret_cast<Complex *>(malloc(sizeof(Complex) * SIGNAL_SIZE));
|
||||||
|
|
||||||
|
// Convolve on the host
|
||||||
|
Convolve(h_signal, SIGNAL_SIZE, h_filter_kernel, FILTER_KERNEL_SIZE,
|
||||||
|
h_convolved_signal_ref);
|
||||||
|
|
||||||
|
// check result
|
||||||
|
bool bTestResult = sdkCompareL2fe(
|
||||||
|
reinterpret_cast<float *>(h_convolved_signal_ref),
|
||||||
|
reinterpret_cast<float *>(h_convolved_signal), 2 * SIGNAL_SIZE, 1e-5f);
|
||||||
|
|
||||||
|
// Destroy CUFFT context
|
||||||
|
checkCudaErrors(cufftDestroy(plan));
|
||||||
|
checkCudaErrors(cufftDestroy(plan_adv));
|
||||||
|
|
||||||
|
// cleanup memory
|
||||||
|
free(h_signal);
|
||||||
|
free(h_filter_kernel);
|
||||||
|
free(h_padded_signal);
|
||||||
|
free(h_padded_filter_kernel);
|
||||||
|
free(h_convolved_signal_ref);
|
||||||
|
checkCudaErrors(cudaFree(d_signal));
|
||||||
|
checkCudaErrors(cudaFree(d_filter_kernel));
|
||||||
|
|
||||||
|
exit(bTestResult ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pad data
|
||||||
|
int PadData(const Complex *signal, Complex **padded_signal, int signal_size,
|
||||||
|
const Complex *filter_kernel, Complex **padded_filter_kernel,
|
||||||
|
int filter_kernel_size) {
|
||||||
|
int minRadius = filter_kernel_size / 2;
|
||||||
|
int maxRadius = filter_kernel_size - minRadius;
|
||||||
|
int new_size = signal_size + maxRadius;
|
||||||
|
|
||||||
|
// Pad signal
|
||||||
|
Complex *new_data =
|
||||||
|
reinterpret_cast<Complex *>(malloc(sizeof(Complex) * new_size));
|
||||||
|
memcpy(new_data + 0, signal, signal_size * sizeof(Complex));
|
||||||
|
memset(new_data + signal_size, 0, (new_size - signal_size) * sizeof(Complex));
|
||||||
|
*padded_signal = new_data;
|
||||||
|
|
||||||
|
// Pad filter
|
||||||
|
new_data = reinterpret_cast<Complex *>(malloc(sizeof(Complex) * new_size));
|
||||||
|
memcpy(new_data + 0, filter_kernel + minRadius, maxRadius * sizeof(Complex));
|
||||||
|
memset(new_data + maxRadius, 0,
|
||||||
|
(new_size - filter_kernel_size) * sizeof(Complex));
|
||||||
|
memcpy(new_data + new_size - minRadius, filter_kernel,
|
||||||
|
minRadius * sizeof(Complex));
|
||||||
|
*padded_filter_kernel = new_data;
|
||||||
|
|
||||||
|
return new_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Filtering operations
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// Computes convolution on the host
|
||||||
|
void Convolve(const Complex *signal, int signal_size,
|
||||||
|
const Complex *filter_kernel, int filter_kernel_size,
|
||||||
|
Complex *filtered_signal) {
|
||||||
|
int minRadius = filter_kernel_size / 2;
|
||||||
|
int maxRadius = filter_kernel_size - minRadius;
|
||||||
|
|
||||||
|
// Loop over output element indices
|
||||||
|
for (int i = 0; i < signal_size; ++i) {
|
||||||
|
filtered_signal[i].x = filtered_signal[i].y = 0;
|
||||||
|
|
||||||
|
// Loop over convolution indices
|
||||||
|
for (int j = -maxRadius + 1; j <= minRadius; ++j) {
|
||||||
|
int k = i + j;
|
||||||
|
|
||||||
|
if (k >= 0 && k < signal_size) {
|
||||||
|
filtered_signal[i] =
|
||||||
|
ComplexAdd(filtered_signal[i],
|
||||||
|
ComplexMul(signal[k], filter_kernel[minRadius - j]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Complex operations
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// Complex addition
|
||||||
|
static __device__ __host__ inline Complex ComplexAdd(Complex a, Complex b) {
|
||||||
|
Complex c;
|
||||||
|
c.x = a.x + b.x;
|
||||||
|
c.y = a.y + b.y;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Complex scale
|
||||||
|
static __device__ __host__ inline Complex ComplexScale(Complex a, float s) {
|
||||||
|
Complex c;
|
||||||
|
c.x = s * a.x;
|
||||||
|
c.y = s * a.y;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Complex multiplication
|
||||||
|
static __device__ __host__ inline Complex ComplexMul(Complex a, Complex b) {
|
||||||
|
Complex c;
|
||||||
|
c.x = a.x * b.x - a.y * b.y;
|
||||||
|
c.y = a.x * b.y + a.y * b.x;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Complex pointwise multiplication
|
||||||
|
static __global__ void ComplexPointwiseMulAndScale(Complex *a, const Complex *b,
|
||||||
|
int size, float scale) {
|
||||||
|
const int numThreads = blockDim.x * gridDim.x;
|
||||||
|
const int threadID = blockIdx.x * blockDim.x + threadIdx.x;
|
||||||
|
|
||||||
|
for (int i = threadID; i < size; i += numThreads) {
|
||||||
|
a[i] = ComplexScale(ComplexMul(a[i], b[i]), scale);
|
||||||
|
}
|
||||||
|
}
|
20
Samples/simpleCUFFT/simpleCUFFT_vs2010.sln
Normal file
20
Samples/simpleCUFFT/simpleCUFFT_vs2010.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||||
|
# Visual Studio 2010
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simpleCUFFT", "simpleCUFFT_vs2010.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
106
Samples/simpleCUFFT/simpleCUFFT_vs2010.vcxproj
Normal file
106
Samples/simpleCUFFT/simpleCUFFT_vs2010.vcxproj
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>simpleCUFFT_vs2010</RootNamespace>
|
||||||
|
<ProjectName>simpleCUFFT</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;$(CudaToolkitIncludeDir);</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>cufft.lib;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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/simpleCUFFT.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,sm_30;compute_35,sm_35;compute_37,sm_37;compute_50,sm_50;compute_52,sm_52;compute_60,sm_60;compute_61,sm_61;compute_70,sm_70;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<CudaCompile Include="simpleCUFFT.cu" />
|
||||||
|
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/simpleCUFFT/simpleCUFFT_vs2012.sln
Normal file
20
Samples/simpleCUFFT/simpleCUFFT_vs2012.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2012
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simpleCUFFT", "simpleCUFFT_vs2012.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
107
Samples/simpleCUFFT/simpleCUFFT_vs2012.vcxproj
Normal file
107
Samples/simpleCUFFT/simpleCUFFT_vs2012.vcxproj
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>simpleCUFFT_vs2012</RootNamespace>
|
||||||
|
<ProjectName>simpleCUFFT</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;$(CudaToolkitIncludeDir);</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>cufft.lib;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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/simpleCUFFT.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,sm_30;compute_35,sm_35;compute_37,sm_37;compute_50,sm_50;compute_52,sm_52;compute_60,sm_60;compute_61,sm_61;compute_70,sm_70;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<CudaCompile Include="simpleCUFFT.cu" />
|
||||||
|
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/simpleCUFFT/simpleCUFFT_vs2013.sln
Normal file
20
Samples/simpleCUFFT/simpleCUFFT_vs2013.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 13.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simpleCUFFT", "simpleCUFFT_vs2013.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
107
Samples/simpleCUFFT/simpleCUFFT_vs2013.vcxproj
Normal file
107
Samples/simpleCUFFT/simpleCUFFT_vs2013.vcxproj
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>simpleCUFFT_vs2013</RootNamespace>
|
||||||
|
<ProjectName>simpleCUFFT</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;$(CudaToolkitIncludeDir);</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>cufft.lib;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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/simpleCUFFT.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,sm_30;compute_35,sm_35;compute_37,sm_37;compute_50,sm_50;compute_52,sm_52;compute_60,sm_60;compute_61,sm_61;compute_70,sm_70;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<CudaCompile Include="simpleCUFFT.cu" />
|
||||||
|
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/simpleCUFFT/simpleCUFFT_vs2015.sln
Normal file
20
Samples/simpleCUFFT/simpleCUFFT_vs2015.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 14.00
|
||||||
|
# Visual Studio 2015
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simpleCUFFT", "simpleCUFFT_vs2015.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
107
Samples/simpleCUFFT/simpleCUFFT_vs2015.vcxproj
Normal file
107
Samples/simpleCUFFT/simpleCUFFT_vs2015.vcxproj
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>simpleCUFFT_vs2015</RootNamespace>
|
||||||
|
<ProjectName>simpleCUFFT</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;$(CudaToolkitIncludeDir);</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>cufft.lib;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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/simpleCUFFT.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,sm_30;compute_35,sm_35;compute_37,sm_37;compute_50,sm_50;compute_52,sm_52;compute_60,sm_60;compute_61,sm_61;compute_70,sm_70;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<CudaCompile Include="simpleCUFFT.cu" />
|
||||||
|
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/simpleCUFFT/simpleCUFFT_vs2017.sln
Normal file
20
Samples/simpleCUFFT/simpleCUFFT_vs2017.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2017
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simpleCUFFT", "simpleCUFFT_vs2017.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
108
Samples/simpleCUFFT/simpleCUFFT_vs2017.vcxproj
Normal file
108
Samples/simpleCUFFT/simpleCUFFT_vs2017.vcxproj
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>simpleCUFFT_vs2017</RootNamespace>
|
||||||
|
<ProjectName>simpleCUFFT</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;$(CudaToolkitIncludeDir);</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>cufft.lib;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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/simpleCUFFT.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration>compute_30,sm_30;compute_35,sm_35;compute_37,sm_37;compute_50,sm_50;compute_52,sm_52;compute_60,sm_60;compute_61,sm_61;compute_70,sm_70;</CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<CudaCompile Include="simpleCUFFT.cu" />
|
||||||
|
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
334
Samples/vectorAdd_nvrtc/Makefile
Normal file
334
Samples/vectorAdd_nvrtc/Makefile
Normal file
|
@ -0,0 +1,334 @@
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Copyright 1993-2015 NVIDIA Corporation. All rights reserved.
|
||||||
|
#
|
||||||
|
# NOTICE TO USER:
|
||||||
|
#
|
||||||
|
# This source code is subject to NVIDIA ownership rights under U.S. and
|
||||||
|
# international Copyright laws.
|
||||||
|
#
|
||||||
|
# NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
|
||||||
|
# CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
|
||||||
|
# IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
# REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
# MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
# IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
||||||
|
# OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||||
|
# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||||
|
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|
||||||
|
# OR PERFORMANCE OF THIS SOURCE CODE.
|
||||||
|
#
|
||||||
|
# U.S. Government End Users. This source code is a "commercial item" as
|
||||||
|
# that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
|
||||||
|
# "commercial computer software" and "commercial computer software
|
||||||
|
# documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
|
||||||
|
# and is provided to the U.S. Government only as a commercial end item.
|
||||||
|
# Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
|
||||||
|
# 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
|
||||||
|
# source code with only those rights set forth herein.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Makefile project only supported on Mac OS X and Linux Platforms)
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Location of the CUDA Toolkit
|
||||||
|
CUDA_PATH ?= /usr/local/cuda
|
||||||
|
|
||||||
|
##############################
|
||||||
|
# start deprecated interface #
|
||||||
|
##############################
|
||||||
|
ifeq ($(x86_64),1)
|
||||||
|
$(info WARNING - x86_64 variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=x86_64 instead)
|
||||||
|
TARGET_ARCH ?= x86_64
|
||||||
|
endif
|
||||||
|
ifeq ($(ARMv7),1)
|
||||||
|
$(info WARNING - ARMv7 variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=armv7l instead)
|
||||||
|
TARGET_ARCH ?= armv7l
|
||||||
|
endif
|
||||||
|
ifeq ($(aarch64),1)
|
||||||
|
$(info WARNING - aarch64 variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=aarch64 instead)
|
||||||
|
TARGET_ARCH ?= aarch64
|
||||||
|
endif
|
||||||
|
ifeq ($(ppc64le),1)
|
||||||
|
$(info WARNING - ppc64le variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=ppc64le instead)
|
||||||
|
TARGET_ARCH ?= ppc64le
|
||||||
|
endif
|
||||||
|
ifneq ($(GCC),)
|
||||||
|
$(info WARNING - GCC variable has been deprecated)
|
||||||
|
$(info WARNING - please use HOST_COMPILER=$(GCC) instead)
|
||||||
|
HOST_COMPILER ?= $(GCC)
|
||||||
|
endif
|
||||||
|
ifneq ($(abi),)
|
||||||
|
$(error ERROR - abi variable has been removed)
|
||||||
|
endif
|
||||||
|
############################
|
||||||
|
# end deprecated interface #
|
||||||
|
############################
|
||||||
|
|
||||||
|
# architecture
|
||||||
|
HOST_ARCH := $(shell uname -m)
|
||||||
|
TARGET_ARCH ?= $(HOST_ARCH)
|
||||||
|
ifneq (,$(filter $(TARGET_ARCH),x86_64 aarch64 ppc64le armv7l))
|
||||||
|
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifneq (,$(filter $(TARGET_ARCH),x86_64 aarch64 ppc64le))
|
||||||
|
TARGET_SIZE := 64
|
||||||
|
else ifneq (,$(filter $(TARGET_ARCH),armv7l))
|
||||||
|
TARGET_SIZE := 32
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
TARGET_SIZE := $(shell getconf LONG_BIT)
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
$(error ERROR - unsupported value $(TARGET_ARCH) for TARGET_ARCH!)
|
||||||
|
endif
|
||||||
|
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifeq (,$(filter $(HOST_ARCH)-$(TARGET_ARCH),aarch64-armv7l x86_64-armv7l x86_64-aarch64 x86_64-ppc64le))
|
||||||
|
$(error ERROR - cross compiling from $(HOST_ARCH) to $(TARGET_ARCH) is not supported!)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# When on native aarch64 system with userspace of 32-bit, change TARGET_ARCH to armv7l
|
||||||
|
ifeq ($(HOST_ARCH)-$(TARGET_ARCH)-$(TARGET_SIZE),aarch64-aarch64-32)
|
||||||
|
TARGET_ARCH = armv7l
|
||||||
|
endif
|
||||||
|
|
||||||
|
# operating system
|
||||||
|
HOST_OS := $(shell uname -s 2>/dev/null | tr "[:upper:]" "[:lower:]")
|
||||||
|
TARGET_OS ?= $(HOST_OS)
|
||||||
|
ifeq (,$(filter $(TARGET_OS),linux darwin qnx android))
|
||||||
|
$(error ERROR - unsupported value $(TARGET_OS) for TARGET_OS!)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# host compiler
|
||||||
|
ifeq ($(TARGET_OS),darwin)
|
||||||
|
ifeq ($(shell expr `xcodebuild -version | grep -i xcode | awk '{print $$2}' | cut -d'.' -f1` \>= 5),1)
|
||||||
|
HOST_COMPILER ?= clang++
|
||||||
|
endif
|
||||||
|
else ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifeq ($(HOST_ARCH)-$(TARGET_ARCH),x86_64-armv7l)
|
||||||
|
ifeq ($(TARGET_OS),linux)
|
||||||
|
HOST_COMPILER ?= arm-linux-gnueabihf-g++
|
||||||
|
else ifeq ($(TARGET_OS),qnx)
|
||||||
|
ifeq ($(QNX_HOST),)
|
||||||
|
$(error ERROR - QNX_HOST must be passed to the QNX host toolchain)
|
||||||
|
endif
|
||||||
|
ifeq ($(QNX_TARGET),)
|
||||||
|
$(error ERROR - QNX_TARGET must be passed to the QNX target toolchain)
|
||||||
|
endif
|
||||||
|
export QNX_HOST
|
||||||
|
export QNX_TARGET
|
||||||
|
HOST_COMPILER ?= $(QNX_HOST)/usr/bin/arm-unknown-nto-qnx6.6.0eabi-g++
|
||||||
|
else ifeq ($(TARGET_OS),android)
|
||||||
|
HOST_COMPILER ?= arm-linux-androideabi-g++
|
||||||
|
endif
|
||||||
|
else ifeq ($(TARGET_ARCH),aarch64)
|
||||||
|
ifeq ($(TARGET_OS), linux)
|
||||||
|
HOST_COMPILER ?= aarch64-linux-gnu-g++
|
||||||
|
else ifeq ($(TARGET_OS),qnx)
|
||||||
|
ifeq ($(QNX_HOST),)
|
||||||
|
$(error ERROR - QNX_HOST must be passed to the QNX host toolchain)
|
||||||
|
endif
|
||||||
|
ifeq ($(QNX_TARGET),)
|
||||||
|
$(error ERROR - QNX_TARGET must be passed to the QNX target toolchain)
|
||||||
|
endif
|
||||||
|
export QNX_HOST
|
||||||
|
export QNX_TARGET
|
||||||
|
HOST_COMPILER ?= $(QNX_HOST)/usr/bin/aarch64-unknown-nto-qnx7.0.0-g++
|
||||||
|
else ifeq ($(TARGET_OS), android)
|
||||||
|
HOST_COMPILER ?= aarch64-linux-android-g++
|
||||||
|
endif
|
||||||
|
else ifeq ($(TARGET_ARCH),ppc64le)
|
||||||
|
HOST_COMPILER ?= powerpc64le-linux-gnu-g++
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
HOST_COMPILER ?= g++
|
||||||
|
NVCC := $(CUDA_PATH)/bin/nvcc -ccbin $(HOST_COMPILER)
|
||||||
|
|
||||||
|
# internal flags
|
||||||
|
NVCCFLAGS := -m${TARGET_SIZE}
|
||||||
|
CCFLAGS :=
|
||||||
|
LDFLAGS :=
|
||||||
|
|
||||||
|
# build flags
|
||||||
|
ifeq ($(TARGET_OS),darwin)
|
||||||
|
LDFLAGS += -rpath $(CUDA_PATH)/lib
|
||||||
|
CCFLAGS += -arch $(HOST_ARCH)
|
||||||
|
else ifeq ($(HOST_ARCH)-$(TARGET_ARCH)-$(TARGET_OS),x86_64-armv7l-linux)
|
||||||
|
LDFLAGS += --dynamic-linker=/lib/ld-linux-armhf.so.3
|
||||||
|
CCFLAGS += -mfloat-abi=hard
|
||||||
|
else ifeq ($(TARGET_OS),android)
|
||||||
|
LDFLAGS += -pie
|
||||||
|
CCFLAGS += -fpie -fpic -fexceptions
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
||||||
|
ifneq ($(TARGET_FS),)
|
||||||
|
GCCVERSIONLTEQ46 := $(shell expr `$(HOST_COMPILER) -dumpversion` \<= 4.6)
|
||||||
|
ifeq ($(GCCVERSIONLTEQ46),1)
|
||||||
|
CCFLAGS += --sysroot=$(TARGET_FS)
|
||||||
|
endif
|
||||||
|
LDFLAGS += --sysroot=$(TARGET_FS)
|
||||||
|
LDFLAGS += -rpath-link=$(TARGET_FS)/lib
|
||||||
|
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib
|
||||||
|
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib/arm-linux-gnueabihf
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_OS),qnx)
|
||||||
|
CCFLAGS += -DWIN_INTERFACE_CUSTOM
|
||||||
|
LDFLAGS += -lsocket
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Install directory of different arch
|
||||||
|
CUDA_INSTALL_TARGET_DIR :=
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/armv7-linux-gnueabihf/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-linux)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/aarch64-linux/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-android)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/armv7-linux-androideabi/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-android)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/aarch64-linux-androideabi/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-qnx)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/ARMv7-linux-QNX/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-qnx)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/aarch64-qnx/
|
||||||
|
else ifeq ($(TARGET_ARCH),ppc64le)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/ppc64le-linux/
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Debug build flags
|
||||||
|
ifeq ($(dbg),1)
|
||||||
|
CCFLAGS += -g
|
||||||
|
BUILD_TYPE := debug
|
||||||
|
else
|
||||||
|
BUILD_TYPE := release
|
||||||
|
endif
|
||||||
|
|
||||||
|
ALL_CCFLAGS :=
|
||||||
|
ALL_CCFLAGS += $(NVCCFLAGS)
|
||||||
|
ALL_CCFLAGS += $(EXTRA_NVCCFLAGS)
|
||||||
|
ALL_CCFLAGS += $(addprefix -Xcompiler ,$(CCFLAGS))
|
||||||
|
ALL_CCFLAGS += $(addprefix -Xcompiler ,$(EXTRA_CCFLAGS))
|
||||||
|
|
||||||
|
UBUNTU = $(shell lsb_release -i -s 2>/dev/null | grep -i ubuntu)
|
||||||
|
|
||||||
|
SAMPLE_ENABLED := 1
|
||||||
|
|
||||||
|
# This sample is not supported on ARMv7
|
||||||
|
ifeq ($(TARGET_ARCH),armv7l)
|
||||||
|
$(info >>> WARNING - vectorAdd_nvrtc is not supported on ARMv7 - waiving sample <<<)
|
||||||
|
SAMPLE_ENABLED := 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
ALL_LDFLAGS :=
|
||||||
|
ALL_LDFLAGS += $(ALL_CCFLAGS)
|
||||||
|
ALL_LDFLAGS += $(addprefix -Xlinker ,$(LDFLAGS))
|
||||||
|
ALL_LDFLAGS += $(addprefix -Xlinker ,$(EXTRA_LDFLAGS))
|
||||||
|
|
||||||
|
# Common includes and paths for CUDA
|
||||||
|
INCLUDES := -I../../Common
|
||||||
|
LIBRARIES :=
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# libNVRTC specific libraries
|
||||||
|
ifeq ($(TARGET_OS),darwin)
|
||||||
|
LDFLAGS += -L$(CUDA_PATH)/lib -framework CUDA
|
||||||
|
else ifeq ($(TARGET_ARCH),x86_64)
|
||||||
|
LDFLAGS += -L$(CUDA_PATH)/lib64/stubs -L$(CUDA_PATH)/lib64
|
||||||
|
else ifeq ($(TARGET_ARCH),ppc64le)
|
||||||
|
LDFLAGS += -L$(CUDA_PATH)/targets/ppc64le-linux/lib/stubs -L$(CUDA_PATH)/targets/ppc64le-linux/lib
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_OS),darwin)
|
||||||
|
ALL_LDFLAGS += -Xcompiler -F/Library/Frameworks -Xlinker -framework -Xlinker CUDA
|
||||||
|
else
|
||||||
|
ifeq ($(TARGET_ARCH),x86_64)
|
||||||
|
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/lib64/stubs
|
||||||
|
CUDA_SEARCH_PATH += $(CUDA_PATH)/targets/x86_64-linux/lib/stubs
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
||||||
|
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/armv7-linux-gnueabihf/lib/stubs
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-linux)
|
||||||
|
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/aarch64-linux/lib/stubs
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-android)
|
||||||
|
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/armv7-linux-androideabi/lib/stubs
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-android)
|
||||||
|
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/aarch64-linux-androideabi/lib/stubs
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-qnx)
|
||||||
|
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/ARMv7-linux-QNX/lib/stubs
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-qnx)
|
||||||
|
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/aarch64-qnx/lib/stubs
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_ARCH),ppc64le)
|
||||||
|
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/ppc64le-linux/lib/stubs
|
||||||
|
endif
|
||||||
|
|
||||||
|
CUDALIB ?= $(shell find -L $(CUDA_SEARCH_PATH) -maxdepth 1 -name libcuda.so 2> /dev/null)
|
||||||
|
ifeq ("$(CUDALIB)","")
|
||||||
|
$(info >>> WARNING - libcuda.so not found, CUDA Driver is not installed. Please re-install the driver. <<<)
|
||||||
|
SAMPLE_ENABLED := 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
LIBRARIES += -lcuda
|
||||||
|
endif
|
||||||
|
|
||||||
|
INCLUDES += -I$(CUDA_PATH)/include
|
||||||
|
|
||||||
|
LIBRARIES += -lnvrtc
|
||||||
|
|
||||||
|
ifeq ($(SAMPLE_ENABLED),0)
|
||||||
|
EXEC ?= @echo "[@]"
|
||||||
|
endif
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Target rules
|
||||||
|
all: build
|
||||||
|
|
||||||
|
build: vectorAdd_nvrtc
|
||||||
|
|
||||||
|
check.deps:
|
||||||
|
ifeq ($(SAMPLE_ENABLED),0)
|
||||||
|
@echo "Sample will be waived due to the above missing dependencies"
|
||||||
|
else
|
||||||
|
@echo "Sample is ready - all dependencies have been met"
|
||||||
|
endif
|
||||||
|
|
||||||
|
vectorAdd.o:vectorAdd.cpp
|
||||||
|
$(EXEC) $(HOST_COMPILER) $(INCLUDES) $(CCFLAGS) $(EXTRA_CCFLAGS) -o $@ -c $<
|
||||||
|
|
||||||
|
vectorAdd_nvrtc: vectorAdd.o
|
||||||
|
$(EXEC) $(HOST_COMPILER) $(LDFLAGS) -o $@ $+ $(LIBRARIES)
|
||||||
|
$(EXEC) mkdir -p ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
||||||
|
$(EXEC) cp $@ ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
||||||
|
|
||||||
|
run: build
|
||||||
|
$(EXEC) ./vectorAdd_nvrtc
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f vectorAdd_nvrtc vectorAdd.o
|
||||||
|
rm -rf ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)/vectorAdd_nvrtc
|
||||||
|
|
||||||
|
clobber: clean
|
98
Samples/vectorAdd_nvrtc/README.md
Normal file
98
Samples/vectorAdd_nvrtc/README.md
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
# vectorAdd_nvrtc - Vector Addition with libNVRTC
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
This CUDA Driver API sample uses NVRTC for runtime compilation of vector addition kernel. Vector addition kernel demonstrated is the same as the sample illustrating Chapter 3 of the programming guide.
|
||||||
|
|
||||||
|
## Key Concepts
|
||||||
|
|
||||||
|
CUDA Driver API, Vector Addition, Runtime Compilation
|
||||||
|
|
||||||
|
## Supported SM Architectures
|
||||||
|
|
||||||
|
[SM 3.0 ](https://developer.nvidia.com/cuda-gpus) [SM 3.5 ](https://developer.nvidia.com/cuda-gpus) [SM 3.7 ](https://developer.nvidia.com/cuda-gpus) [SM 5.0 ](https://developer.nvidia.com/cuda-gpus) [SM 5.2 ](https://developer.nvidia.com/cuda-gpus) [SM 6.0 ](https://developer.nvidia.com/cuda-gpus) [SM 6.1 ](https://developer.nvidia.com/cuda-gpus) [SM 7.0 ](https://developer.nvidia.com/cuda-gpus)
|
||||||
|
|
||||||
|
## Supported OSes
|
||||||
|
|
||||||
|
Linux, Windows, MacOSX
|
||||||
|
|
||||||
|
## Supported CPU Architecture
|
||||||
|
|
||||||
|
x86_64, ppc64le, aarch64
|
||||||
|
|
||||||
|
## CUDA APIs involved
|
||||||
|
|
||||||
|
### [CUDA Driver API](http://docs.nvidia.com/cuda/cuda-driver-api/index.html)
|
||||||
|
cuMemAlloc, cuMemFree, cuMemcpyHtoD, cuMemcpyDtoH
|
||||||
|
|
||||||
|
## Dependencies needed to build/run
|
||||||
|
[NVRTC](../../README.md#nvrtc)
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
Download and install the [CUDA Toolkit 9.2](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
|
||||||
|
Make sure the dependencies mentioned in [Dependencies]() section above are installed.
|
||||||
|
|
||||||
|
## Build and Run
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
The Windows samples are built using the Visual Studio IDE. Solution files (.sln) are provided for each supported version of Visual Studio, using the format:
|
||||||
|
```
|
||||||
|
*_vs<version>.sln - for Visual Studio <version>
|
||||||
|
```
|
||||||
|
Each individual sample has its own set of solution files in its directory:
|
||||||
|
|
||||||
|
To build/examine all the samples at once, the complete solution files should be used. To build/examine a single sample, the individual sample solution files should be used.
|
||||||
|
> **Note:** Some samples require that the Microsoft DirectX SDK (June 2010 or newer) be installed and that the VC++ directory paths are properly set up (**Tools > Options...**). Check DirectX Dependencies section for details."
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
The Linux samples are built using makefiles. To use the makefiles, change the current directory to the sample directory you wish to build, and run make:
|
||||||
|
```
|
||||||
|
$ cd <sample_dir>
|
||||||
|
$ make
|
||||||
|
```
|
||||||
|
The samples makefiles can take advantage of certain options:
|
||||||
|
* **TARGET_ARCH=<arch>** - cross-compile targeting a specific architecture. Allowed architectures are x86_64, ppc64le, aarch64.
|
||||||
|
By default, TARGET_ARCH is set to HOST_ARCH. On a x86_64 machine, not setting TARGET_ARCH is the equivalent of setting TARGET_ARCH=x86_64.<br/>
|
||||||
|
`$ make TARGET_ARCH=x86_64` <br/> `$ make TARGET_ARCH=ppc64le` <br/> `$ make TARGET_ARCH=aarch64` <br/>
|
||||||
|
See [here](http://docs.nvidia.com/cuda/cuda-samples/index.html#cross-samples) for more details.
|
||||||
|
* **dbg=1** - build with debug symbols
|
||||||
|
```
|
||||||
|
$ make dbg=1
|
||||||
|
```
|
||||||
|
* **SMS="A B ..."** - override the SM architectures for which the sample will be built, where `"A B ..."` is a space-delimited list of SM architectures. For example, to generate SASS for SM 50 and SM 60, use `SMS="50 60"`.
|
||||||
|
```
|
||||||
|
$ make SMS="50 60"
|
||||||
|
```
|
||||||
|
|
||||||
|
* **HOST_COMPILER=<host_compiler>** - override the default g++ host compiler. See the [Linux Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements) for a list of supported host compilers.
|
||||||
|
```
|
||||||
|
$ make HOST_COMPILER=g++
|
||||||
|
```
|
||||||
|
|
||||||
|
### Mac
|
||||||
|
The Mac samples are built using makefiles. To use the makefiles, change directory into the sample directory you wish to build, and run make:
|
||||||
|
```
|
||||||
|
$ cd <sample_dir>
|
||||||
|
$ make
|
||||||
|
```
|
||||||
|
|
||||||
|
The samples makefiles can take advantage of certain options:
|
||||||
|
|
||||||
|
* **dbg=1** - build with debug symbols
|
||||||
|
```
|
||||||
|
$ make dbg=1
|
||||||
|
```
|
||||||
|
|
||||||
|
* **SMS="A B ..."** - override the SM architectures for which the sample will be built, where "A B ..." is a space-delimited list of SM architectures. For example, to generate SASS for SM 50 and SM 60, use SMS="50 60".
|
||||||
|
```
|
||||||
|
$ make SMS="A B ..."
|
||||||
|
```
|
||||||
|
|
||||||
|
* **HOST_COMPILER=<host_compiler>** - override the default clang host compiler. See the [Mac Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html#system-requirements) for a list of supported host compilers.
|
||||||
|
```
|
||||||
|
$ make HOST_COMPILER=clang
|
||||||
|
```
|
||||||
|
|
||||||
|
## References (for more details)
|
||||||
|
|
153
Samples/vectorAdd_nvrtc/vectorAdd.cpp
Normal file
153
Samples/vectorAdd_nvrtc/vectorAdd.cpp
Normal file
|
@ -0,0 +1,153 @@
|
||||||
|
/* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vector addition: C = A + B.
|
||||||
|
*
|
||||||
|
* This sample is a very basic sample that implements element by element
|
||||||
|
* vector addition. It is the same as the sample illustrating Chapter 2
|
||||||
|
* of the programming guide with some additions like error checking.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
// For the CUDA runtime routines (prefixed with "cuda_")
|
||||||
|
#include <cuda.h>
|
||||||
|
#include <cuda_runtime.h>
|
||||||
|
|
||||||
|
// helper functions and utilities to work with CUDA
|
||||||
|
#include <helper_functions.h>
|
||||||
|
|
||||||
|
#include <nvrtc_helper.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Host main routine
|
||||||
|
*/
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
char *ptx, *kernel_file;
|
||||||
|
size_t ptxSize;
|
||||||
|
kernel_file = sdkFindFilePath("vectorAdd_kernel.cu", argv[0]);
|
||||||
|
compileFileToPTX(kernel_file, argc, argv, &ptx, &ptxSize, 0);
|
||||||
|
CUmodule module = loadPTX(ptx, argc, argv);
|
||||||
|
|
||||||
|
CUfunction kernel_addr;
|
||||||
|
checkCudaErrors(cuModuleGetFunction(&kernel_addr, module, "vectorAdd"));
|
||||||
|
|
||||||
|
// Print the vector length to be used, and compute its size
|
||||||
|
int numElements = 50000;
|
||||||
|
size_t size = numElements * sizeof(float);
|
||||||
|
printf("[Vector addition of %d elements]\n", numElements);
|
||||||
|
|
||||||
|
// Allocate the host input vector A
|
||||||
|
float *h_A = reinterpret_cast<float *>(malloc(size));
|
||||||
|
|
||||||
|
// Allocate the host input vector B
|
||||||
|
float *h_B = reinterpret_cast<float *>(malloc(size));
|
||||||
|
|
||||||
|
// Allocate the host output vector C
|
||||||
|
float *h_C = reinterpret_cast<float *>(malloc(size));
|
||||||
|
|
||||||
|
// Verify that allocations succeeded
|
||||||
|
if (h_A == NULL || h_B == NULL || h_C == NULL) {
|
||||||
|
fprintf(stderr, "Failed to allocate host vectors!\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize the host input vectors
|
||||||
|
for (int i = 0; i < numElements; ++i) {
|
||||||
|
h_A[i] = rand() / static_cast<float>(RAND_MAX);
|
||||||
|
h_B[i] = rand() / static_cast<float>(RAND_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allocate the device input vector A
|
||||||
|
CUdeviceptr d_A;
|
||||||
|
checkCudaErrors(cuMemAlloc(&d_A, size));
|
||||||
|
|
||||||
|
// Allocate the device input vector B
|
||||||
|
CUdeviceptr d_B;
|
||||||
|
checkCudaErrors(cuMemAlloc(&d_B, size));
|
||||||
|
|
||||||
|
// Allocate the device output vector C
|
||||||
|
CUdeviceptr d_C;
|
||||||
|
checkCudaErrors(cuMemAlloc(&d_C, size));
|
||||||
|
|
||||||
|
// Copy the host input vectors A and B in host memory to the device input
|
||||||
|
// vectors in device memory
|
||||||
|
printf("Copy input data from the host memory to the CUDA device\n");
|
||||||
|
checkCudaErrors(cuMemcpyHtoD(d_A, h_A, size));
|
||||||
|
checkCudaErrors(cuMemcpyHtoD(d_B, h_B, size));
|
||||||
|
|
||||||
|
// Launch the Vector Add CUDA Kernel
|
||||||
|
int threadsPerBlock = 256;
|
||||||
|
int blocksPerGrid = (numElements + threadsPerBlock - 1) / threadsPerBlock;
|
||||||
|
printf("CUDA kernel launch with %d blocks of %d threads\n", blocksPerGrid,
|
||||||
|
threadsPerBlock);
|
||||||
|
dim3 cudaBlockSize(threadsPerBlock, 1, 1);
|
||||||
|
dim3 cudaGridSize(blocksPerGrid, 1, 1);
|
||||||
|
|
||||||
|
void *arr[] = {reinterpret_cast<void *>(&d_A), reinterpret_cast<void *>(&d_B),
|
||||||
|
reinterpret_cast<void *>(&d_C),
|
||||||
|
reinterpret_cast<void *>(&numElements)};
|
||||||
|
checkCudaErrors(cuLaunchKernel(kernel_addr, cudaGridSize.x, cudaGridSize.y,
|
||||||
|
cudaGridSize.z, /* grid dim */
|
||||||
|
cudaBlockSize.x, cudaBlockSize.y,
|
||||||
|
cudaBlockSize.z, /* block dim */
|
||||||
|
0, 0, /* shared mem, stream */
|
||||||
|
&arr[0], /* arguments */
|
||||||
|
0));
|
||||||
|
checkCudaErrors(cuCtxSynchronize());
|
||||||
|
|
||||||
|
// Copy the device result vector in device memory to the host result vector
|
||||||
|
// in host memory.
|
||||||
|
printf("Copy output data from the CUDA device to the host memory\n");
|
||||||
|
checkCudaErrors(cuMemcpyDtoH(h_C, d_C, size));
|
||||||
|
|
||||||
|
// Verify that the result vector is correct
|
||||||
|
for (int i = 0; i < numElements; ++i) {
|
||||||
|
if (fabs(h_A[i] + h_B[i] - h_C[i]) > 1e-5) {
|
||||||
|
fprintf(stderr, "Result verification failed at element %d!\n", i);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Test PASSED\n");
|
||||||
|
|
||||||
|
// Free device global memory
|
||||||
|
checkCudaErrors(cuMemFree(d_A));
|
||||||
|
checkCudaErrors(cuMemFree(d_B));
|
||||||
|
checkCudaErrors(cuMemFree(d_C));
|
||||||
|
|
||||||
|
// Free host memory
|
||||||
|
free(h_A);
|
||||||
|
free(h_B);
|
||||||
|
free(h_C);
|
||||||
|
|
||||||
|
printf("Done\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
42
Samples/vectorAdd_nvrtc/vectorAdd_kernel.cu
Normal file
42
Samples/vectorAdd_nvrtc/vectorAdd_kernel.cu
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CUDA Kernel Device code
|
||||||
|
*
|
||||||
|
* Computes the vector addition of A and B into C. The 3 vectors have the same
|
||||||
|
* number of elements numElements.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern "C" __global__ void vectorAdd(const float *A, const float *B, float *C,
|
||||||
|
int numElements) {
|
||||||
|
int i = blockDim.x * blockIdx.x + threadIdx.x;
|
||||||
|
|
||||||
|
if (i < numElements) {
|
||||||
|
C[i] = A[i] + B[i];
|
||||||
|
}
|
||||||
|
}
|
20
Samples/vectorAdd_nvrtc/vectorAdd_nvrtc_vs2010.sln
Normal file
20
Samples/vectorAdd_nvrtc/vectorAdd_nvrtc_vs2010.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||||
|
# Visual Studio 2010
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vectorAdd_nvrtc", "vectorAdd_nvrtc_vs2010.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
106
Samples/vectorAdd_nvrtc/vectorAdd_nvrtc_vs2010.vcxproj
Normal file
106
Samples/vectorAdd_nvrtc/vectorAdd_nvrtc_vs2010.vcxproj
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>vectorAdd_nvrtc_vs2010</RootNamespace>
|
||||||
|
<ProjectName>vectorAdd_nvrtc</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;$(CudaToolkitIncludeDir);$(CUDA_PATH)/include;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>cuda.lib;nvrtc.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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/vectorAdd_nvrtc.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration></CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="vectorAdd.cpp" />
|
||||||
|
<None Include="vectorAdd_kernel.cu" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/vectorAdd_nvrtc/vectorAdd_nvrtc_vs2012.sln
Normal file
20
Samples/vectorAdd_nvrtc/vectorAdd_nvrtc_vs2012.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2012
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vectorAdd_nvrtc", "vectorAdd_nvrtc_vs2012.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
107
Samples/vectorAdd_nvrtc/vectorAdd_nvrtc_vs2012.vcxproj
Normal file
107
Samples/vectorAdd_nvrtc/vectorAdd_nvrtc_vs2012.vcxproj
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>vectorAdd_nvrtc_vs2012</RootNamespace>
|
||||||
|
<ProjectName>vectorAdd_nvrtc</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;$(CudaToolkitIncludeDir);$(CUDA_PATH)/include;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>cuda.lib;nvrtc.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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/vectorAdd_nvrtc.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration></CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="vectorAdd.cpp" />
|
||||||
|
<None Include="vectorAdd_kernel.cu" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/vectorAdd_nvrtc/vectorAdd_nvrtc_vs2013.sln
Normal file
20
Samples/vectorAdd_nvrtc/vectorAdd_nvrtc_vs2013.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 13.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vectorAdd_nvrtc", "vectorAdd_nvrtc_vs2013.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
107
Samples/vectorAdd_nvrtc/vectorAdd_nvrtc_vs2013.vcxproj
Normal file
107
Samples/vectorAdd_nvrtc/vectorAdd_nvrtc_vs2013.vcxproj
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>vectorAdd_nvrtc_vs2013</RootNamespace>
|
||||||
|
<ProjectName>vectorAdd_nvrtc</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;$(CudaToolkitIncludeDir);$(CUDA_PATH)/include;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>cuda.lib;nvrtc.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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/vectorAdd_nvrtc.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration></CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="vectorAdd.cpp" />
|
||||||
|
<None Include="vectorAdd_kernel.cu" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/vectorAdd_nvrtc/vectorAdd_nvrtc_vs2015.sln
Normal file
20
Samples/vectorAdd_nvrtc/vectorAdd_nvrtc_vs2015.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 14.00
|
||||||
|
# Visual Studio 2015
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vectorAdd_nvrtc", "vectorAdd_nvrtc_vs2015.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
107
Samples/vectorAdd_nvrtc/vectorAdd_nvrtc_vs2015.vcxproj
Normal file
107
Samples/vectorAdd_nvrtc/vectorAdd_nvrtc_vs2015.vcxproj
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>vectorAdd_nvrtc_vs2015</RootNamespace>
|
||||||
|
<ProjectName>vectorAdd_nvrtc</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;$(CudaToolkitIncludeDir);$(CUDA_PATH)/include;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>cuda.lib;nvrtc.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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/vectorAdd_nvrtc.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration></CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="vectorAdd.cpp" />
|
||||||
|
<None Include="vectorAdd_kernel.cu" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
20
Samples/vectorAdd_nvrtc/vectorAdd_nvrtc_vs2017.sln
Normal file
20
Samples/vectorAdd_nvrtc/vectorAdd_nvrtc_vs2017.sln
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2017
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vectorAdd_nvrtc", "vectorAdd_nvrtc_vs2017.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
108
Samples/vectorAdd_nvrtc/vectorAdd_nvrtc_vs2017.vcxproj
Normal file
108
Samples/vectorAdd_nvrtc/vectorAdd_nvrtc_vs2017.vcxproj
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
||||||
|
<RootNamespace>vectorAdd_nvrtc_vs2017</RootNamespace>
|
||||||
|
<ProjectName>vectorAdd_nvrtc</ProjectName>
|
||||||
|
<CudaToolkitCustomDir />
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules />
|
||||||
|
<CodeAnalysisRuleAssemblies />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
||||||
|
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;$(CudaToolkitIncludeDir);$(CUDA_PATH)/include;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>cuda.lib;nvrtc.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)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
||||||
|
<OutputFile>$(OutDir)/vectorAdd_nvrtc.exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<CodeGeneration></CodeGeneration>
|
||||||
|
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<Include>./;../../Common</Include>
|
||||||
|
<Defines>WIN32</Defines>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MTd</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
<CudaCompile>
|
||||||
|
<Runtime>MT</Runtime>
|
||||||
|
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||||
|
</CudaCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="vectorAdd.cpp" />
|
||||||
|
<None Include="vectorAdd_kernel.cu" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(CUDAPropsPath)\CUDA 9.2.targets" />
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
287
Samples/warpAggregatedAtomicsCG/Makefile
Normal file
287
Samples/warpAggregatedAtomicsCG/Makefile
Normal file
|
@ -0,0 +1,287 @@
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Copyright 1993-2015 NVIDIA Corporation. All rights reserved.
|
||||||
|
#
|
||||||
|
# NOTICE TO USER:
|
||||||
|
#
|
||||||
|
# This source code is subject to NVIDIA ownership rights under U.S. and
|
||||||
|
# international Copyright laws.
|
||||||
|
#
|
||||||
|
# NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
|
||||||
|
# CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
|
||||||
|
# IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
# REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
# MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
# IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
||||||
|
# OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||||
|
# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||||
|
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|
||||||
|
# OR PERFORMANCE OF THIS SOURCE CODE.
|
||||||
|
#
|
||||||
|
# U.S. Government End Users. This source code is a "commercial item" as
|
||||||
|
# that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
|
||||||
|
# "commercial computer software" and "commercial computer software
|
||||||
|
# documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
|
||||||
|
# and is provided to the U.S. Government only as a commercial end item.
|
||||||
|
# Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
|
||||||
|
# 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
|
||||||
|
# source code with only those rights set forth herein.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Makefile project only supported on Mac OS X and Linux Platforms)
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Location of the CUDA Toolkit
|
||||||
|
CUDA_PATH ?= /usr/local/cuda
|
||||||
|
|
||||||
|
##############################
|
||||||
|
# start deprecated interface #
|
||||||
|
##############################
|
||||||
|
ifeq ($(x86_64),1)
|
||||||
|
$(info WARNING - x86_64 variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=x86_64 instead)
|
||||||
|
TARGET_ARCH ?= x86_64
|
||||||
|
endif
|
||||||
|
ifeq ($(ARMv7),1)
|
||||||
|
$(info WARNING - ARMv7 variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=armv7l instead)
|
||||||
|
TARGET_ARCH ?= armv7l
|
||||||
|
endif
|
||||||
|
ifeq ($(aarch64),1)
|
||||||
|
$(info WARNING - aarch64 variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=aarch64 instead)
|
||||||
|
TARGET_ARCH ?= aarch64
|
||||||
|
endif
|
||||||
|
ifeq ($(ppc64le),1)
|
||||||
|
$(info WARNING - ppc64le variable has been deprecated)
|
||||||
|
$(info WARNING - please use TARGET_ARCH=ppc64le instead)
|
||||||
|
TARGET_ARCH ?= ppc64le
|
||||||
|
endif
|
||||||
|
ifneq ($(GCC),)
|
||||||
|
$(info WARNING - GCC variable has been deprecated)
|
||||||
|
$(info WARNING - please use HOST_COMPILER=$(GCC) instead)
|
||||||
|
HOST_COMPILER ?= $(GCC)
|
||||||
|
endif
|
||||||
|
ifneq ($(abi),)
|
||||||
|
$(error ERROR - abi variable has been removed)
|
||||||
|
endif
|
||||||
|
############################
|
||||||
|
# end deprecated interface #
|
||||||
|
############################
|
||||||
|
|
||||||
|
# architecture
|
||||||
|
HOST_ARCH := $(shell uname -m)
|
||||||
|
TARGET_ARCH ?= $(HOST_ARCH)
|
||||||
|
ifneq (,$(filter $(TARGET_ARCH),x86_64 aarch64 ppc64le armv7l))
|
||||||
|
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifneq (,$(filter $(TARGET_ARCH),x86_64 aarch64 ppc64le))
|
||||||
|
TARGET_SIZE := 64
|
||||||
|
else ifneq (,$(filter $(TARGET_ARCH),armv7l))
|
||||||
|
TARGET_SIZE := 32
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
TARGET_SIZE := $(shell getconf LONG_BIT)
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
$(error ERROR - unsupported value $(TARGET_ARCH) for TARGET_ARCH!)
|
||||||
|
endif
|
||||||
|
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifeq (,$(filter $(HOST_ARCH)-$(TARGET_ARCH),aarch64-armv7l x86_64-armv7l x86_64-aarch64 x86_64-ppc64le))
|
||||||
|
$(error ERROR - cross compiling from $(HOST_ARCH) to $(TARGET_ARCH) is not supported!)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# When on native aarch64 system with userspace of 32-bit, change TARGET_ARCH to armv7l
|
||||||
|
ifeq ($(HOST_ARCH)-$(TARGET_ARCH)-$(TARGET_SIZE),aarch64-aarch64-32)
|
||||||
|
TARGET_ARCH = armv7l
|
||||||
|
endif
|
||||||
|
|
||||||
|
# operating system
|
||||||
|
HOST_OS := $(shell uname -s 2>/dev/null | tr "[:upper:]" "[:lower:]")
|
||||||
|
TARGET_OS ?= $(HOST_OS)
|
||||||
|
ifeq (,$(filter $(TARGET_OS),linux darwin qnx android))
|
||||||
|
$(error ERROR - unsupported value $(TARGET_OS) for TARGET_OS!)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# host compiler
|
||||||
|
ifeq ($(TARGET_OS),darwin)
|
||||||
|
ifeq ($(shell expr `xcodebuild -version | grep -i xcode | awk '{print $$2}' | cut -d'.' -f1` \>= 5),1)
|
||||||
|
HOST_COMPILER ?= clang++
|
||||||
|
endif
|
||||||
|
else ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifeq ($(HOST_ARCH)-$(TARGET_ARCH),x86_64-armv7l)
|
||||||
|
ifeq ($(TARGET_OS),linux)
|
||||||
|
HOST_COMPILER ?= arm-linux-gnueabihf-g++
|
||||||
|
else ifeq ($(TARGET_OS),qnx)
|
||||||
|
ifeq ($(QNX_HOST),)
|
||||||
|
$(error ERROR - QNX_HOST must be passed to the QNX host toolchain)
|
||||||
|
endif
|
||||||
|
ifeq ($(QNX_TARGET),)
|
||||||
|
$(error ERROR - QNX_TARGET must be passed to the QNX target toolchain)
|
||||||
|
endif
|
||||||
|
export QNX_HOST
|
||||||
|
export QNX_TARGET
|
||||||
|
HOST_COMPILER ?= $(QNX_HOST)/usr/bin/arm-unknown-nto-qnx6.6.0eabi-g++
|
||||||
|
else ifeq ($(TARGET_OS),android)
|
||||||
|
HOST_COMPILER ?= arm-linux-androideabi-g++
|
||||||
|
endif
|
||||||
|
else ifeq ($(TARGET_ARCH),aarch64)
|
||||||
|
ifeq ($(TARGET_OS), linux)
|
||||||
|
HOST_COMPILER ?= aarch64-linux-gnu-g++
|
||||||
|
else ifeq ($(TARGET_OS),qnx)
|
||||||
|
ifeq ($(QNX_HOST),)
|
||||||
|
$(error ERROR - QNX_HOST must be passed to the QNX host toolchain)
|
||||||
|
endif
|
||||||
|
ifeq ($(QNX_TARGET),)
|
||||||
|
$(error ERROR - QNX_TARGET must be passed to the QNX target toolchain)
|
||||||
|
endif
|
||||||
|
export QNX_HOST
|
||||||
|
export QNX_TARGET
|
||||||
|
HOST_COMPILER ?= $(QNX_HOST)/usr/bin/aarch64-unknown-nto-qnx7.0.0-g++
|
||||||
|
else ifeq ($(TARGET_OS), android)
|
||||||
|
HOST_COMPILER ?= aarch64-linux-android-g++
|
||||||
|
endif
|
||||||
|
else ifeq ($(TARGET_ARCH),ppc64le)
|
||||||
|
HOST_COMPILER ?= powerpc64le-linux-gnu-g++
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
HOST_COMPILER ?= g++
|
||||||
|
NVCC := $(CUDA_PATH)/bin/nvcc -ccbin $(HOST_COMPILER)
|
||||||
|
|
||||||
|
# internal flags
|
||||||
|
NVCCFLAGS := -m${TARGET_SIZE}
|
||||||
|
CCFLAGS :=
|
||||||
|
LDFLAGS :=
|
||||||
|
|
||||||
|
# build flags
|
||||||
|
ifeq ($(TARGET_OS),darwin)
|
||||||
|
LDFLAGS += -rpath $(CUDA_PATH)/lib
|
||||||
|
CCFLAGS += -arch $(HOST_ARCH)
|
||||||
|
else ifeq ($(HOST_ARCH)-$(TARGET_ARCH)-$(TARGET_OS),x86_64-armv7l-linux)
|
||||||
|
LDFLAGS += --dynamic-linker=/lib/ld-linux-armhf.so.3
|
||||||
|
CCFLAGS += -mfloat-abi=hard
|
||||||
|
else ifeq ($(TARGET_OS),android)
|
||||||
|
LDFLAGS += -pie
|
||||||
|
CCFLAGS += -fpie -fpic -fexceptions
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
||||||
|
ifneq ($(TARGET_FS),)
|
||||||
|
GCCVERSIONLTEQ46 := $(shell expr `$(HOST_COMPILER) -dumpversion` \<= 4.6)
|
||||||
|
ifeq ($(GCCVERSIONLTEQ46),1)
|
||||||
|
CCFLAGS += --sysroot=$(TARGET_FS)
|
||||||
|
endif
|
||||||
|
LDFLAGS += --sysroot=$(TARGET_FS)
|
||||||
|
LDFLAGS += -rpath-link=$(TARGET_FS)/lib
|
||||||
|
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib
|
||||||
|
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib/arm-linux-gnueabihf
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_OS),qnx)
|
||||||
|
CCFLAGS += -DWIN_INTERFACE_CUSTOM
|
||||||
|
LDFLAGS += -lsocket
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Install directory of different arch
|
||||||
|
CUDA_INSTALL_TARGET_DIR :=
|
||||||
|
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/armv7-linux-gnueabihf/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-linux)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/aarch64-linux/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-android)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/armv7-linux-androideabi/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-android)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/aarch64-linux-androideabi/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-qnx)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/ARMv7-linux-QNX/
|
||||||
|
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-qnx)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/aarch64-qnx/
|
||||||
|
else ifeq ($(TARGET_ARCH),ppc64le)
|
||||||
|
CUDA_INSTALL_TARGET_DIR = targets/ppc64le-linux/
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Debug build flags
|
||||||
|
ifeq ($(dbg),1)
|
||||||
|
NVCCFLAGS += -g -G
|
||||||
|
BUILD_TYPE := debug
|
||||||
|
else
|
||||||
|
BUILD_TYPE := release
|
||||||
|
endif
|
||||||
|
|
||||||
|
ALL_CCFLAGS :=
|
||||||
|
ALL_CCFLAGS += $(NVCCFLAGS)
|
||||||
|
ALL_CCFLAGS += $(EXTRA_NVCCFLAGS)
|
||||||
|
ALL_CCFLAGS += $(addprefix -Xcompiler ,$(CCFLAGS))
|
||||||
|
ALL_CCFLAGS += $(addprefix -Xcompiler ,$(EXTRA_CCFLAGS))
|
||||||
|
|
||||||
|
SAMPLE_ENABLED := 1
|
||||||
|
|
||||||
|
ALL_LDFLAGS :=
|
||||||
|
ALL_LDFLAGS += $(ALL_CCFLAGS)
|
||||||
|
ALL_LDFLAGS += $(addprefix -Xlinker ,$(LDFLAGS))
|
||||||
|
ALL_LDFLAGS += $(addprefix -Xlinker ,$(EXTRA_LDFLAGS))
|
||||||
|
|
||||||
|
# Common includes and paths for CUDA
|
||||||
|
INCLUDES := -I../../Common
|
||||||
|
LIBRARIES :=
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Gencode arguments
|
||||||
|
SMS ?= 30 35 37 50 52 60 61 70
|
||||||
|
|
||||||
|
ifeq ($(SMS),)
|
||||||
|
$(info >>> WARNING - no SM architectures have been specified - waiving sample <<<)
|
||||||
|
SAMPLE_ENABLED := 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(GENCODE_FLAGS),)
|
||||||
|
# Generate SASS code for each SM architecture listed in $(SMS)
|
||||||
|
$(foreach sm,$(SMS),$(eval GENCODE_FLAGS += -gencode arch=compute_$(sm),code=sm_$(sm)))
|
||||||
|
|
||||||
|
# Generate PTX code from the highest SM architecture in $(SMS) to guarantee forward-compatibility
|
||||||
|
HIGHEST_SM := $(lastword $(sort $(SMS)))
|
||||||
|
ifneq ($(HIGHEST_SM),)
|
||||||
|
GENCODE_FLAGS += -gencode arch=compute_$(HIGHEST_SM),code=compute_$(HIGHEST_SM)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(SAMPLE_ENABLED),0)
|
||||||
|
EXEC ?= @echo "[@]"
|
||||||
|
endif
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Target rules
|
||||||
|
all: build
|
||||||
|
|
||||||
|
build: warpAggregatedAtomicsCG
|
||||||
|
|
||||||
|
check.deps:
|
||||||
|
ifeq ($(SAMPLE_ENABLED),0)
|
||||||
|
@echo "Sample will be waived due to the above missing dependencies"
|
||||||
|
else
|
||||||
|
@echo "Sample is ready - all dependencies have been met"
|
||||||
|
endif
|
||||||
|
|
||||||
|
warpAggregatedAtomicsCG.o:warpAggregatedAtomicsCG.cu
|
||||||
|
$(EXEC) $(NVCC) $(INCLUDES) $(ALL_CCFLAGS) $(GENCODE_FLAGS) -o $@ -c $<
|
||||||
|
|
||||||
|
warpAggregatedAtomicsCG: warpAggregatedAtomicsCG.o
|
||||||
|
$(EXEC) $(NVCC) $(ALL_LDFLAGS) $(GENCODE_FLAGS) -o $@ $+ $(LIBRARIES)
|
||||||
|
$(EXEC) mkdir -p ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
||||||
|
$(EXEC) cp $@ ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
||||||
|
|
||||||
|
run: build
|
||||||
|
$(EXEC) ./warpAggregatedAtomicsCG
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f warpAggregatedAtomicsCG warpAggregatedAtomicsCG.o
|
||||||
|
rm -rf ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)/warpAggregatedAtomicsCG
|
||||||
|
|
||||||
|
clobber: clean
|
64
Samples/warpAggregatedAtomicsCG/NsightEclipse.xml
Normal file
64
Samples/warpAggregatedAtomicsCG/NsightEclipse.xml
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE entry SYSTEM "SamplesInfo.dtd">
|
||||||
|
<entry>
|
||||||
|
<name>warpAggregatedAtomicsCG</name>
|
||||||
|
<description><![CDATA[This sample demonstrates how using Cooperative Groups (CG) to perform warp aggregated atomics, a useful technique to improve performance when many threads atomically add to a single counter.]]></description>
|
||||||
|
<includepaths>
|
||||||
|
<path>./</path>
|
||||||
|
<path>../</path>
|
||||||
|
<path>../../common/inc</path>
|
||||||
|
</includepaths>
|
||||||
|
<keyconcepts>
|
||||||
|
<concept level="basic">Cooperative Groups</concept>
|
||||||
|
<concept level="basic">Atomic Intrinsics</concept>
|
||||||
|
</keyconcepts>
|
||||||
|
<keywords>
|
||||||
|
<keyword>GPGPU</keyword>
|
||||||
|
<keyword>Cooperative Groups</keyword>
|
||||||
|
<keyword>Atomic</keyword>
|
||||||
|
</keywords>
|
||||||
|
<libraries>
|
||||||
|
</libraries>
|
||||||
|
<librarypaths>
|
||||||
|
</librarypaths>
|
||||||
|
<nsight_eclipse>true</nsight_eclipse>
|
||||||
|
<primary_file>warpAggregatedAtomicsCG.cu</primary_file>
|
||||||
|
<scopes>
|
||||||
|
<scope>1:CUDA Advanced Topics</scope>
|
||||||
|
</scopes>
|
||||||
|
<sm-arch>sm30</sm-arch>
|
||||||
|
<sm-arch>sm35</sm-arch>
|
||||||
|
<sm-arch>sm37</sm-arch>
|
||||||
|
<sm-arch>sm50</sm-arch>
|
||||||
|
<sm-arch>sm52</sm-arch>
|
||||||
|
<sm-arch>sm60</sm-arch>
|
||||||
|
<sm-arch>sm61</sm-arch>
|
||||||
|
<sm-arch>sm70</sm-arch>
|
||||||
|
<supported_envs>
|
||||||
|
<env>
|
||||||
|
<arch>x86_64</arch>
|
||||||
|
<platform>linux</platform>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<arch>ppc64le</arch>
|
||||||
|
<platform>linux</platform>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<arch>x86_64</arch>
|
||||||
|
<platform>macosx</platform>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<platform>windows7</platform>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<arch>arm</arch>
|
||||||
|
</env>
|
||||||
|
<env>
|
||||||
|
<arch>aarch64</arch>
|
||||||
|
</env>
|
||||||
|
</supported_envs>
|
||||||
|
<supported_sm_architectures>
|
||||||
|
<from>3.0</from>
|
||||||
|
</supported_sm_architectures>
|
||||||
|
<title>Warp Aggregated Atomics using Cooperative Groups</title>
|
||||||
|
</entry>
|
91
Samples/warpAggregatedAtomicsCG/README.md
Normal file
91
Samples/warpAggregatedAtomicsCG/README.md
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
# warpAggregatedAtomicsCG - Warp Aggregated Atomics using Cooperative Groups
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
This sample demonstrates how using Cooperative Groups (CG) to perform warp aggregated atomics, a useful technique to improve performance when many threads atomically add to a single counter.
|
||||||
|
|
||||||
|
## Key Concepts
|
||||||
|
|
||||||
|
Cooperative Groups, Atomic Intrinsics
|
||||||
|
|
||||||
|
## Supported SM Architectures
|
||||||
|
|
||||||
|
[SM 3.0 ](https://developer.nvidia.com/cuda-gpus) [SM 3.5 ](https://developer.nvidia.com/cuda-gpus) [SM 3.7 ](https://developer.nvidia.com/cuda-gpus) [SM 5.0 ](https://developer.nvidia.com/cuda-gpus) [SM 5.2 ](https://developer.nvidia.com/cuda-gpus) [SM 6.0 ](https://developer.nvidia.com/cuda-gpus) [SM 6.1 ](https://developer.nvidia.com/cuda-gpus) [SM 7.0 ](https://developer.nvidia.com/cuda-gpus)
|
||||||
|
|
||||||
|
## Supported OSes
|
||||||
|
|
||||||
|
Linux, Windows, MacOSX
|
||||||
|
|
||||||
|
## Supported CPU Architecture
|
||||||
|
|
||||||
|
x86_64, ppc64le, armv7l, aarch64
|
||||||
|
|
||||||
|
## CUDA APIs involved
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
Download and install the [CUDA Toolkit 9.2](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
|
||||||
|
|
||||||
|
## Build and Run
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
The Windows samples are built using the Visual Studio IDE. Solution files (.sln) are provided for each supported version of Visual Studio, using the format:
|
||||||
|
```
|
||||||
|
*_vs<version>.sln - for Visual Studio <version>
|
||||||
|
```
|
||||||
|
Each individual sample has its own set of solution files in its directory:
|
||||||
|
|
||||||
|
To build/examine all the samples at once, the complete solution files should be used. To build/examine a single sample, the individual sample solution files should be used.
|
||||||
|
> **Note:** Some samples require that the Microsoft DirectX SDK (June 2010 or newer) be installed and that the VC++ directory paths are properly set up (**Tools > Options...**). Check DirectX Dependencies section for details."
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
The Linux samples are built using makefiles. To use the makefiles, change the current directory to the sample directory you wish to build, and run make:
|
||||||
|
```
|
||||||
|
$ cd <sample_dir>
|
||||||
|
$ make
|
||||||
|
```
|
||||||
|
The samples makefiles can take advantage of certain options:
|
||||||
|
* **TARGET_ARCH=<arch>** - cross-compile targeting a specific architecture. Allowed architectures are x86_64, ppc64le, armv7l, aarch64.
|
||||||
|
By default, TARGET_ARCH is set to HOST_ARCH. On a x86_64 machine, not setting TARGET_ARCH is the equivalent of setting TARGET_ARCH=x86_64.<br/>
|
||||||
|
`$ make TARGET_ARCH=x86_64` <br/> `$ make TARGET_ARCH=ppc64le` <br/> `$ make TARGET_ARCH=armv7l` <br/> `$ make TARGET_ARCH=aarch64` <br/>
|
||||||
|
See [here](http://docs.nvidia.com/cuda/cuda-samples/index.html#cross-samples) for more details.
|
||||||
|
* **dbg=1** - build with debug symbols
|
||||||
|
```
|
||||||
|
$ make dbg=1
|
||||||
|
```
|
||||||
|
* **SMS="A B ..."** - override the SM architectures for which the sample will be built, where `"A B ..."` is a space-delimited list of SM architectures. For example, to generate SASS for SM 50 and SM 60, use `SMS="50 60"`.
|
||||||
|
```
|
||||||
|
$ make SMS="50 60"
|
||||||
|
```
|
||||||
|
|
||||||
|
* **HOST_COMPILER=<host_compiler>** - override the default g++ host compiler. See the [Linux Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements) for a list of supported host compilers.
|
||||||
|
```
|
||||||
|
$ make HOST_COMPILER=g++
|
||||||
|
```
|
||||||
|
|
||||||
|
### Mac
|
||||||
|
The Mac samples are built using makefiles. To use the makefiles, change directory into the sample directory you wish to build, and run make:
|
||||||
|
```
|
||||||
|
$ cd <sample_dir>
|
||||||
|
$ make
|
||||||
|
```
|
||||||
|
|
||||||
|
The samples makefiles can take advantage of certain options:
|
||||||
|
|
||||||
|
* **dbg=1** - build with debug symbols
|
||||||
|
```
|
||||||
|
$ make dbg=1
|
||||||
|
```
|
||||||
|
|
||||||
|
* **SMS="A B ..."** - override the SM architectures for which the sample will be built, where "A B ..." is a space-delimited list of SM architectures. For example, to generate SASS for SM 50 and SM 60, use SMS="50 60".
|
||||||
|
```
|
||||||
|
$ make SMS="A B ..."
|
||||||
|
```
|
||||||
|
|
||||||
|
* **HOST_COMPILER=<host_compiler>** - override the default clang host compiler. See the [Mac Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html#system-requirements) for a list of supported host compilers.
|
||||||
|
```
|
||||||
|
$ make HOST_COMPILER=clang
|
||||||
|
```
|
||||||
|
|
||||||
|
## References (for more details)
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user