-
Notifications
You must be signed in to change notification settings - Fork 338
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
1 parent
c4ddd6b
commit 8bce353
Showing
4 changed files
with
15 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,6 @@ __pycache__ | |
runs | ||
build | ||
checkpoints | ||
*.prof | ||
.lvimrc | ||
.vimtags |
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 |
---|---|---|
@@ -1,24 +1,12 @@ | ||
#ifndef _CUDA_UTILS_H | ||
#define _CUDA_UTILS_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
#include <cmath> | ||
|
||
inline int opt_n_threads(int work_size) { | ||
unsigned int n_threads = work_size; | ||
n_threads--; | ||
n_threads |= n_threads >> 1; | ||
n_threads |= n_threads >> 2; | ||
n_threads |= n_threads >> 4; | ||
n_threads |= n_threads >> 8; | ||
n_threads |= n_threads >> 16; | ||
n_threads++; | ||
const int pow_2 = std::log(static_cast<double>(work_size)) / std::log(2.0); | ||
|
||
return max(min(n_threads / 2, 512), 2); | ||
return max(min(1 << pow_2, 512), 32); | ||
} | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#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