-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
130 additions
and
494,024 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#! /bin/bash | ||
|
||
echo -e "Creating input file." | ||
cd inputGen | ||
make | ||
./datagen 1000 | ||
mv 1000_34.txt ../ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
datagen: datagen.cpp | ||
g++ -o $@ $< | ||
|
||
clean: | ||
rm datagen | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* datagen.cpp | ||
* by Sam Kauffman - University of Virginia | ||
* | ||
* This program generates datasets for Rodinia's kmeans | ||
* | ||
* Usage: | ||
* datagen <numObjects> [ <numFeatures> ] [-f] | ||
* | ||
* numFeatures defaults to 34 | ||
* Features are integers from 0 to 255 by default | ||
* With -f, features are floats from 0.0 to 1.0 | ||
* Output file is "<numObjects>_<numFeatures>.txt" | ||
* One object per line. The first number in each line is an object ID and is | ||
* ignored by kmeans. | ||
* | ||
*/ | ||
|
||
#include <iostream> | ||
#include <fstream> | ||
#include <sstream> | ||
#include <cstdlib> | ||
#include <cstring> | ||
#include <ctime> | ||
|
||
using namespace std; | ||
|
||
int main( int argc, char * argv[] ) | ||
{ | ||
if ( argc < 2 ) | ||
{ | ||
cerr << "Error: Specify a number of objects to generate.\n"; | ||
exit( 1 ); | ||
} | ||
int nObj = atoi( argv[1] ); | ||
int nFeat = 0; | ||
if ( argc > 2 ) | ||
nFeat = atoi( argv[2] ); | ||
if ( nFeat == 0 && argc > 3 ) | ||
nFeat = atoi( argv[3] ); | ||
if ( nFeat == 0 ) | ||
nFeat = 34; | ||
if ( nObj < 1 || nFeat < 1 ) | ||
{ | ||
cerr << "Error: Invalid argument(s).\n"; | ||
exit( 1 ); | ||
} | ||
bool floats = false; | ||
if ( ( argc > 2 && strcmp( argv[2], "-f" ) == 0 ) || ( argc > 3 && strcmp( argv[2], "-f" ) == 0 ) ) | ||
floats = true; | ||
|
||
stringstream ss; | ||
string f = floats ? "f" : ""; | ||
ss << nObj << "_" << nFeat << f << ".txt"; | ||
ofstream outf( ss.str().c_str(), ios::out | ios::trunc ); | ||
srand( time( NULL ) ); | ||
|
||
if ( !floats ) | ||
for ( int i = 0; i < nObj; i++ ) | ||
{ | ||
outf << i << " "; | ||
for ( int j = 0; j < nFeat; j++ ) | ||
outf << ( rand() % 256 ) << " "; | ||
outf << endl; | ||
} | ||
else | ||
{ | ||
outf.precision( 4 ); | ||
outf.setf( ios::fixed ); | ||
for ( int i = 0; i < nObj; i++ ) | ||
{ | ||
outf << i << " "; | ||
for ( int j = 0; j < nFeat; j++ ) | ||
outf << ( (float)rand() / (float)RAND_MAX ) << " "; | ||
outf << endl; | ||
} | ||
} | ||
|
||
outf.close(); | ||
string type = floats ? " \"float\"" : " \"int\""; | ||
cout << "Generated " << nObj << " objects with " << nFeat << type << " features in " << ss.str() << ".\n"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
./datagen 100 | ||
./datagen 300 | ||
./datagen 1000 | ||
./datagen 3000 | ||
./datagen 10000 | ||
./datagen 30000 | ||
./datagen 100000 | ||
./datagen 300000 | ||
./datagen 1000000 | ||
./datagen 3000000 | ||
./datagen 10000000 | ||
./datagen 100 -f | ||
./datagen 300 -f | ||
./datagen 1000 -f | ||
./datagen 3000 -f | ||
./datagen 10000 -f | ||
./datagen 30000 -f | ||
./datagen 100000 -f | ||
./datagen 300000 -f | ||
./datagen 1000000 -f | ||
./datagen 3000000 -f | ||
./datagen 10000000 -f | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters