I don't see much optimisation options.
You are already using a lookup table and the code should not consume much time when dim is small. Rewriting it in assembler will be probably not faster because modern compilers will generate effective code (you may tell your compiler to generate an assembly output to check this).
When using the popcnt instruction and your data are always a multiple of 2 or 4 (or 8 with 64-bit builds), you can reduce the number of loop executions by performing the operation with 16/32/64 bits.
I wouldn't recommend assembly, unless platform portability is not a concern. A relatively easier option would be to apply a Duff's device to this loop. Unrolling the loop can provide performance boost. However, unless this is, say DSP code that has to run over and over again its probably not worthwhile and the effects wont be noticable.
If you are linking for 64bits the entry point for dll should be _DllMainCRTStartup (undecorated entry point). If you get this error probably there is a error in linker switches because it seems that you are trying to use 64 bits objects in a 32bits link.
It is not very clear in which part of your project you're getting the error: compiling the console exe or one of the DLL?
A very simple and realistically non-worthwhile implementation is simple. Your malloc calls new with an byte array. Then your free, which you would also implement would use delete to delete the array.
If you want a learning experience however then you should do the following in the specified order.
1. Learn what stack and list are and how to implement them.
2. Specifically learn how to implement them using sequential memory and not just pointers.
3. Learn how malloc is generally implemented. You will need substantial understanding of 1/2 to understand this.
4. Implement your own heap management. (Which you will understand after doing 1/2/3.)
There are no limitations to support different types of databases in one application. The application wizard only prepares the project to support a specific database interface. Support for other interfaces can be added later manually.
Create two new empty projects with support for different database interfaces. Then choose one as your project and add the necessary definitions from the created source files of the other project by comparing the files.
Thanks for reply.
Since wizard can relief my work. I just think is it possible to select both ODBC and OLEDB by using wizard.
If it is not possible, I have to implement the code myself.
That's hell a lot of work
Note that reading even a trivial excel file in an application can be a difficult task.
Once you have read the data the user interface and writing to a database is easier because there are more sources that one can learn from.
But as you can see this is much more code and it is insecure without checking for buffer overflows (which adds more code).
If you don't need the data to be in text format (e.g. only loaded by your application), it might be better to write the data to a binary file. That solves also the problem of inaccuracies when converting floating point values to text and back again later.
FILE *f = fopen(fileName, "wb");
fwrite(&newForce.x, sizeof(newForce.x), 1, f);
// Write other items here
Reading is then done in a similar way:
FILE *f = fopen(fileName, "rb");
fread(&newForce.x, sizeof(newForce.x), 1, f);
// Read other items here
Using the width specifier, all numbers will have the same width padded with blanks. For proper alignment of the decimal point you should also use the precision specifier and the flag specifier (use a space or minus). The final values to be used depend on the range of your values and the required precision. Assuming a range up to (but excluding) 100 and a precision of 2 fractional digits:
Precision = 2
Width = 1 (sign) + 2 (digits) + 1 (decimal point) + 2 (digits) = 6
The data i'm getting is of very large sample. I use a inbuilt thread class calls at very high frequency. Basically I want to reduce the sampling rate so that I'll get significant data with less samples..Do you have any idea how to create periodic thread with a fixed frequency?
Basically two functions one is for updating graphics and other for haptics rendering. Haptic rendering sampling rate is quite large compared to graphics. In the library I'm using there is a thread class basically gives priority to haptic and graphics rendering. But I'm not able to see any section in the code where they access system timing and setting sampling rate etc.
I'm thinking about assigning some condition inside data will be written into the file at a rate of 100 samples per second. There is an inbuilt precision clock with the library, so if I've I can get cpu time with precision clock , how can formulate a condition to write data at a rate 100Hz??
As far as I understood you have a haptic device which is some kind of hardware which generates data at a frequency defined by the hardware. If the library does not provide functions to set the sample rate, it is probably fixed. The thread is then activated when new data are available.
But again, without knowing the hardware and the library (which acesses the hardware specific driver), it is rather impossible to answer.
Do you want to write the data to a file with 100 Hz. This is probably too fast (especially when the file must be opened for each write). It again depends on your requirements (who is reading the file). If the data should be read by another process, you may use some kind of IPC (Inter Process Communication).
Windows has no high resolution timers. While it is possible to measure times with high resolution (QueryPerformanceCounter), the system timers have a resolution of about 10 ms by default and can be tweaked down to 1 ms.
Just call Sleep() with a time out value of 1000 / frequency[Hz].
A better implememntation would use WaitForSingleObject() with the same time out value and a handle to a terminate thread event so that you can terminate the thread:
UINT worker_thread_func(LPVOID pParam)
// pParam is usually a pointer to a C++ class to which this thread belongs
// that is passed when creating the thread.
// Cast the pointer to get access to member vars.
MyClass *pThis = (MyClass *)pParam;
HANDLE hKillEvent = pThis->m_hKillEvent;
if (WAIT_OBJECT_0 == WaitForSingleObject(hKillEvent, TIME_OUT_VAL))
// Perform periodic task here
I still didn't get idea of using WaitForSingleObject() as a timer. Basically WaitForSingleObject is a predefined function under windows.h? right?. Can you bit explain how exactly this can be embedded with a project?
It is a Windows API function that is used with threads. It will suspend the thread until the event specified by the passed handle occurs or the time out time has elapsed.
Using threads is an advanced topic. So you should read about it first. A starting point may be Using Worker Threads[^].
Your requirement was to execute specific tasks in fixed intervals. This can be done by Windows timers from within your main (GUI) thread. But this will block the main thread for the task execution time. With short intervals, this will lead to delayed user input (mouse and keyboard actions are not performed immediately). To avoid this, a worker thread can be used.
There is class precision clock included in the library. So I can use this for getting system time. But my doubt is if I've the 'time', with a conditional statement I should be able down sample data writing to a sampling rate of 100hZ??!.
If I've time stamp at rate of 8KHz then how to formulate a conditional statement to write data at 100Hz??
Last Visit: 31-Dec-99 19:00 Last Update: 27-Mar-15 2:39