Hello all. Forgive me if I do not post any real code snippets just yet. This is my first post, so I'm just mostly saying hello for now. Until I get a chance to get a look at the code I am working on, and get back to you..can anyone post any tips on optimizing C code when there are a lot of cache misses?
I am new to C code, so I'll give the basic run down. The code I am working on speeding up sends array references to a function, does some calculations on them. This obviously has its own set of loops that I think is as fast as it is going to get. Wrapping the call to that function is a loop that is pulling the arrays out of a structure. The setup of trhis is kind of funny to me, as it seems like the structure has been "wrapped" by typedef statements to declare it as a pointer type and avoid the struct reference. The structure's real data is passed back as void from some function, cast to the correct type, and assigned to the pointer type of the structure. I'm not entirely sure i have that interpretation correct.
ex:
So this is all psuedo-codeish but like I said, I am new to C. I feel like somewhere in all those pointers, there is something slowing me down and causing those misses, but not really sure where to start. Reading the profling tool I am using can only tell me so much. TIACode:typedef struct { double *AA } typeName
followed by something like
typedef typeName *typeNamep;
/*then declaring an object type */
typeNamep theObject;
theObject = (typeNamep) some_function_returning_data();
//then finally setting some arrays up like
loop:
AA = theObject->AA; // this line has a lot of samples in my profiler, order of magnitude more than the others
//then passing AA to a function
arrayOperations(AA);
endloop