-
Notifications
You must be signed in to change notification settings - Fork 542
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
89 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <cuda_runtime.h> | ||
#include <nvfunctional> | ||
#include "cudapp.cuh" | ||
|
||
using namespace cudapp; | ||
|
||
extern "C" __global__ void kernel(int x) { | ||
printf("内核参数 x = %d\n", x); | ||
printf("线程编号 (%d, %d)\n", blockIdx.x, threadIdx.x); | ||
} | ||
|
||
int main() { | ||
int x = 42; | ||
kernel<<<3, 4, 0, 0>>>(x); | ||
|
||
void *args[] = {&x}; | ||
CHECK_CUDA(cudaLaunchKernel((const void *)kernel, dim3(3), dim3(4), args, 0, 0)); | ||
|
||
cudaLaunchConfig_t cfg{}; | ||
cfg.blockDim = dim3(3); | ||
cfg.gridDim = dim3(4); | ||
cfg.dynamicSmemBytes = 0; | ||
cfg.stream = 0; | ||
cfg.attrs = nullptr; | ||
cfg.numAttrs = 0; | ||
CHECK_CUDA(cudaLaunchKernelEx(&cfg, kernel, x)); | ||
|
||
const char *name; | ||
CHECK_CUDA(cudaFuncGetName(&name, (const void *)kernel)); | ||
|
||
CudaStream::nullStream().join(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
#define TINYBENCH_IMPL_MAIN | ||
#define TINYBENCH_IMPL | ||
#include "tinybench.hpp" | ||
|
||
[[gnu::weak]] int main() { | ||
std::unique_ptr<tinybench::Reporter> rep(tinybench::makeMultipleReporter({tinybench::makeConsoleReporter()})); | ||
rep->run_all(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters