Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP XC System Software: User's Guide > Appendix A Examples

Building and Running a Serial Application

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

This example show how to build a simple application, called hello world, and launch it with the SLURM srun command.

The following is the source code for the hello world program, located in file hw_hostname.c.

	#include <unistd.h>
	#include <stdio.h>

	int main()
	{
	  char name[100];
	  gethostname(name, sizeof(name));
	  printf("%s says Hello!\n", name);
	  return 0;
	}

The hello world program is compiled in the usual way:

$ cc hw_hostname.c -o hw_hostname

When run on the login node, it shows the name of the login node; n16 in this case:

$ ./hw_hostname
n16 says Hello!

The srun command can be used to run it on one of the compute nodes in the default SLURM partition. This time it lands on n13:

$ srun ./hw_hostname
n13 says Hello!

The srun command can also be used to replicate it on several compute nodes. This is not generally useful, but is included for illustrative purposes.

$ srun -n4 ./hw_hostname
n13 says Hello!
n13 says Hello!
n14 says Hello!
n14 says Hello!
Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 2003 Hewlett-Packard Development Company, L.P.