Skip to content

Commit

Permalink
change the way of memory allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
buensons committed Dec 13, 2020
1 parent 69e5d09 commit 2ff3df7
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/TimeSeriesPredictor.cu
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ TimeSeriesPredictor::~TimeSeriesPredictor() {
gpuErrchk(cudaFree(this->mapWeightsGpu));
gpuErrchk(cudaFree(this->dataGpu));
gpuErrchk(cudaFree(this->mapInputGpu));
free(this->fitnessHost);
delete [] this->fitnessHost;
}

auto TimeSeriesPredictor::prepareGpuMemory() -> void {
Expand All @@ -27,9 +27,7 @@ auto TimeSeriesPredictor::prepareGpuMemory() -> void {
gpuErrchk(cudaMalloc((void**)&this->mapWeightsGpu, this->populationSize * this->numberOfNodes * this->numberOfNodes * sizeof(float)));
gpuErrchk(cudaMalloc((void**)&this->mapInputGpu, this->populationSize * this->numberOfNodes * sizeof(float)));

if((this->fitnessHost = (float *)malloc(this->populationSize * sizeof(float))) == NULL) {
std::cerr << "malloc\n";
}
this->fitnessHost = new float[this->populationSize];
gpuErrchk(cudaMemcpy(this->dataGpu, this->data.data(), this->data.size() * sizeof(float), cudaMemcpyHostToDevice));
}

Expand Down

0 comments on commit 2ff3df7

Please sign in to comment.