C :: Cache Optimizations / Make Multiplication And Calculations Faster?

Jan 30, 2014

I have a 125X125 array, each element is 55 bits. The cache line for the CPU ( Cortex A9) is 32 bits. Is there anyway to do optimizations, like loop tiling that would make multiplication and calculations faster?

View 5 Replies


ADVERTISEMENT

C/C++ :: OpenMP Can Make For Loop Faster?

Dec 9, 2014

I'm trying to optimize this code using openMP. The line I added made it run about twice as fast but I'm trying to figure out how to make it even faster. Could reshaping the loops potentially increase the speed?

//4 threads
int listsize=15000;
#pragma omp parallel for shared(f) private(i,j,hash)
for(i = 0; i < listsize; i++) {
printf("Thread: %d i: %zu wl_size: %zu
",omp_get_thread_num(),i,wl_size);
for (j = 0; j < num; j++) {
h = f[j] (getw(list, i));
c[h] = 1;
} }

View 2 Replies View Related

C++ :: Analysis Of Discrete Wavelet Transform - Modifying For Loop To Make It Faster

Aug 25, 2014

I have this code which performs the analysis part of discrete wavelet transform. It works pretty well. However, I wish to reduce the time that it consumes even further. I did use reserve() and it worked upto few msec.

int rows = signal.size();
int cols = signal[0].size();
int cols_lp1 =(int) ceil( (double) cols / 2);
vector<vector<double> > lp_dn1(rows, vector<double>(cols_lp1));
vector<double> temp_row;
temp_row.reserve(512);

[Code] ....

View 5 Replies View Related

C++ :: Getting A File From Designated Location / Grab Value And Make Calculations

Oct 30, 2013

My project is to get a file from a designated location in my computer and not just read, but grab the values from the user and make a count, sum, and average calculation of the numbers in my code. I am using the fstream library and I am trying I did do it, I got the values and calcualated them, however I want the values to be accessed from maybe my desktop or my drive, I want to know how to manipulate my code to get a path like C:UserDesktop and maybe executed from the path input or given. I dont know if this is possible, or easy to do. ALso I did copy some of this code from my teachers examples and I dont know exatly why the variables have to be initilized at zero, and I would like to know a little more on the Bitwise right shift breaker used in line 20 something.

Here is my code below.

#include <iostream>//For avergae functionality
#include <fstream>//For the file commands, such as ifstream and the Bitwise right breakers(<< and >>).
#include <iomanip> // To control the amount of decimals in my results desired.
using namespace std;
int main () {
int aNumber=0; //Initilized at zero because of Stack Overflow:

[Code] .....

View 2 Replies View Related

C++ :: Bit Shifting - Cache Simulator

Apr 18, 2013

I'm attempting to make a cache simulator in C++. But I need to access individual bits in an integer to figure out where in my "cache" the writing actually gets done. I'm pretty new to bit shifting. Say I'm trying to access the the bits of the int 5, which are its "address". I'm simulating a direct mapped cache. I need to find its tag, the set it goes into, and which line. How do I use bit shifting to access the bits to acquire the tag, the index bits, offset bits, block number...all these pieces in order to actually find where I store it in the cache.

View 6 Replies View Related

C :: Cache Simulator - Bit Shifting

Apr 21, 2013

I'm attempting to make a cache simulator in C++. But I need to access individual bits in an integer to figure out where in my "cache" the writing actually gets done. I'm pretty new to bit shifting. Say I'm trying to access the the bits of the int 5, which are its "address". I'm simulating a direct mapped cache. I need to find its tag, the set it goes into, and which line. How do I use bit shifting to access the bits to aquire the tag, the index bits, offset bits, block number...all these pieces in order to actually find where I store it in the cache. I need to break the bits up into 3 sections: tag, set index, and block index. I think I can figure out the set and block index sizes based on the values passed in. The tag bits are just the remaining ones. And I'm hard coding values such as cache size (C) - 1024, number of physical address bits (m) - 32, block size (B) - 2, number of lines per set (E) - 1 (again, directly mapped cache). How would this look? I'll be using unsigned longs, so it can handle up to 64 bits.

View 3 Replies View Related

C++ :: Using Vectors For A Clip / Cache

Apr 19, 2013

I'm trying to make it like a game. You would fire your gun, then have the option of reloading. If you run out of ammo and try to fire...it will automatically come out of your cache. Anyone who played a 3rd or first person shooter knows what I mean. I thought vectors would be the best course of actions since they can remove and add elements with ease. One of the many problems I have is subtracting the Hand Guns current ammo (size) from its maximum (capacity) to see how much to A. push_back into the clip and B. pop_back out of the cache. Can size() and capacity even be subtracted? Here's the code with what I believe to be all the possibilities.

#include<iostream>
#include<vector>
using namespace std;
int main(int argc,char** argv) {
vector<int> HG_cache (36,1);
vector<int> HG_clip (12,1);
char user_input;

[code]....

View 1 Replies View Related

C++ :: Faster Prime Number Algorithm

Oct 19, 2014

Can I possibly get a better implementation of a prime number detecting algorithm than the one I already have below?

Code:
#include <cstdio>
#include <cstdlib>
int main() {
int no, high, low;
int divisor;

[Code] .....

View 8 Replies View Related

C :: Reaction Game - How To Create Randomize Algorithm Which Gets Exponentially Faster

Mar 29, 2014

I am creating a reaction game using a series of lasers and LRDs and need to make a function which waits for a specific pin in portb to be triggered high before it can move onto waiting for the next pin to be triggered. The time lasped before the "game loses" needs to get exponentially faster as the game goes on.

I am using statements such as if(input(PIN_B0)==1 generate_tone(G_note[2], 1000); but unsure how to write in c "wait x amount of time, if trigger move onto next random pin or no trigger go to lose function.

View 8 Replies View Related

C++ :: Faster To Create New Variable Or Reuse Existing One For Math Calculation?

Feb 15, 2015

is it better to reuse an existing variable or create a new variable for the following situation:

/* Is this faster: */
glm::mat4 newViewModelMatrix = (*existingViewMatrix) * (*existingModelMatrix);
/* Or is this faster? */
glm::mat4 existingViewModelMatrix; /* declared in class header - initial value assigned in class constructor */
existingViewModelMatrix = (*existingViewMatrix) * (*existingModelMatrix);

Just wondering if it makes a difference or not.

View 1 Replies View Related

C/C++ :: Calculations From Textfile?

Mar 31, 2014

I have a text file that contains values as follows:
2013 05 27 15 52 02.049824 231.401 0.022 49.738
2013 05 27 15 52 02.668822 229.814 0.019 49.738
2013 05 27 15 52 03.283705 228.528 2.599 49.726
2013 05 27 15 52 03.898469 230.140 2.576 49.751

Column1=date, Column2=Month, Column3=Day, Column4=Hour, Column5=Minute, Column6=Seconds, Column7=Voltage(Vrms), Column8=Current(Irms), Column9=Frequency(Hz).

I have to develop a program that will analyse these time-sampled voltage and current measurements over 24 hours and find the total energy used, mean and peak power consumption and Energy used over each hour of the 24 hour period.

How do I go about doing this? I also have to use at least one integration method. The file data contains over 50 thousand lines in the format mentioned above.

View 11 Replies View Related

C++ :: Calculations From Text Files?

Mar 31, 2014

I have a text file that contains values as follows:

2013 05 27 15 52 02.049824 231.401 0.022 49.738 2013 05 27 15 52 02.668822 229.814 0.019 49.738 2013 05 27 15 52 03.283705 228.528 2.599 49.726 2013 05 27 15 52 03.898469 230.140 2.576 49.751
Column1=date, Column2=Month, Column3=Day, Column4=Hour, Column5=Minute, Column6=Seconds, Column7=Voltage(Vrms), Column8=Current(Irms), Column9=Frequency(Hz).

I have to develop a program that will analyse these time-sampled voltage and current measurements over 24 hours and find the total energy used, mean and peak power consumption and Energy used over each hour of the 24 hour period.

How do I go about doing this? I also need to include at least one numerical integration technique. The file data contains over 50 thousand lines in the format mentioned above.

View 2 Replies View Related

C++ :: Calculations Are Done Correctly But Showing Zero

Nov 26, 2013

#include <iostream>
#include <cstdio>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
const int SZ = 55;

[Code] ....

View 1 Replies View Related

C++ :: Calculations From Text File?

Mar 31, 2014

I have a text file that contains values as follows:

2013 05 27 15 52 02.049824 231.401 0.022 49.738
2013 05 27 15 52 02.668822 229.814 0.019 49.738
2013 05 27 15 52 03.283705 228.528 2.599 49.726
2013 05 27 15 52 03.898469 230.140 2.576 49.751

Column1=date, Column2=Month, Column3=Day, Column4=Hour, Column5=Minute, Column6=Seconds, Column7=Voltage(Vrms), Column8=Current(Irms), Column9=Frequency(Hz).

I have to develop a program that will analyse these time-sampled voltage and current measurements over 24 hours and find the total energy used, mean and peak power consumption and Energy used over each hour of the 24 hour period.

How do I go about doing this? The file data contains over 50 thousand lines in the format mentioned above.

View 5 Replies View Related

C/C++ :: Adding Calculations To BMI Calculator

Oct 8, 2014

I have to enhance my BMI program to tell whether the person is at optimal weight, under weight, or overweight and I cannot find the correct calculation. Here is the code I have so far that works for calculating the BMI.

namespace Body_Mass_Index {
public partial class BMI_HW : Form {
public BMI_HW() {
InitializeComponent();

[Code] ....

View 14 Replies View Related

C/C++ :: Overtime And Payroll Calculations

Apr 11, 2014

When you execute my code you'll notice the regular pay for the first example will calculate to $500 when it is only supposed to calculate to $400. I'm also having a problem adding up the totals of the regular pay and overtime pay to get a total payroll which is displayed in one cout statement. 95% of my code is correct, I'm just having these two issues. To make it more clear hear is my assignment:

The regular working hour for an employee is 40 hours a week. Sometimes employees work over time. When the employee works 40 or less hours, the regular pay is calculated as number of hours worked times the hourly rate. When the employee works over time i.e. beyond 40 hours then the employee's pay has two components a) regular pay (40 hours X hourly rate), and 2) overtime pay (the overtime hours beyond 40 X time and half of the hourly rate).

void compute(incomeInfo *ptrI, int count) {                                                
    for (int i = 0; i<count; i++)  
    if (ptrI->hours <= 40) {
        ptrI->regPay = ptrI->hours * ptrI->hRate;
        ptrI++;

[Code] ....

View 1 Replies View Related

C++ :: Timer With Non-return Calculations

Dec 25, 2013

My game runs in a while loop, as you can see in the code below. I need a timer, which won't stop this loop or freeze it, but it will wait, until timer is over and executes code without interfering with the while or for loop.

Code:

Code:
#include <iostream>
#include <iomanip>
#include <windows.h>
#include <ctime>
using namespace std;
char *map[25][25];

[Code] ....

View 1 Replies View Related

C/C++ :: Menu Driven Complex Calculations

Mar 18, 2015

//complxCalc.cpp//

#include "complx.h"
using namespace std;
ifstream infile ("in.dat");
int main() {
int i = 0;
complx tempComplx;
double d = 4.5;

[Code] ....

//in.dat//
(4,4) (6,7) (2.5, 9.3) (3,8.4) (13, 26.5) (2.2, 3.4)

My plan is to make this a menu driven program, I have already got the program to give the answers but now I want it to give the user choices as well. The first step in this project is to add a menu to the program. The first menu the user sees should ask the user if the program will be taking input from a file or from the user directly via the keyboard. Regardless of option chosen, the user should then be prompted to specify whether a multiplication,subtraction or addition operation should be performed.

If the user originally chose the file input method then the program should proceed to display to the screen the results of those operations on each pair of data elements in the file and terminate. If the user chose to input via the keyboard then the user should be prompted to input the two numbers, perform the operation on those two numbers and display the results to the screen and ask the user which mathematical operation they would like to do next and continue in this manner until the user chooses to exit the program via a menu option. Fortunately the only file that needs to be edited are in.dat and complxcalc.cpp files.

View 1 Replies View Related

C++ :: Writing Calculations For Unknown Amount Of Students?

Jun 27, 2014

I need to create a program that continuously records data until the user enters '0'

The data that I read in is the student's last name, the year of the student (1-4), the major, the gpa, and the advisors name. I then need to print out how many students are in each year (1-4), the number of students each advisor has, the average gpa for each major, and so on. This is what I have, but I am stuck and think that I might be headed the wrong direction because the only thing working is the loop (not my gpa test calc).

//This program displays information pertaining to students
#include <iostream>
#include <string>
using namespace std;
int main () {
int studYear;
double average, studGpa;
string studName, studMajor, studAdvisor, complete;

[code]....

View 2 Replies View Related

C/C++ :: Using Values From Distance Array In Function To Be Used For Calculations

Mar 30, 2014

I know that the issue is around the array distance being of type double in the function get distance of type double. My question is how do i get around using the values from the distance array in the function to be used for calculations.

#include <stdio.h>/* initialization of preprocessor directives*/
#include <stdlib.h>
#include <math.h> /*preprocessor directive in order to use sqrt function*/
int calcSecondsvar(int,int,int ,double);
double getdistance(double,double,int,int,int);

[Code] ....

I forgot to mention that it keeps giving me the error cannot convert from 'double[8] to 'double' ....

View 2 Replies View Related

C/C++ :: Employee Payroll Calculations Program For A Class

Sep 30, 2013

getting output from my code when I compile, the codeblocks ide doesnt show any errors it just doesn't give me any out put when I compile?

Here is my code:

#include <iostream>
#include <string>
#include <iomanip>  
using namespace std;  
//
//CLASS DECLARATION SECTION

[code].....

View 1 Replies View Related

C/C++ :: Create Billing System Without Using Pointers - Array Calculations

Feb 17, 2014

I am trying to create an billing system "without using pointers". This is my class assignment. In this,

1) User inputs the name
2) The system asks how many items he has purchased
3) Displays a bill number [just a random number]
4) System asks for the item names the user purchased and stores them in an array (of max 10 (ten) inputs (or items))
5) After each item the user inputs, the system asks for the price of the item (stored in an array of numbers)
6) The total bill is calculated, by adding the sum of all prices in the array

I am having terrible difficulties in coding #4 and #5. Somehow, they aren't going well together. Here's what I have:

#include<stdio.h>
#include <stdlib.h>
int main() {
char item[10][10], answer = 'y', name;
int price[10], total_item, total_price = 0, i, j, a, total_bill = 0, max_items = 10, max_char = 10;

[Code] ....

You might find a lot of unused variables

View 10 Replies View Related

Visual C++ :: Get Streamreader To Read And Calculations To Populate Textbox

Jul 27, 2013

Here what i have so far, the error in the stream

[CODE]

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fileName As String = IO.File.ReadAllText("Grades.txt")
Dim GPA As Double = 0

[Code]....

View 1 Replies View Related

C++ :: Program Compiles Successfully But Calculations Give Wrong Answer

Feb 11, 2013

I'm using MSVC++ and it builds sucessfully but somewhere something is obviously messed it. Once i try to debug it just shows weird numbers.

int k=0; //could this be the problem??? since 0 would be over writing any given value. but if i leave int k; it showsa warning and MSVC would count that as an error

#include "stdafx.h" //Header file section
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
//structure declaration
struct menuitemtype

[Code] ......

View 14 Replies View Related

C++ :: Computational Calculations - Numerically Solve Quantum Harmonic Oscillator

Apr 20, 2012

My task I am trying to accomplish is write a program for C++ that numerically solves a quantum harmonic oscillator. I have a routine that I am trying to implement into this program that iterates through a matrix and finds it eigenvalues, however, I do not know how to put it all together to make it work. Code is below:

Code:
//Compiler flags and numerical constants
#include <iostream>
#include <math.h>
#define L 10.0
#define N 200
using namespace std;

[Code] ....

View 1 Replies View Related

C++ :: If Statement Multiplication By Zero

Mar 28, 2013

I want to set an integer to zero when it easy equal to another integer, but it seems that the program for some reason won't set the integer to zero. Here is the example of that code:

#include <iostream>
using namespace std;
int main () {
int n = 2;
int r = 2;
if(n==r)
n++;
r*0;
cout << " n is " << n << endl;
cout << " r is " << r << endl;
}

What am I doing wrong, it should say that "n is 3" and "r is 0".

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved