Skip to content

Instantly share code, notes, and snippets.

@TangerineCat
Created June 5, 2015 23:38
Show Gist options
  • Save TangerineCat/e04dfa9f03d410a33a4b to your computer and use it in GitHub Desktop.
Save TangerineCat/e04dfa9f03d410a33a4b to your computer and use it in GitHub Desktop.
while(getline(fbase, line))
{
cudaEventSynchronize(finishedMemcpyEvent);
if (!(fbase >> user >> movie >> day >> rating)){
data_idx++;
continue;
}
// process the line. Store indices instead of values
buffer[data_idx % batchsize] = DataPoint(user - 1, movie - 1, rating);
if((data_idx % batchsize == batchsize - 1)){
cudaMemcpyAsync(d_data[i], inbuffers[i],
batchsize * sizeof(DataPoint), cudaMemcpyHostToDevice, s[i]);
cudaEventRecord(finishedMemcpyEvent, s[i]);
// RUN KERNEL
cudaTrain(d_data[i], pack,
batchsize, nfactors, s[i]);
i = (i + 1) % nstreams;
if(VERBOSE)
printf("Batch %6d finished\n", data_idx/batchsize);
buffer = inbuffers[i];
}
data_idx++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment