Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated cutensorInit with cutensorCreate #138

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions cuTENSOR/contraction.cu
Original file line number Diff line number Diff line change
Expand Up @@ -179,31 +179,31 @@ int main()
* cuTENSOR
*************************/

cutensorHandle_t handle;
HANDLE_ERROR(cutensorInit(&handle));
cutensorHandle_t *handle;
HANDLE_ERROR(cutensorCreate(&handle));

/**********************
* Create Tensor Descriptors
**********************/

cutensorTensorDescriptor_t descA;
HANDLE_ERROR(cutensorInitTensorDescriptor(&handle,
HANDLE_ERROR(cutensorInitTensorDescriptor(handle,
&descA,
nmodeA,
extentA.data(),
NULL,/*stride*/
typeA, CUTENSOR_OP_IDENTITY));

cutensorTensorDescriptor_t descB;
HANDLE_ERROR(cutensorInitTensorDescriptor(&handle,
HANDLE_ERROR(cutensorInitTensorDescriptor(handle,
&descB,
nmodeB,
extentB.data(),
NULL,/*stride*/
typeB, CUTENSOR_OP_IDENTITY));

cutensorTensorDescriptor_t descC;
HANDLE_ERROR(cutensorInitTensorDescriptor( &handle,
HANDLE_ERROR(cutensorInitTensorDescriptor( handle,
&descC,
nmodeC,
extentC.data(),
Expand All @@ -215,19 +215,19 @@ int main()
**********************************************/

uint32_t alignmentRequirementA;
HANDLE_ERROR(cutensorGetAlignmentRequirement(&handle,
HANDLE_ERROR(cutensorGetAlignmentRequirement(handle,
A_d,
&descA,
&alignmentRequirementA));

uint32_t alignmentRequirementB;
HANDLE_ERROR(cutensorGetAlignmentRequirement(&handle,
HANDLE_ERROR(cutensorGetAlignmentRequirement(handle,
B_d,
&descB,
&alignmentRequirementB));

uint32_t alignmentRequirementC;
HANDLE_ERROR(cutensorGetAlignmentRequirement(&handle,
HANDLE_ERROR(cutensorGetAlignmentRequirement(handle,
C_d,
&descC,
&alignmentRequirementC));
Expand All @@ -237,7 +237,7 @@ int main()
*******************************/

cutensorContractionDescriptor_t desc;
HANDLE_ERROR(cutensorInitContractionDescriptor(&handle,
HANDLE_ERROR(cutensorInitContractionDescriptor(handle,
&desc,
&descA, modeA.data(), alignmentRequirementA,
&descB, modeB.data(), alignmentRequirementB,
Expand All @@ -251,15 +251,15 @@ int main()

cutensorContractionFind_t find;
HANDLE_ERROR(cutensorInitContractionFind(
&handle, &find,
handle, &find,
CUTENSOR_ALGO_DEFAULT));

/**********************
* Query workspace
**********************/

uint64_t worksize = 0;
HANDLE_ERROR(cutensorContractionGetWorkspaceSize(&handle,
HANDLE_ERROR(cutensorContractionGetWorkspaceSize(handle,
&desc,
&find,
CUTENSOR_WORKSPACE_RECOMMENDED, &worksize));
Expand All @@ -279,7 +279,7 @@ int main()
**************************/

cutensorContractionPlan_t plan;
HANDLE_ERROR(cutensorInitContractionPlan(&handle,
HANDLE_ERROR(cutensorInitContractionPlan(handle,
&plan,
&desc,
&find,
Expand All @@ -300,7 +300,7 @@ int main()
GPUTimer timer;
timer.start();

err = cutensorContraction(&handle,
err = cutensorContraction(handle,
&plan,
(void*) &alpha, A_d, B_d,
(void*) &beta, C_d, C_d,
Expand Down
28 changes: 14 additions & 14 deletions cuTENSOR/contraction_autotuning.cu
Original file line number Diff line number Diff line change
Expand Up @@ -183,31 +183,31 @@ int main()
* cuTENSOR
*************************/

cutensorHandle_t handle;
HANDLE_ERROR(cutensorInit(&handle));
cutensorHandle_t *handle;
HANDLE_ERROR(cutensorCreate(&handle));

/**********************
* Create Tensor Descriptors
**********************/

cutensorTensorDescriptor_t descA;
HANDLE_ERROR(cutensorInitTensorDescriptor(&handle,
HANDLE_ERROR(cutensorInitTensorDescriptor(handle,
&descA,
nmodeA,
extentA.data(),
NULL,/*stride*/
typeA, CUTENSOR_OP_IDENTITY));

cutensorTensorDescriptor_t descB;
HANDLE_ERROR(cutensorInitTensorDescriptor(&handle,
HANDLE_ERROR(cutensorInitTensorDescriptor(handle,
&descB,
nmodeB,
extentB.data(),
NULL,/*stride*/
typeB, CUTENSOR_OP_IDENTITY) );

cutensorTensorDescriptor_t descC;
HANDLE_ERROR(cutensorInitTensorDescriptor(&handle,
HANDLE_ERROR(cutensorInitTensorDescriptor(handle,
&descC,
nmodeC,
extentC.data(),
Expand All @@ -219,19 +219,19 @@ int main()
**********************************************/

uint32_t alignmentRequirementA;
HANDLE_ERROR(cutensorGetAlignmentRequirement(&handle,
HANDLE_ERROR(cutensorGetAlignmentRequirement(handle,
A_d,
&descA,
&alignmentRequirementA));

uint32_t alignmentRequirementB;
HANDLE_ERROR(cutensorGetAlignmentRequirement(&handle,
HANDLE_ERROR(cutensorGetAlignmentRequirement(handle,
B_d,
&descB,
&alignmentRequirementB));

uint32_t alignmentRequirementC;
HANDLE_ERROR(cutensorGetAlignmentRequirement(&handle,
HANDLE_ERROR(cutensorGetAlignmentRequirement(handle,
C_d,
&descC,
&alignmentRequirementC));
Expand All @@ -241,7 +241,7 @@ int main()
*******************************/

cutensorContractionDescriptor_t desc;
HANDLE_ERROR(cutensorInitContractionDescriptor(&handle,
HANDLE_ERROR(cutensorInitContractionDescriptor(handle,
&desc,
&descA, modeA.data(), alignmentRequirementA,
&descB, modeB.data(), alignmentRequirementB,
Expand All @@ -255,11 +255,11 @@ int main()

cutensorContractionFind_t find;
HANDLE_ERROR(cutensorInitContractionFind(
&handle, &find,
handle, &find,
CUTENSOR_ALGO_DEFAULT));

uint64_t worksize = 0;
HANDLE_ERROR(cutensorContractionGetWorkspaceSize(&handle,
HANDLE_ERROR(cutensorContractionGetWorkspaceSize(handle,
&desc,
&find,
CUTENSOR_WORKSPACE_MAX, &worksize));
Expand Down Expand Up @@ -298,7 +298,7 @@ int main()
**************************/

cutensorContractionFind_t find;
err = cutensorInitContractionFind(&handle, &find, (cutensorAlgo_t) algo);
err = cutensorInitContractionFind(handle, &find, (cutensorAlgo_t) algo);

if (err == CUTENSOR_STATUS_SUCCESS)
{
Expand All @@ -307,7 +307,7 @@ int main()
**************************/

cutensorContractionPlan_t plan;
err = cutensorInitContractionPlan(&handle,
err = cutensorInitContractionPlan(handle,
&plan,
&desc,
&find,
Expand All @@ -319,7 +319,7 @@ int main()
GPUTimer timer;
timer.start();

err = cutensorContraction(&handle,
err = cutensorContraction(handle,
&plan,
(void*) &alpha, A_d, B_d,
(void*) &beta, C_d, C_d,
Expand Down
46 changes: 23 additions & 23 deletions cuTENSOR/contraction_plan_cache.cu
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ int main()
* cuTENSOR
*************************/

cutensorHandle_t handle;
HANDLE_ERROR(cutensorInit(&handle));
cutensorHandle_t *handle;
HANDLE_ERROR(cutensorCreate(&handle));

/**********************
* Setup planCache
Expand All @@ -189,11 +189,11 @@ int main()
size_t sizeCache = numCachelines * sizeof(cutensorPlanCacheline_t);
printf("Allocating: %.2f kB for the cache\n", sizeCache / 1000.);
cutensorPlanCacheline_t* cachelines = (cutensorPlanCacheline_t*) malloc(sizeCache);
HANDLE_ERROR( cutensorHandleAttachPlanCachelines(&handle, cachelines, numCachelines) );
HANDLE_ERROR( cutensorHandleAttachPlanCachelines(handle, cachelines, numCachelines) );

const char cacheFilename[] = "./cache.bin";
uint32_t numCachelinesRead = 0;
cutensorStatus_t status = cutensorHandleReadCacheFromFile(&handle, cacheFilename, &numCachelinesRead);
cutensorStatus_t status = cutensorHandleReadCacheFromFile(handle, cacheFilename, &numCachelinesRead);
if (status == CUTENSOR_STATUS_SUCCESS)
{
printf("%d cachelines have been successfully read from file (%s).\n", numCachelinesRead, cacheFilename);
Expand All @@ -212,23 +212,23 @@ int main()
**********************/

cutensorTensorDescriptor_t descA;
HANDLE_ERROR(cutensorInitTensorDescriptor(&handle,
HANDLE_ERROR(cutensorInitTensorDescriptor(handle,
&descA,
nmodeA,
extentA.data(),
NULL,/*stride*/
typeA, CUTENSOR_OP_IDENTITY));

cutensorTensorDescriptor_t descB;
HANDLE_ERROR(cutensorInitTensorDescriptor(&handle,
HANDLE_ERROR(cutensorInitTensorDescriptor(handle,
&descB,
nmodeB,
extentB.data(),
NULL,/*stride*/
typeB, CUTENSOR_OP_IDENTITY));

cutensorTensorDescriptor_t descC;
HANDLE_ERROR(cutensorInitTensorDescriptor( &handle,
HANDLE_ERROR(cutensorInitTensorDescriptor( handle,
&descC,
nmodeC,
extentC.data(),
Expand All @@ -240,19 +240,19 @@ int main()
**********************************************/

uint32_t alignmentRequirementA;
HANDLE_ERROR(cutensorGetAlignmentRequirement(&handle,
HANDLE_ERROR(cutensorGetAlignmentRequirement(handle,
A_d,
&descA,
&alignmentRequirementA));

uint32_t alignmentRequirementB;
HANDLE_ERROR(cutensorGetAlignmentRequirement(&handle,
HANDLE_ERROR(cutensorGetAlignmentRequirement(handle,
B_d,
&descB,
&alignmentRequirementB));

uint32_t alignmentRequirementC;
HANDLE_ERROR(cutensorGetAlignmentRequirement(&handle,
HANDLE_ERROR(cutensorGetAlignmentRequirement(handle,
C_d,
&descC,
&alignmentRequirementC));
Expand All @@ -262,7 +262,7 @@ int main()
*******************************/

cutensorContractionDescriptor_t desc;
HANDLE_ERROR(cutensorInitContractionDescriptor(&handle,
HANDLE_ERROR(cutensorInitContractionDescriptor(handle,
&desc,
&descA, modeA.data(), alignmentRequirementA,
&descB, modeB.data(), alignmentRequirementB,
Expand All @@ -276,28 +276,28 @@ int main()

cutensorContractionFind_t find;
HANDLE_ERROR(cutensorInitContractionFind(
&handle, &find,
handle, &find,
CUTENSOR_ALGO_DEFAULT));

const cutensorCacheMode_t cacheMode = CUTENSOR_CACHE_MODE_PEDANTIC;
HANDLE_ERROR(cutensorContractionFindSetAttribute(
&handle,
handle,
&find,
CUTENSOR_CONTRACTION_FIND_CACHE_MODE,
&cacheMode,
sizeof(cutensorCacheMode_t)));

const cutensorAutotuneMode_t autotuneMode = CUTENSOR_AUTOTUNE_INCREMENTAL;
HANDLE_ERROR(cutensorContractionFindSetAttribute(
&handle,
handle,
&find,
CUTENSOR_CONTRACTION_FIND_AUTOTUNE_MODE,
&autotuneMode ,
sizeof(cutensorAutotuneMode_t)));

const uint32_t incCount = 4;
HANDLE_ERROR(cutensorContractionFindSetAttribute(
&handle,
handle,
&find,
CUTENSOR_CONTRACTION_FIND_INCREMENTAL_COUNT,
&incCount,
Expand All @@ -308,7 +308,7 @@ int main()
**********************/

uint64_t worksize = 0;
HANDLE_ERROR(cutensorContractionGetWorkspaceSize(&handle,
HANDLE_ERROR(cutensorContractionGetWorkspaceSize(handle,
&desc,
&find,
CUTENSOR_WORKSPACE_MAX, &worksize)); // TODO
Expand Down Expand Up @@ -342,20 +342,20 @@ int main()

const cutensorCacheMode_t cacheMode = CUTENSOR_CACHE_MODE_NONE;
HANDLE_ERROR(cutensorContractionFindSetAttribute(
&handle,
handle,
&find_copy,
CUTENSOR_CONTRACTION_FIND_CACHE_MODE,
&cacheMode,
sizeof(cutensorCacheMode_t)));

// To take advantage of the incremental-autotuning (via the cache), it's important to re-initialize the plan
HANDLE_ERROR(cutensorInitContractionPlan(&handle,
HANDLE_ERROR(cutensorInitContractionPlan(handle,
&plan,
&desc,
&find_copy,
worksize));

HANDLE_ERROR(cutensorContraction(&handle,
HANDLE_ERROR(cutensorContraction(handle,
&plan,
(void*) &alpha, A_d, B_d,
(void*) &beta, C_d, C_d,
Expand All @@ -375,13 +375,13 @@ int main()
timer.start();

// To take advantage of the incremental-autotuning (via the cache), it's important to re-initialize the plan
HANDLE_ERROR(cutensorInitContractionPlan(&handle,
HANDLE_ERROR(cutensorInitContractionPlan(handle,
&plan,
&desc,
&find,
worksize));

cutensorStatus_t err = cutensorContraction(&handle,
cutensorStatus_t err = cutensorContraction(handle,
&plan,
(void*) &alpha, A_d, B_d,
(void*) &beta, C_d, C_d,
Expand Down Expand Up @@ -409,11 +409,11 @@ int main()
/*
* Optional: Write cache to disk
*/
HANDLE_ERROR( cutensorHandleWriteCacheToFile(&handle, cacheFilename) );
HANDLE_ERROR( cutensorHandleWriteCacheToFile(handle, cacheFilename) );
printf("Cache has been successfully written to file (%s).\n", cacheFilename);

// Detach cache and free-up resources
HANDLE_ERROR( cutensorHandleDetachPlanCachelines(&handle) );
HANDLE_ERROR( cutensorHandleDetachPlanCachelines(handle) );

if (A) free(A);
if (B) free(B);
Expand Down
Loading