Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
e12fcd05
Kaydet (Commit)
e12fcd05
authored
Ock 07, 2015
tarafından
Kohei Yoshida
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Set up foundation for supporting multiple OpenCL command queues per device.
Change-Id: Ia63c8bd6552cdbc2b5eabadaa044b9f1eca5f664
üst
37947afc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
16 deletions
+60
-16
openclwrapper.hxx
include/opencl/openclwrapper.hxx
+9
-1
openclwrapper.cxx
opencl/source/openclwrapper.cxx
+51
-15
No files found.
include/opencl/openclwrapper.hxx
Dosyayı görüntüle @
e12fcd05
...
...
@@ -33,6 +33,7 @@ if( status != CL_SUCCESS ) \
}
#define MAX_CLFILE_NUM 50
#define OPENCL_CMDQUEUE_SIZE 1 // number of command queues per OpenCL device.
#include <cstdio>
...
...
@@ -53,9 +54,10 @@ struct GPUEnv
cl_context
mpContext
;
cl_device_id
*
mpArryDevsID
;
cl_device_id
mpDevID
;
cl_command_queue
mpCmdQueue
;
cl_command_queue
mpCmdQueue
[
OPENCL_CMDQUEUE_SIZE
]
;
cl_program
mpArryPrograms
[
MAX_CLFILE_NUM
];
//one program object maps one kernel source file
int
mnIsUserCreated
;
// 1: created , 0:no create and needed to create by opencl wrapper
int
mnCmdQueuePos
;
bool
mnKhrFp64Flag
;
bool
mnAmdFp64Flag
;
};
...
...
@@ -79,6 +81,12 @@ OPENCL_DLLPUBLIC bool switchOpenCLDevice(const OUString* pDeviceId, bool bAutoSe
OPENCL_DLLPUBLIC
void
getOpenCLDeviceInfo
(
size_t
&
rDeviceId
,
size_t
&
rPlatformId
);
/**
* Set the current command queue position in case of multiple command queues
* for a given device.
*/
OPENCL_DLLPUBLIC
void
setOpenCLCmdQueuePosition
(
int
nPos
);
}
#endif
...
...
opencl/source/openclwrapper.cxx
Dosyayı görüntüle @
e12fcd05
...
...
@@ -89,8 +89,10 @@ OString maCacheFolder = getCacheFolder();
void
setKernelEnv
(
KernelEnv
*
envInfo
)
{
envInfo
->
mpkContext
=
gpuEnv
.
mpContext
;
envInfo
->
mpkCmdQueue
=
gpuEnv
.
mpCmdQueue
;
envInfo
->
mpkProgram
=
gpuEnv
.
mpArryPrograms
[
0
];
assert
(
gpuEnv
.
mnCmdQueuePos
<
OPENCL_CMDQUEUE_SIZE
);
envInfo
->
mpkCmdQueue
=
gpuEnv
.
mpCmdQueue
[
gpuEnv
.
mnCmdQueuePos
];
}
namespace
{
...
...
@@ -259,7 +261,7 @@ struct OpenCLEnv
cl_platform_id
mpOclPlatformID
;
cl_context
mpOclContext
;
cl_device_id
mpOclDevsID
;
cl_command_queue
mpOclCmdQueue
;
cl_command_queue
mpOclCmdQueue
[
OPENCL_CMDQUEUE_SIZE
]
;
};
bool
initOpenCLAttr
(
OpenCLEnv
*
env
)
...
...
@@ -270,10 +272,14 @@ bool initOpenCLAttr( OpenCLEnv * env )
gpuEnv
.
mpContext
=
env
->
mpOclContext
;
gpuEnv
.
mpPlatformID
=
env
->
mpOclPlatformID
;
gpuEnv
.
mpDevID
=
env
->
mpOclDevsID
;
gpuEnv
.
mpCmdQueue
=
env
->
mpOclCmdQueue
;
gpuEnv
.
mnIsUserCreated
=
1
;
for
(
int
i
=
0
;
i
<
OPENCL_CMDQUEUE_SIZE
;
++
i
)
gpuEnv
.
mpCmdQueue
[
i
]
=
env
->
mpOclCmdQueue
[
i
];
gpuEnv
.
mnCmdQueuePos
=
0
;
// default to 0.
return
false
;
}
...
...
@@ -284,11 +290,16 @@ void releaseOpenCLEnv( GPUEnv *gpuInfo )
return
;
}
if
(
gpuEnv
.
mpCmdQueue
)
for
(
int
i
=
0
;
i
<
OPENCL_CMDQUEUE_SIZE
;
++
i
)
{
clReleaseCommandQueue
(
gpuEnv
.
mpCmdQueue
);
gpuEnv
.
mpCmdQueue
=
NULL
;
if
(
gpuEnv
.
mpCmdQueue
[
i
])
{
clReleaseCommandQueue
(
gpuEnv
.
mpCmdQueue
[
i
]);
gpuEnv
.
mpCmdQueue
[
i
]
=
NULL
;
}
}
gpuEnv
.
mnCmdQueuePos
=
0
;
if
(
gpuEnv
.
mpContext
)
{
clReleaseContext
(
gpuEnv
.
mpContext
);
...
...
@@ -761,25 +772,41 @@ bool switchOpenCLDevice(const OUString* pDevice, bool bAutoSelect, bool bForceEv
return
false
;
}
cl_command_queue
command_queue
=
clCreateCommandQueue
(
cl_command_queue
command_queue
[
OPENCL_CMDQUEUE_SIZE
];
for
(
int
i
=
0
;
i
<
OPENCL_CMDQUEUE_SIZE
;
++
i
)
{
command_queue
[
i
]
=
clCreateCommandQueue
(
context
,
pDeviceId
,
CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE
,
&
nState
);
if
(
command_queue
==
NULL
||
nState
!=
CL_SUCCESS
)
{
if
(
command_queue
!=
NULL
)
clReleaseCommandQueue
(
command_queue
);
if
(
command_queue
[
i
]
==
NULL
||
nState
!=
CL_SUCCESS
)
{
// Release all command queues created so far.
for
(
int
j
=
0
;
j
<=
i
;
++
j
)
{
if
(
command_queue
[
j
])
{
clReleaseCommandQueue
(
command_queue
[
j
]);
command_queue
[
j
]
=
NULL
;
}
}
clReleaseContext
(
context
);
SAL_WARN
(
"opencl"
,
"failed to set/switch opencl device"
);
return
false
;
clReleaseContext
(
context
);
SAL_WARN
(
"opencl"
,
"failed to set/switch opencl device"
);
return
false
;
}
}
setOpenCLCmdQueuePosition
(
0
);
// Call this just to avoid the method being deleted from unused function deleter.
releaseOpenCLEnv
(
&
gpuEnv
);
OpenCLEnv
env
;
env
.
mpOclPlatformID
=
platformId
;
env
.
mpOclContext
=
context
;
env
.
mpOclDevsID
=
pDeviceId
;
env
.
mpOclCmdQueue
=
command_queue
;
for
(
int
i
=
0
;
i
<
OPENCL_CMDQUEUE_SIZE
;
++
i
)
env
.
mpOclCmdQueue
[
i
]
=
command_queue
[
i
];
initOpenCLAttr
(
&
env
);
// why do we need this at all?
...
...
@@ -804,6 +831,15 @@ void getOpenCLDeviceInfo(size_t& rDeviceId, size_t& rPlatformId)
findDeviceInfoFromDeviceId
(
id
,
rDeviceId
,
rPlatformId
);
}
void
setOpenCLCmdQueuePosition
(
int
nPos
)
{
if
(
nPos
<
0
||
nPos
>=
OPENCL_CMDQUEUE_SIZE
)
// Out of range. Ignore this.
return
;
gpuEnv
.
mnCmdQueuePos
=
nPos
;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment