getVal seems to work

This commit is contained in:
Robin committed 2024-12-21 14:17:39 +01:00
1 parent 4b06f289b8
commit a7ad248c38
6 files changed
+39 -50

No files matched your search

+17 -10
View File
@@ -1,12 +1,19 @@
#include "fielddata.h"
// __device__ float getVal(
// const FieldMetadata &md,
// const FieldData &d,
// const size_t &timeInd,
// const size_t &lonInd,
// const size_t &latInd,
// const size_t &levInd
// ) {
// return d.valArrays[0][timeInd];
// }
__device__ float getVal(
const FieldMetadata &md,
const FieldData &d,
const size_t &timeInd,
const size_t &levInd,
const size_t &latInd,
const size_t &lonInd
) {
size_t sizeSpatialData = md.widthSize*md.heightSize*md.depthSize;
size_t size2DMapData = md.widthSize*md.heightSize;
return d.valArrays[0][
timeInd*sizeSpatialData
+ levInd*size2DMapData
+ latInd*md.widthSize
+ lonInd
];
}
+8 -8
View File
@@ -32,13 +32,13 @@ struct FieldData {
using FieldData = FieldData;
// __device__ float getVal(
// const FieldMetadata &md,
// const FieldData &d,
// const size_t &timeInd,
// const size_t &lonInd,
// const size_t &latInd,
// const size_t &levInd
// );
extern __device__ float getVal(
const FieldMetadata &md,
const FieldData &d,
const size_t &timeInd,
const size_t &levInd,
const size_t &latInd,
const size_t &lonInd
);
#endif //FIELDDATA_H
-4
View File
@@ -21,8 +21,6 @@ path(path), variableName(variableName) {
readAndAllocateAxis<double>(&fmd->levs, &fmd->depthSize, vars.find("lev")->second);
}
FieldData GPUBuffer::nextFieldData() {
NcFile data(path, NcFile::read);
@@ -47,8 +45,6 @@ FieldData GPUBuffer::nextFieldData() {
var.getVar(h_array);
// Copy data to device
// float *d_array;
cudaError_t status = cudaMalloc(&fd.valArrays[0], sizeof(float)*length);
if (status != cudaSuccess)
cout << "Error allocating memory: " << status << "\n";
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.