I have multiple "Process Flows".
I have multiple program files.
I would like to use each program file in each "Process Flow".
I would like to sequence the use of the program files differently in each "Process Flow".
What is the canonical way to do this in SAS Enterprise Guide 7.1?
The canonical way to do this is with Ordered Lists.
A seven minute demonstration video is here.
In words:
You should create an ordered list for each sequence of tasks/programs.
Aside (wet-paint):
AFAICT, the "Process Flow" is useful for organizing code and tasks where they are unique to each process flow.
If you have shared objects then you should re-purpose the "Process Flow" idiom in the following way:
Organize shared program files, etc. into a "Shared tasks" or "Support tasks", etc "Process Flow".
Assign single use program files, etc. to a "Process Flow" named to reflect their functionality.
Create an "Ordered List" that executes that shared and single use objects in the correct order for that task. Name the "Ordered List" to reflect the fact that it is the object to be Executed, e.g. "Monthly Run: Overdue Balances" and "Daily Run: Overdue Balances".
Related
I am trying to make a billing software for which I need to take the output of one cpp program as an input in the second program.
eg:
In program 1, the user chose multiple things which made the to the value 'bill'=100.
I need Program 2 to read the value of 'bill' which was 100 in the end of program 1, and then add/subtract whatever the user does to this (interger?) and print the final value in the end of program #2..
I don't know if i explained it correctly but you can take a rough idea of what I meant..
As mentioned in the comments, there are many alternatives. However, I do not suggest the solutions like writing out to a file and reading from another program because you can face with problems like synchronization issues while accessing the file or bottleneck issues (may not be issue in this case but it may happen during big data transfers) regarding file I/O performance. Using mechanisms such as pipes or sockets would be a better solution.
If your software is using Qt Framework, I recommend using Qt Remote Objects. Both PyQt and Qt with C++ support QtRO communication.
In QtRO, the objects can be shared between applications through a defined interface. The source node (program 1) shares the object that contains bill. The clients can access the replicas of the shared object and get properties. When the replica is received, it can be used like any other QObject.
For more information about Qt Remote Objects check out: https://doc.qt.io/qt-6/qtremoteobjects-index.html
I want to parallelise my googletest cases in c++.
I have read the documentation of google test sharding but unable to implement it in c++ coding environment.
As I'm new to the coding field , so can anyone please by a code explain to me the documentation in the link below
https://github.com/google/googletest/blob/master/googletest/docs/advanced.md
Google Sharding works on different machines or can be implemented on same using multiple threads?
Sharding isn't done in code, it's done using the environment. Your machine specifies two environment variables GTEST_TOTAL_SHARDS, which is the total number of machines you are running and GTEST_SHARD_INDEX, which is unique to each machine. When GTEST starts up, it selects a subset of these tests.
If you want to simulate this, then you need to set these environment variables (which can be done in code).
I would probably try something like this (on Windows) in a .bat file:
set GTEST_TOTAL_SHARDS=10
FOR /L %%I in (1,1,10) DO cmd.exe /c "set GTEST_SHARD_INDEX=%%I && start mytest.exe"
And hope that the new cmd instance had it's own environment.
Running the following in a command window worked for me (very similar to James Poag's answer, but note change of range from "1,1,10" to "0,1,9", "%%" -> "%" and "set" to "set /A"):
set GTEST_TOTAL_SHARDS=10
FOR /L %I in (0,1,9) DO cmd.exe /c "set /A GTEST_SHARD_INDEX=%I && start mytests.exe"
After further experimentation it is also possible to do this in C++. But it is not straightforward and I did not find a portable way of doing it. I can't post the code as it was done at work.
Essentially, from main, create new processes (where n is the number of cores available), capture the results from each shard, merge and output to the screen.
To get each process running a different shard, the total number of shard and instance number is given to the child process by the controller.
This is done by retrieving and copying the current environment, and setting in the copy the two environment variables (GTEST_TOTAL_SHARDS and GTEST_SHARD_INDEX) as required. GTEST_TOTAL_SHARDS is always the same, but GTEST_SHARD_INDEX will be the instance number of the child.
Merging the results is tedious but straightforward string manipulation. I successfully managed to get a correct total at the end, adding up the results of all the separate shards.
I was using Windows, so used CreateProcessA to create the new processes, passing in the custom environment.
It turned out that creating new processes takes a significant amount of time, but my program was taking about 3 minutes to run, so there was good benefits to be had from parallel running - the time came down to about 30 seconds on my 12 core PC.
Note that if this all seems overkill, there is a python program which does what I have described here but using a python script (I think - I haven't used it). This might be more straight forward.
Is there any macro command that allows calling one program from another (the %run_program() pseudo code)?
Program "Settings":
%let myvar="HELLO WORLD!";
Program "Program":
%run_program(Settings); *Pseudo-code;
%put &myvar; *Should print *Should print "HELLO WORLD!";
This is not exact answer on your question, but if you only want to be sure that Settings is run before Program when Run Process Flow you can link them together.
Right click Settings,
choose Link Settings to...,
and pick Program from the dialog.
Run Process FLow And see the Hello World be printed in the log.
I think that you are looking for the %include function.
You would have to save 'Settings' as a stand-alone program on your server like '/myserver/somefolder/settings.sas'.
Then you could ensure that it is run via:
...some code
%include ('/myserver/somefolder/settings.sas');
... more code
The program would run exactly as it would if you copy-pasted the contents of 'settings.sas' into the current program.
In addition to the Process Flow, you also can create an Ordered List. This allows you to run programs in a single process flow in multiple different orders (or run a subset of a process flow).
You create that in New -> Ordered List, then Add programs to it, move them up/down in the order you want. Then you see the ordered list on the left in the project tree and can right click to run it (or select then F8).
There is not a macro command to run a program in enterprise guide; you can use automation via .NET if you want to do things like that. Chris Hemedinger on The SAS Dummy has a good article on EG automation.
till today when i was starting up a child program in my application (distributed computing) i used execv and as an argument i was passing a filename which has a payload stored.
So i had two files:
1) child-program.binary (+x)
2) child-program.payload (+r)
When child-program.binary executed it knew that it has to load child-program.payload on startup, then the computing took place and the new payload was stored into child-program.payload file.
i would like to change that and instead of storing payload on the hard drive, i would love to run the binary and pass the payload the different way, maybe via pipes?
Also, do i have to store the binary on the hard disk to be able to run it?
Isn't there any other memory like option to execute something?
What are the possible options?
Thanks all !
The advantage of your file-approach is that it is non-volatile and the data can be easily distributed around the globe as file.
Based on your thought about pipes, I assume your "distributed computing" is on the same node. You could also use shared memory see: shm_open and pass the name of the "file" name of your shared memory to the child.
BTW. Pipes or FIFOs let you easily synchornize using poll/select. AFAIK you need a bit more infrastructure to synchronize access to Shared Memory.
Hi I am trying to write a program in C++ or Java that uses threads. I have no idea where to start. It is for an operating systems class. The class only teaches concepts and no actual coding whatsoever. The professor just hands out this assignment and said that he will provide no help at all. Thanks a lot for helping.
Below is the program requirements:
The goal of this assignment is to create a routine which creates multiple threads, has them do work in parallel, and terminates when the last thread has finished.
The Scenario:
There are several groups of people in a bar watching the Olympics cheering for their country. Each group will cheer for their country some given number of times, with a random pause (between 2 and 5 seconds) between each cheer. There is enough room at the bar for up to ten different groups to sit (each would be cheering for a different country).
The Program:
The task is to write a program that will simulate these cheers using threads. The program should be called cheer.X (X being the language of choice). You may use any language that supports threading. When the program is run it should ask for the number of countries and then the name and how many times it will be cheered for. The main function will then create a thread for each team and each thread is responsible for cheering the specified number of times for the correct team at the random interval. You will submit the proper source code file for me to open and compile myself, not an executable.
An example cheer would be: “Go USA!” An example run would look something like this:
How many countries are supported at the bar? 3
Enter the first: China
How many cheers? 2
Enter the second: USA
How many cheers? 4
Enter the third: Russia
How many cheers? 3
Go USA!
Go China!
Go Russia!
Go China!
Go USA!
Go Russia!
Go USA!
Go Russia!
Go USA!
(Remember there will be a pause, and consecutive runs with the same arguments will not create the same results)
You can use C++11 for multi-threading or install pthread library in your system and write a simple multi-threaded C++ code. Java is also very good option to write multi-thread program.
I would suggest before writing a code try to get the basic understanding of threads, how multiple threads are synchronized.
For pthread library help. Go through this.
Here is the wiki page for basic understanding of Threads.