Skip to content

Commit 08130dc

Browse files
author
bragadeesh
committed
adding error return to handle mismatched device usgae between BakePlan and EnqueueTransform
1 parent 3ed0dc3 commit 08130dc

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

src/include/clFFT.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ enum clfftStatus_
127127
CLFFT_VERSION_MISMATCH, /*!< Version conflict between client and library. */
128128
CLFFT_INVALID_PLAN, /*!< Requested plan could not be found. */
129129
CLFFT_DEVICE_NO_DOUBLE, /*!< Double precision not supported on this device. */
130+
CLFFT_DEVICE_MISMATCH, /*!< Attempt to run on a device using a plan baked for a different device. */
130131
CLFFT_ENDSTATUS /* This value will always be last, and marks the length of clfftStatus. */
131132
};
132133
typedef enum clfftStatus_ clfftStatus;

src/library/plan.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,9 @@ clfftStatus clfftBakePlan( clfftPlanHandle plHandle, cl_uint numQueues, cl_comma
494494
return CLFFT_SUCCESS;
495495
}
496496

497+
// Store the device for which we are baking
498+
clGetCommandQueueInfo(*commQueueFFT, CL_QUEUE_DEVICE, sizeof(cl_device_id), &fftPlan->bakeDevice, NULL);
499+
497500
//find product of lengths
498501
size_t pLength = 1;
499502
switch(fftPlan->dim)

src/library/plan.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ class FFTPlan
223223
size_t iDist, oDist;
224224
size_t batchsize;
225225

226+
// Note the device passed to BakePlan, assuming we are baking for one device
227+
// TODO, change this logic for handling multiple GPUs/devices
228+
cl_device_id bakeDevice;
229+
226230
// Devices that the user specified in the context passed to the create function
227231
std::vector< cl_device_id > devices;
228232

src/library/transform.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ clfftStatus clfftEnqueueTransform(
6363
OPENCL_V( clfftBakePlan( plHandle, numQueuesAndEvents, commQueues, NULL, NULL ), _T( "Failed to bake plan" ) );
6464
}
6565

66+
67+
// get the device information
68+
cl_device_id q_device;
69+
clGetCommandQueueInfo(*commQueues, CL_QUEUE_DEVICE, sizeof(cl_device_id), &q_device, NULL);
70+
71+
// verify if the current device is the same as the one used for baking the plan
72+
if(q_device != fftPlan->bakeDevice)
73+
return CLFFT_DEVICE_MISMATCH;
74+
75+
6676
if (fftPlan->inputLayout == CLFFT_REAL) dir = CLFFT_FORWARD;
6777
else if (fftPlan->outputLayout == CLFFT_REAL) dir = CLFFT_BACKWARD;
6878

0 commit comments

Comments
 (0)