Visual C++ :: Number Of Hardware Processors (cores)

Apr 24, 2014

Apparently there are various methods (GetSystemInfo() / GetLogicalProcessorInfoEx() etc) which can return the number of available processors. But they usually return the number of logical processors and they're affected by stuff like hyperthreading. So for example, depending on how you get the information, a dual-core CPU can either return 1, 2 or 4 processors.

I've been asked if there's any simple way to retrieve the actual number of physical processor cores - i.e. such that a dual core CPU will always get returned as '2'. An 8-core CPU would return '8' etc.

View 9 Replies


ADVERTISEMENT

C :: Accessing Files From Multiple Processors

Apr 9, 2013

I have a big un-editable program, A, which I need to run for like a 1000 different input files. It takes about 15 minutes for each file, so a little parallelisation wouldn't hurt.

I have installed openmpi and it works fine. I have made a small program, B, which selects an input file, moves it to another directory, calls program A with the path to the selected input file and then - when A is done - selects a new input file etc. It should loop until there are no more files in the initial directory.

The problem is this: When I have several processors they might pick the same file and that leads to errors. I have a working program, but it is not pretty.

Code:

#include <stdio.h>
#include <mpi.h>
#include <dirent.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
int num_procs, procs_id, i, exit;
struct dirent *ent;

[Code]...

Every time a processor tries to move a file that another processor has just moved, the output shows an error message before looping to the next file and trying again. It works, but it is a bit annoying. So my questions are:

1) Can I switch off the error message somehow?

2) Is there a better way to do this?

View 3 Replies View Related

C :: Access A FIFO (Circular Queue) Between Two Cores

Oct 31, 2014

I want to write a program where one core (core 0) will fill the FIFO and other core (core 1 ) will delete the data from FIFO.

Core 0:

I create a fifo

Code:
struct node
{
int info;
struct node *ptr;
}*front,*rear,*temp,*front1;

And my en-queue function is in core 0 and writing to specific memory location..(which works perfectly)

