Beispiel #1
0
void THCState_setCurrentSparseHandleIndex(THCState *state, int handle)
{
  if (handle > state->numUserSparseHandles || handle <= 0)
  {
    THError("%d is not a valid handle, valid range is: (1, %d)",
            handle, state->numUserSparseHandles);
  }
  THCThreadLocal_set(state->currentPerDeviceSparseHandle, (void*)(intptr_t)handle);
}
Beispiel #2
0
static THCStream* THCState_getStreamOnDevice(THCState* state, int device)
{
  THCThreadLocal local = state->currentStreams[device];
  THCStream* stream = (THCStream*)THCThreadLocal_get(local);
  if (!stream) {
    stream = THCStream_defaultStream(device);
    THCStream_retain(stream);
    THCThreadLocal_set(local, stream);
  }
  return stream;
}
Beispiel #3
0
static void THCState_setStreamOnDevice(THCState *state, int device, THCStream *stream)
{
  THAssert(stream);
  if (stream->device != device) {
    THError("invalid stream; expected stream for device %d, but was on %d",
        device, stream->device);
  }
  THCStream_retain(stream);
  THCThreadLocal local = state->currentStreams[device];
  THCStream_free((THCStream*)THCThreadLocal_get(local));
  THCThreadLocal_set(local, stream);
}
Beispiel #4
0
void THCState_setCurrentStreamIndex(THCState *state, int stream)
{
  THCThreadLocal_set(state->currentPerDeviceStream, (void*)(intptr_t)stream);
}