64bit vs. 32bit floats

When I create an array of floats, each array member is 64 bits. In order to successfully transfer them to my card for use in CUBLAS, they appear to have to be 32 bits.

Is there a simple fix that doesn’t require building the whole thing with 32-bit architecture?

double = double precision, float = single precision. if you want to use doubles, compile with -arch sm_13 and make sure you have a GT200 (GTX 2xx, etc.).

sizeof(float) returns 8. That’s my problem. In the example projects, sizeof(float) returns 4.

Do the examples force 32-bit host architecture?

Where does sizeof(float) return 8? What compiler are you using and what settings? sizeof(float) should return 4 on x86 assuming no strange compiler magic.

GCC 4.1 (on Intel Core2) seems to have been the problem. GCC 4.3 fixed the ‘size of a float’ issue. I still have an inexplicable difficulty with:

cublasSetVector(1, sizeof(float), X, 1, x, 1);

It returns 11 (CUBLAS_STATUS_MAPPING_ERROR).

Using gdb, *X clearly = 1.0. x has been successfully allocated as an array of floats (with length much larger than 1). x has the value 0x3010000, and it has the value 0x0 before the cublas allocator is called:

status = cublasAlloc(Sesco1, sizeof(float), (void**)&x); //returns 0, Sesco1 is 224870.

The only thing I can think of is that maybe cublas is choking on it being a 64-bit pointer? I don’t get why it wouldn’t do that in the example projects, though.

I don’t think gcc 4.1 is broken (I’ve used it before without this problem). There’s something very wrong with your configuration, I think, and gcc 4.3 is not officially supported yet.

CUBLAS doesn’t care what pointer sizes you have; it will use whatever the host architecture gives you.

Some of my code now works!

x is global within the file.

int allocateResources() { //This function will execute just fine with no cublas or host errors.
float GAH[995226];
int k;
for(k=0;k<995
226;k++) GAH[k]=1.0;
status = cublasAlloc(maxSamplesesco1, sizeof(float), (void**)&x); //maxSamplesesco1=995226
status = cublasSetVector(maxSamples
esco1, sizeof(float), GAH, 1, x, 1);
}

All good so far. Now, with my array allocated and a file-global pointers to it, I move on to a new function call in the same file:

int putStuffIn() {
float GAH[995226];
int k;
for(k=0;k<995
226;k++) GAH[k]=1.0;
status = cublasSetVector(maxSamples*esco1, sizeof(float), GAH, 1, x, 1); //Returns 11 (mapping error).
}

x is still the value it was assigned earlier and execution remains in the same thread. Is there a scope issue here?

Edit: It has nothing to do with the variable name x…renaming it xblah does nothing. This is a multithreaded application with OpenGL calls happening on the same card concurrently…if that matters. Testing the same code in a single-threaded context ( int main(){allocateResources(); putStuffIn(); return 0;} ) works just fine. Also, it can free x, just not write to it…which makes no sense if an OpenGL collision is at fault.

Is there some sort of cleanup? Can pointers go stale?