Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize random seed during CUDA initialization. #45

Merged
merged 1 commit into from Sep 25, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion init.c
Expand Up @@ -39,7 +39,6 @@ static int cutorch_setDevice(lua_State *L)
{
int device = (int)luaL_checknumber(L, 1)-1;
THCudaCheck(cudaSetDevice(device));
THCRandom_manualSeed(THCRandom_initialSeed());
return 0;
}

Expand Down
31 changes: 15 additions & 16 deletions lib/THC/THCGeneral.c
@@ -1,5 +1,6 @@
#include "THCGeneral.h"
#include "TH.h"
#include "THCTensorRandom.h"

void THCudaInit(void)
{
Expand All @@ -9,28 +10,26 @@ void THCudaInit(void)
int count = 0;
THCudaCheck(cudaGetDeviceCount(&count));

if(count>1)
{
int device = 0;
THCudaCheck(cudaGetDevice(&device));
int device = 0;
THCudaCheck(cudaGetDevice(&device));

int i,j;
for(i=0; i < count; ++i)
int i,j;
for(i=0; i < count; ++i)
{
THCudaCheck(cudaSetDevice(i));
THCRandom_manualSeed(THCRandom_initialSeed());
for (j=0; j < count; ++j)
{
THCudaCheck(cudaSetDevice(i));
for (j=0; j < count; ++j)
if(i != j)
{
if(i != j)
{
int can = 0;
THCudaCheck(cudaDeviceCanAccessPeer(&can, i, j));
if(can)
THCudaCheck(cudaDeviceEnablePeerAccess(j, 0));
}
int can = 0;
THCudaCheck(cudaDeviceCanAccessPeer(&can, i, j));
if(can)
THCudaCheck(cudaDeviceEnablePeerAccess(j, 0));
}
}
THCudaCheck(cudaSetDevice(device));
}
THCudaCheck(cudaSetDevice(device));
}

void THCudaShutdown(void)
Expand Down