Fix block dim and block number in droput

This commit is contained in:
Tomasz Dwojak 2017-02-13 10:17:21 +00:00
parent d1e90650dc
commit 1227d0bb31
2 changed files with 5 additions and 13 deletions

View File

@ -42,8 +42,10 @@ class DropoutGenerator {
void Generate(float* data, int n, float p) {
CURAND_CALL(curandGenerateUniform(generator_, data, n));
/* CUDA_CALL( gScalled<<<512, 512>>>(data, n, p) ); */
gScalled<<<512, 512>>>(data, n, p);
int numThreads = std::min(n, 512);
int numBlocks = n / numThreads + (n % numThreads != 0);
gScalled<<<numBlocks, numThreads>>>(data, n, p);
}
~DropoutGenerator() {

View File

@ -27,7 +27,7 @@ int main() {
int layers = 64;
std::cerr << "Number of elements in tensor: " << rows * cols * layers << std::endl;
int rep = 10;
int rep = 1000;
const float prob = 0.5f;
Tensor dropoutMatrix;
@ -40,16 +40,6 @@ int main() {
for (int i = 0; i < rep;++i) {
dropout.Generate(dropoutMatrix, prob);
cudaDeviceSynchronize();
std::vector<float> tmpVector(rows * cols * layers);
dropoutMatrix >> tmpVector;
std::cerr << dropoutMatrix->debug();
/* for (size_t i = 0; i < 30; ++i) std::cerr << tmpVector[i] << " "; */
/* std::cerr <<"| non-zero: "; */
/* int counter = 0; */
/* for (auto& v : tmpVector) counter += (v != 0.0f); */
/* std::cerr << counter << std::endl; */
}