-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Bensuperpc <[email protected]>
- Loading branch information
1 parent
ad2333e
commit 35c5b7c
Showing
6 changed files
with
44 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "generateString.cuh" | ||
|
||
__device__ void generateStringKernel(uint8_t* array, uint64_t n, uint64_t* terminatorIndex) { | ||
// If n > 27 | ||
uint64_t i = 0; | ||
while (n > 0) { | ||
array[i] = alpha[(--n) % 26]; | ||
n /= 26; | ||
++i; | ||
} | ||
*terminatorIndex = i; | ||
} | ||
|
||
__device__ void generateStringKernelV2(uint8_t* array, uint64_t n, uint64_t* terminatorIndex) { | ||
uint64_t i = 0; | ||
do { | ||
array[i++] = alpha[--n % 26]; | ||
n /= 26; | ||
} while (n > 0); | ||
|
||
*terminatorIndex = i; | ||
} | ||
|
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,13 @@ | ||
#ifndef CUDA_GENERATESTRING_CUH | ||
#define CUDA_GENERATESTRING_CUH | ||
|
||
#include <cuda.h> | ||
#include <cuda_runtime.h> | ||
#include <stdio.h> | ||
|
||
__device__ void generateStringKernel(uint8_t* array, uint64_t n, uint64_t* terminatorIndex); | ||
__device__ void generateStringKernelV2(uint8_t* array, uint64_t n, uint64_t* terminatorIndex); | ||
|
||
__device__ const uint8_t alpha[27] = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"}; | ||
|
||
#endif |
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