added support for multiple architectures. right now, support is tested only for sm_35 and sm_37
This commit is contained in:
40
ptxtools/GPUTargets.h
Normal file
40
ptxtools/GPUTargets.h
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// -*- mode: c++ -*-
|
||||||
|
/*
|
||||||
|
Copyright (c) 2015, Evghenii Gaburov
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of Intel Corporation nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace GPUTargets
|
||||||
|
{
|
||||||
|
static std::vector<std::string> computeMode = {"sm_35", "sm_37"};
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// -*- mode: c++ -*-
|
// -*- mode: c++ -*-
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2014, Evghenii Gaburov
|
Copyright (c) 2014-2015, Evghenii Gaburov
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
@@ -43,6 +43,7 @@ met:
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include "PTXParser.h"
|
#include "PTXParser.h"
|
||||||
|
#include "GPUTargets.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -119,9 +120,11 @@ static void lUsage(const int ret)
|
|||||||
fprintf(stdout, "\nusage: ptxcc [options] file.ptx \n");
|
fprintf(stdout, "\nusage: ptxcc [options] file.ptx \n");
|
||||||
fprintf(stdout, " [--help]\t\t\t This help\n");
|
fprintf(stdout, " [--help]\t\t\t This help\n");
|
||||||
fprintf(stdout, " [--verbose]\t\t\t Be verbose\n");
|
fprintf(stdout, " [--verbose]\t\t\t Be verbose\n");
|
||||||
fprintf(stdout, " [--arch=]\t\t\t GPU target architecture\n");
|
fprintf(stdout, " [--arch=]\t\t\t GPU target architectures:\n");
|
||||||
fprintf(stdout, " \t\t\t\t sm_35 - K20, K40, GK110 chip \n");
|
fprintf(stdout, " \t\t\t\t ");
|
||||||
fprintf(stdout, " \t\t\t\t sm_37 - K80, GK210 chip \n");
|
for (const auto& mode : GPUTargets::computeMode)
|
||||||
|
fprintf(stdout, "%s ", mode.c_str());
|
||||||
|
fprintf(stdout, "\n");
|
||||||
fprintf(stdout, " [-o <name>]\t\t\t Output file name\n");
|
fprintf(stdout, " [-o <name>]\t\t\t Output file name\n");
|
||||||
fprintf(stdout, " [-Xnvcc=<arguments>]\t Arguments to pass through to \"nvcc\"\n");
|
fprintf(stdout, " [-Xnvcc=<arguments>]\t Arguments to pass through to \"nvcc\"\n");
|
||||||
fprintf(stdout, " \n");
|
fprintf(stdout, " \n");
|
||||||
@@ -134,7 +137,7 @@ int main(int _argc, char * _argv[])
|
|||||||
char *argv[128];
|
char *argv[128];
|
||||||
lGetAllArgs(_argc, _argv, argc, argv);
|
lGetAllArgs(_argc, _argv, argc, argv);
|
||||||
|
|
||||||
std::string arch="sm_35";
|
std::string arch = GPUTargets::computeMode.front();
|
||||||
std::string filePTX;
|
std::string filePTX;
|
||||||
std::string fileOBJ;
|
std::string fileOBJ;
|
||||||
std::string extString = ".ptx";
|
std::string extString = ".ptx";
|
||||||
@@ -197,7 +200,11 @@ int main(int _argc, char * _argv[])
|
|||||||
for (int i= 0; i < (int)nvccArgumentList.size(); i++)
|
for (int i= 0; i < (int)nvccArgumentList.size(); i++)
|
||||||
fprintf(stderr, " arg= %d : %s \n", i, nvccArgumentList[i].c_str());
|
fprintf(stderr, " arg= %d : %s \n", i, nvccArgumentList[i].c_str());
|
||||||
#endif
|
#endif
|
||||||
assert(arch == std::string("sm_35") || arch == std::string("sm_37"));
|
if (std::find(GPUTargets::computeMode.begin(), GPUTargets::computeMode.end(), arch) == GPUTargets::computeMode.end())
|
||||||
|
{
|
||||||
|
fprintf(stderr, "ptxcc fatal : --arch=%s is not supported; use option --help for more information\n", arch.c_str());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
if (filePTX.empty())
|
if (filePTX.empty())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "ptxcc fatal : No input file specified; use option --help for more information\n");
|
fprintf(stderr, "ptxcc fatal : No input file specified; use option --help for more information\n");
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// -*- mode: c++ -*-
|
// -*- mode: c++ -*-
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2014, Evghenii Gaburov
|
Copyright (c) 2014-2015, Evghenii Gaburov
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
@@ -43,6 +43,8 @@ met:
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
#include "GPUTargets.h"
|
||||||
|
|
||||||
#include <nvvm.h>
|
#include <nvvm.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@@ -51,9 +53,7 @@ met:
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
static std::string lValueToString(const T& value)
|
static std::string lValueToString(const T& value)
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
return std::to_string(value);
|
||||||
oss << value;
|
|
||||||
return oss.str();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Exception : public std::exception
|
struct Exception : public std::exception
|
||||||
@@ -220,9 +220,11 @@ static void lUsage(const int ret)
|
|||||||
fprintf(stdout, "\nusage: ptxgen [options] file.[ll,bc] \n");
|
fprintf(stdout, "\nusage: ptxgen [options] file.[ll,bc] \n");
|
||||||
fprintf(stdout, " [--help]\t\t This help\n");
|
fprintf(stdout, " [--help]\t\t This help\n");
|
||||||
fprintf(stdout, " [--verbose]\t\t Be verbose\n");
|
fprintf(stdout, " [--verbose]\t\t Be verbose\n");
|
||||||
fprintf(stdout, " [--arch=]\t\t GPU target architecture\n");
|
fprintf(stdout, " [--arch=]\t\t\t GPU target architectures:\n");
|
||||||
fprintf(stdout, " \t\t\t sm_35 - K20, K40, GK110 chip \n");
|
fprintf(stdout, " \t\t\t\t ");
|
||||||
fprintf(stdout, " \t\t\t sm_37 - K80, GK210 chip \n");
|
for (const auto& mode : GPUTargets::computeMode)
|
||||||
|
fprintf(stdout, "%s ", mode.c_str());
|
||||||
|
fprintf(stdout, "\n");
|
||||||
fprintf(stdout, " [-o <name>]\t\t Output file name\n");
|
fprintf(stdout, " [-o <name>]\t\t Output file name\n");
|
||||||
fprintf(stdout, " [-g]\t\t Enable generation of debuggin information \n");
|
fprintf(stdout, " [-g]\t\t Enable generation of debuggin information \n");
|
||||||
fprintf(stdout, " [--opt=]\t\t Optimization parameters \n");
|
fprintf(stdout, " [--opt=]\t\t Optimization parameters \n");
|
||||||
@@ -255,7 +257,7 @@ int main(int argc, char *argv[])
|
|||||||
bool _useFastMath = false;
|
bool _useFastMath = false;
|
||||||
bool _debug = false;
|
bool _debug = false;
|
||||||
bool _verbose = false;
|
bool _verbose = false;
|
||||||
std::string _arch = "sm_35";
|
std::string _arch = GPUTargets::computeMode.front();
|
||||||
std::string fileIR, filePTX;
|
std::string fileIR, filePTX;
|
||||||
|
|
||||||
for (int i = 1; i < argc; ++i)
|
for (int i = 1; i < argc; ++i)
|
||||||
@@ -336,11 +338,11 @@ int main(int argc, char *argv[])
|
|||||||
fprintf(stderr, "use_fast_math= %s\n", _useFastMath ? "true" : "false");
|
fprintf(stderr, "use_fast_math= %s\n", _useFastMath ? "true" : "false");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int computeArch = 35;
|
if (std::find(GPUTargets::computeMode.begin(), GPUTargets::computeMode.end(), _arch) == GPUTargets::computeMode.end())
|
||||||
assert(_arch == std::string("sm_35") || _arch == std::string("sm_37"));
|
{
|
||||||
|
fprintf(stderr, "ptxcc fatal : --arch=%s is not supported; use option --help for more information\n", _arch.c_str());
|
||||||
if (_arch == std::string("sm_37"))
|
exit(1);
|
||||||
computeArch = 37;
|
}
|
||||||
|
|
||||||
if (_useFastMath)
|
if (_useFastMath)
|
||||||
{
|
{
|
||||||
@@ -348,8 +350,14 @@ int main(int argc, char *argv[])
|
|||||||
_precSqrt = _precDiv = 0;
|
_precSqrt = _precDiv = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* replace "sm" with "compute" */
|
||||||
|
assert(_arch[0] == 's' && _arch[1] == 'm' && _arch[2] == '_');
|
||||||
|
const std::string _mode = std::string("compute_") + &_arch[3];
|
||||||
|
const int computeArch = atoi(&_arch[3]);
|
||||||
|
|
||||||
|
|
||||||
std::vector<std::string> nvvmOptions;
|
std::vector<std::string> nvvmOptions;
|
||||||
nvvmOptions.push_back("-arch=compute_"+std::to_string(computeArch));
|
nvvmOptions.push_back("-arch=" + _mode);
|
||||||
nvvmOptions.push_back("-ftz=" + lValueToString(_ftz));
|
nvvmOptions.push_back("-ftz=" + lValueToString(_ftz));
|
||||||
nvvmOptions.push_back("-prec-sqrt=" + lValueToString(_precSqrt));
|
nvvmOptions.push_back("-prec-sqrt=" + lValueToString(_precSqrt));
|
||||||
nvvmOptions.push_back("-prec-div=" + lValueToString(_precDiv));
|
nvvmOptions.push_back("-prec-div=" + lValueToString(_precDiv));
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2014, Evghenii Gaburov
|
Copyright (c) 2014-2015, Evghenii Gaburov
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
@@ -43,6 +43,8 @@ met:
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <algorithm>
|
||||||
|
#include "GPUTargets.h"
|
||||||
|
|
||||||
#define YYERROR_VERBOSE 1
|
#define YYERROR_VERBOSE 1
|
||||||
|
|
||||||
@@ -117,10 +119,12 @@ version:
|
|||||||
TOKEN_VERSION TOKEN_FLOAT { assert($2 >= 3.0); } ;//std::cerr << "Reading PTX version " << $2 << std::endl; };
|
TOKEN_VERSION TOKEN_FLOAT { assert($2 >= 3.0); } ;//std::cerr << "Reading PTX version " << $2 << std::endl; };
|
||||||
target:
|
target:
|
||||||
TOKEN_TARGET TOKEN_STRING {
|
TOKEN_TARGET TOKEN_STRING {
|
||||||
assert(
|
if (std::find(GPUTargets::computeMode.begin(), GPUTargets::computeMode.end(), std::string($2)) == GPUTargets::computeMode.end())
|
||||||
std::string($2) == std::string("sm_35")
|
{
|
||||||
|| std::string($2) == std::string("sm_37")
|
fprintf(stderr, "ptxcc fatal : Found wrong Target=\"%s\" in ptx file\n", $2);
|
||||||
); } //std::cerr << "Target " << $2 << std::endl; };
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
address_size:
|
address_size:
|
||||||
TOKEN_ADDRESS_SIZE TOKEN_INT { assert($2 == 64); } //std::cerr << "Address_Size " << $2 << std::endl; };
|
TOKEN_ADDRESS_SIZE TOKEN_INT { assert($2 == 64); } //std::cerr << "Address_Size " << $2 << std::endl; };
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user