Code:
void enq(int data)
{
if (rear == NULL)
{
rear = (struct node *)malloc(1*sizeof(struct node));
rear->ptr = NULL;
rear->info = data;
front = rear;

[Code] ....

Now the problem is in the core 1. Here I am unable to read the values from the specific memory location. I am getting garbage value. Where I am doing some stupid error.. I did not understand

Code:
(front->ptr) = (unsigned int *) memory_location;

When I print the (front->ptr) it shows correct memory address but inside the De-queue function in core 1, I am getting wrong value..

Code:
int deq(int buf[n]) {
front1 = front;
printf("Val %d ", front->info); // showing wrong value
if (front1 == NULL) {
printf("

Error: Trying to display elements from empty queue");
return 0;

[Code] ...

View 8 Replies View Related

C++ :: Find Prime Numbers From 0 To 100 Million - Running On 8 Cores?

May 11, 2012

I made a program which finds the prime numbers from 0 to 100 million, and ran it on my laptop (core 2 duo, 1.83ghz, 2gb ram). It takes around 35 seconds for it to sieve all the non-prime numbers on my laptop.

I then ran the same program on a windows server, 2x 64 bit Intel Xeon Quad Core Processors @ 1.6 ghz, 6gb ram, and it takes the same amount of time, even when I set the priority to high and the affinity to all 8 cores, it seems to only use one core for the processing, is there any way to make it use all 8 cores at close to 100%?

View 11 Replies View Related

Visual C++ :: Rounding A Number Multiple Of Another

Jul 23, 2013

How would I be able to round a number in multiples of another...

Let's say width is 150
And multiple to be 64...
I want 150 to become 128...
if it was 160 to become 192...

The width number will change and I want to covert it in multiples of the other number example 64... The minimum value will always be the multiple number used...

View 7 Replies View Related

Visual C++ :: Localize Big Number Mask

Feb 10, 2013

I have some strings that shows big number. I need to add commas to the big number so for example 9999999 become 9,999,999.

I need it to be localized and I know that some languages uses the char '.' instead of ',' ... How can I do it ?

View 3 Replies View Related

Visual C++ :: Calculating Number Of Days Between Dates

Mar 19, 2014

I have a code that calculates the number of days between dates. It considers leap years and different days among months. The problem I have is when i debug the code nothing comes out.

Here is the code.
#include<iostream>
#include<fstream>
using namespace std;
bool wheep();
int daysinmonth();
bool wheep(int yr) {
if (yr % 400 == 0)

[Code] ....

this is the file its reading
1 7 9 1 10 9

View 3 Replies View Related

Visual C++ :: Bubble Sort Is Making Up Its Own Number

Dec 10, 2013

i cant figure out what im doing wrong with my bubble sort. when i cout the sorted test scores, the first number(testScore[0])this is the code.

#include <iostream>
using namespace std;
int main()
{

[Code]....

View 2 Replies View Related

Visual C++ :: Calculate Fewest Number Of Each Denomination

Mar 4, 2013

Write a C++ program to calculate the fewest number of each denomination needed to pay a bill of amount TOTAL. For example, if the end user enters $97 for TOTAL, program will output that the bills would consist of one $50 bill, two $20 bills, one $5 bill, and two $1 bills. (Assume that the amount is in whole dollars, no cents, and only $100, $50, $20, $10, $5, and $1 denominations are available.) Aid: You may want to use the modulus operator %.

View 5 Replies View Related

Visual C++ :: Adding Rational Number Using Only Class Functions

Feb 22, 2015

I'm having trouble finishing this program. What I'm trying to do is create a class for Rational numbers. Get input from user for denominator and numerator. Store the numbers without a sign, and for the sign store it separately in char. I'm not supposed to use accessor functions. The part that I can't seem to know how to do is use the info that was stored in the addUp function. This function need to add two rational numbers. i need to make this function general enough that it can handle two fractions, or a fraction and a whole number, or two whole numbers. What I already have here is readin function which reads in the numerator and denominator. setnumerator and setdenominator to assign positive values. setsign should get the sign of the fraction. Finally addUp should addUp which I explained before. I have some ideas about writing the tests, but can't seem to know how to implement it to the program. The main program is still empty but all I'm supposed to do there is call the class functions.

Code:
#include <iostream>
using namespace std;
class Rational {
private:
int numerator, denominator;
char sign;

[Code] .....

View 14 Replies View Related

Visual C++ :: Using Imaginary Number - How To Declare Complex Numbers

Aug 13, 2013

I created an algorithm that uses imaginary numbers. It is fine on Dev C++, and now I am trying to port to VS2008. I figured out most things, including how to declare complex numbers. However, I've been having an incredible hard time trying to figure how to use the " i " number! For example:

In Dev C++:

Code:
z_cmplx = cexp(I * f1/Fs * 2 * PI);

Where "I" is a macro from the library!

In VS2008:

Code:
z_cmplx = std::exp(I * f1/Fs * 2 * PI);

Although I DID include <complex> library just like I did before, the compiler gives me: error C2065: 'I' : undeclared identifier.

View 10 Replies View Related

Visual C++ :: How To Send A Number To OPENGL Class From Main Dlg

May 14, 2014

I want to send a number to my OPENGL class from my main dlg. Im using a updated edit control.

here is my open gl code that will draw what I want

Code:

void COpenGLControl::oglDrawScene()
{char side[32];
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glBegin(GL_LINE_LOOP);
for(int i = 0; i < 256; i++) {
glColor3f(1.0f,0.0f,0.0f);
glVertex3f( 1.0f, 1.0f, 1.0f);

[Code]...

I want to update the glVertex3f values when I enter numbers into edit controls on my main dialog

how can I send messages from my main dialog to the opengl class that I created?

View 1 Replies View Related

Visual C++ :: Getting Port Number Of A Packet In Pcap File

Jan 19, 2014

I am programming in c++ with 'winpcap' . I read a .pcap file and after I want to get the source and destination of packets in that file. Here is a piece of my code:

Code:
////I define the sructures here
#pragma pack(1)
struct sniff_ethernet {
u_char ether_dhost[ETHER_ADDR_LEN]; /* Destination host address */
u_char ether_shost[ETHER_ADDR_LEN]; /* Source host address */
u_short ether_type; /* IP? ARP? RARP? etc */

[Code] ....

but the result is incorrect? where is the problem?

View 5 Replies View Related

Visual C++ :: Converting Decimal Number Given By User To Binary?

Dec 19, 2014

Write a C++ program that adds three binary numbers of 8-bit each. Every number is stored into an array of 8 elements.

Example:

Array A
0 1 2 3 4 5 6 7
0 1 1 0 1 1 1 0
+
Array B
0 1 2 3 4 5 6 7
0 1 1 0 1 1 1 0
+
Array C
0 1 2 3 4 5 6 7
0 1 1 0 1 1 1 0

Store the result into an array D of 8 elements. Your program should show the decimal numbers for every binary number. Print screen of 6 answers. This means you should try your program six times with different numbers in every run and show the printed screen result.

View 5 Replies View Related

Visual C++ :: Write Number In Excel Cell - OLE Automation

Sep 23, 2013

I need to make a programm to write in a excel cell a number.

I must use OLE Automation. How i can do it??

Code:
#include "stdafx.h"
#include <stdio.h>
#include <windows.h>
#include <ole2.h>
#include <assert.h>
#include <iostream>
void main(void) {
CLSID clsid;
CLSIDFromProgID(L"Excel.Application", &clsid);

[Code] ....

View 1 Replies View Related

Visual C++ :: Employee Class - Number Of Vacation / Sick Days Used

Oct 21, 2012

Can not even say this is the error as it is giving me 45 errors. l am writing code which accept employee type based on calculating the miles traveled in a year,my code is based on type of employee, number of vacation days used and no of sick days used.

#include <iostream>
#include <iomanip>
#include <conio.h>
class employee {
int emp_type;
float emp_vacation;

[Code] ....

View 11 Replies View Related

Visual C++ :: Number Of Players - Making Score Stay With Each Player

Oct 21, 2013

I am writing a game that is 2 to 4 players. i am wondering how to ask how many players, and make the score stay with each player. it is a rip off of zombie dice, this is what i have so far the playerScore array is to hold the score for each player and the turn array is hold hold the values that they rolled that turn, i also dont know how to clear out the turn array when it goes to the next player.

#include <iostream>
#include <cstdlib>
#include <cmath>
#include <ctime>
using namespace std;
int main() {
int playerScore[4];

[Code] ....

View 3 Replies View Related

Visual C++ :: Nim Project - Not Displaying Matches But Display Correct Number

Apr 9, 2013

I am having one issue with my project. We are making a game of Nim code.I'm 99% done with it, i worked hard on it and i feel like i did a good job, however my project is not displaying the matches i want. For example, it display's the inital number of them 23. But once the first player subtracts a number, it doesn't display matches for player 2, just the number of matches remaining. Then as i keep running the program the same thing happens. This is what it's supposed to
output:

"Input/Output sample
WELCOME TO NIM
------- -- ---
Enter the starting player's name (no spaces)-->John
Enter the second player's name (no spaces)-->Mary
There are 23 matches.
ooooooooooooooooooooooo
|||||||||||||||||||||||
Player John please enter the number of matches to remove-->2
There are 21 matches.
ooooooooooooooooooooo
|||||||||||||||||||||
Player Mary please enter the number of matches to remove-->3
There are 18 matches.
oooooooooooooooooo
||||||||||||||||||
Player John please enter the number of matches to remove-->1 "

This is entire code.

#include <iostream>
#include <string>
using namespace std;
int main() {
// Holds variables.

[Code] ....

I will attach my code as well.ProjectNim.cpp

View 7 Replies View Related

Visual C++ :: Getting Slider With Number Displayed Inside Slider?

Oct 23, 2012

I need a slider with number displayed inside the slider. Slider thumb or number should be moved and finally i need to fetch the value where the slider thumb is placed. I had attached the image of slider which i required.

[URL]

View 4 Replies View Related

C :: Function To Round A Number To Give Integer Number That Is Closer To Real Value

Oct 9, 2013

I was told to use a round function to round a number to give an integer number that is closer to the real value. (for example if the number is 114.67 I need to print an int value of 115 instead of 114)

I am not exactly sure how a round function works, but I am told to include math.h library. What I try doesn't seem to work.

View 1 Replies View Related

C++ :: Search For A Number When Vector Is In Order - Count How Many Times That Number Appears

Feb 6, 2014

In this program what i'm doing is to search for a number when the vector is in order, and count how many times that number appears, the problem is that count how many times the number does not appear, but when its appear the program stays in an "standby mode" and the cursor does not move.

int buscarNumOrdenado (int x [MAX]) //MAX is the define {
int num,d, LimiteInferior, LimiteSuperior,mitad;
d=0;
LimiteInferior = 0;
LimiteSuperior = MAX-1;

[Code] ....

View 2 Replies View Related

C :: Program That Allow User To Enter A Number N And Print Nth Prime Number

Nov 3, 2013

I need to write a program that will allow the user to enter a number "n" and the program tell you that the nth prime number is .....

EXAMPLE

user enters 55

printf("The 55th prime number is %i", variable");

View 1 Replies View Related

C++ :: Input Decimal Number And Output To Be Number Scientific Notation

Apr 26, 2013

I need to write a code in c++ , to input decimal number and the output to be number in Scientific notation with 32 bits .

View 1 Replies View Related

C++ :: Variable Initiation - Calculate Number Of Multiplications It Took To Reach A Certain Number

Feb 19, 2014

So I have a template, part of a larger code, that is designed to calculate the number of multiplications it took to reach a certain number. The problem is, whenever I execute the program, mults is always printing out a strange number, perhaps its actual address.

template <class T>
T power3(T x, unsigned int n, unsigned int& mults) {
if (n == 0) return 1;
if (n == 1) return x;
if (n == 2){

[Code] ....

View 10 Replies View Related

C++ :: Receive Number From User And Output Largest Prime Number

Nov 20, 2014

I am attempting to write code that receives a number from the user and outputs the largest prime number underneath the user's number. There are no errors in my code, but no matter what number is imputed, the program says the largest prime number is 1. I cannot find where the issue is in the code. Here is the code I wrote:

#include <cstdlib>
#include <iostream>
#include <cmath>
using namespace std;
bool isPrime(int num);//function prototype

[Code] ....

View 2 Replies View Related

C++ :: Random Number Generator - Count How Many Times Each Number Shows Up

Sep 26, 2012

I'm running a game online and designing a program to generate Enemy Stats. Basically, it's supposed to generate 25 numbers between 0 and 7(to represent 8 Attributes on a 25 Point Buy system) and count how many times each number shows up.

Here's what the code looks like:

Code:
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int Generate() {
int r= rand();
int s= r%7;
[Code] ....

And here's two outputs.

1: Code:

12133089220 12133089220 12133089220 12133089220 12133089220 12133089220 12133089220 12133089220 12133089220 12133089220 12133089220 12133089220 12133089220 12133089220 12133089220 12133089220 12133089220 12133089220 12133089220 12133089220 12133089220 12133089220 12133089220 12133089220 12133089220 Stats[0]= 25 Stats[1]= 0 Stats[2]= 0 Stats[3]= 0 Stats[4]= 0 Stats[5]= 0 Stats[6]= 0 Stats[7]= 0 Stats[8]= 0 Disallowed system call: SYS_socketcall

2: Code:

14787708434 14787708434 14787708434 14787708434 14787708434 14787708434 14787708434 14787708434 14787708434 14787708434 14787708434 14787708434 14787708434 14787708434 14787708434 14787708434 14787708434 14787708434 14787708434 14787708434 14787708434 14787708434 14787708434 14787708434 14787708434 Stats[0]= 0 Stats[1]= 0 Stats[2]= 0 Stats[3]= 0 Stats[4]= 25 Stats[5]= 0 Stats[6]= 0 Stats[7]= 0 Stats[8]= 0 Disallowed system call: SYS_socketcall

Note that the number does change, but only between runs.

View 3 Replies View Related







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